MacPWAs: Reparent tabs when installing PWAs

This works now. When re-parenting the window, the initial attempt to
re-parent the window fails, because the PWA's bundle has not yet
been created. The second attempt then re-creates the bundle and
succeeds. This is a bit kludgey in that it is possible that the bundle
will be recreated twice.

A cleaner solution would be to delay reparenting the contents and
revealing the app in Finder until the app has been created, but that
solution may not be suitable for merge.

(cherry picked from commit 96b864cc836925ac0756772dcf1d7435205767c6)

Bug: 915571
Change-Id: Ifaf507525729a9a168e821f722aee03e9f6dd8f4
Reviewed-by: Ben Wells <>
Reviewed-by: Dominick Ng <>
Commit-Queue: ccameron <>
Cr-Original-Commit-Position: refs/heads/master@{#627151}
Reviewed-by: ccameron <>
Cr-Commit-Position: refs/branch-heads/3683@{#128}
Cr-Branched-From: e51029943e0a38dd794b73caaf6373d5496ae783-refs/heads/master@{#625896}
diff --git a/chrome/browser/extensions/ b/chrome/browser/extensions/
index bffd882..d13ce386 100644
--- a/chrome/browser/extensions/
+++ b/chrome/browser/extensions/
@@ -530,6 +530,7 @@
 #endif  // !defined(OS_CHROMEOS)
+#endif  // !defined(OS_MACOSX)
   // Reparent the tab into an app window immediately when opening as a window.
   if (!silent_install &&
@@ -537,7 +538,6 @@
       launch_type == LAUNCH_TYPE_WINDOW && !profile_->IsOffTheRecord()) {
     ReparentWebContentsIntoAppBrowser(contents_, extension);
-#endif  // !defined(OS_MACOSX)
   callback_.Run(extension, web_app_info_);
diff --git a/chrome/browser/extensions/ b/chrome/browser/extensions/
index debe2c5..6428014 100644
--- a/chrome/browser/extensions/
+++ b/chrome/browser/extensions/
@@ -183,12 +183,10 @@
   Wait();  // Quits when the extension install completes.
-#if !defined(OS_MACOSX)
   // We do not reparent the tab on OS X.
   Browser* app_browser = chrome::FindBrowserWithWebContents(web_contents());
   EXPECT_NE(app_browser, browser());
-#endif  // defined(OS_MACOSX)
 }  // namespace extensions