Index: chrome/browser/ui/startup/startup_browser_creator_impl.cc |
=================================================================== |
--- chrome/browser/ui/startup/startup_browser_creator_impl.cc (revision 161954) |
+++ chrome/browser/ui/startup/startup_browser_creator_impl.cc (working copy) |
@@ -111,6 +111,7 @@ |
#endif |
#if defined(OS_WIN) |
+#include "base/win/metro.h" |
#include "base/win/windows_version.h" |
#endif |
@@ -298,6 +299,39 @@ |
DISALLOW_COPY_AND_ASSIGN(WebContentsCloseObserver); |
}; |
+// Platform specific helper to activate an existing Browser instance for the |
+// profile passed in. Defaults to returning false. For Windows 8 in metro mode |
+// we activate an existing browser if the startup urls contains only the new |
+// tab page. |
+#if defined(OS_WIN) && !defined(USE_AURA) |
+bool PlatformActivateBrowserForProfile( |
+ Profile* profile, const std::vector<GURL>& startup_urls) { |
+ if (!base::win::IsMetroProcess()) |
+ return false; |
+ |
+ // We activate an existing browser window if we are opening just the new tab |
+ // page in metro mode. |
+ if (startup_urls.size() > 1) |
+ return false; |
+ |
+ if (startup_urls[0] != GURL(chrome::kChromeUINewTabURL)) |
+ return false; |
+ |
+ Browser* browser = browser::FindBrowserWithProfile( |
+ profile, chrome::HOST_DESKTOP_TYPE_NATIVE); |
+ |
+ if (!browser) |
+ return false; |
+ |
+ browser->window()->Show(); |
+} |
+#else |
+bool PlatformActivateBrowserForProfile( |
+ Profile* profile, const std::vector<GURL>& startup_urls) { |
+ return false; |
+} |
+#endif |
+ |
} // namespace |
StartupBrowserCreatorImpl::StartupBrowserCreatorImpl( |
@@ -617,12 +651,13 @@ |
std::vector<GURL> adjust_urls = urls_to_open; |
if (adjust_urls.empty()) { |
AddStartupURLs(&adjust_urls); |
+ if (PlatformActivateBrowserForProfile(profile_, adjust_urls)) |
sky
2012/10/16 15:46:30
Name this OpenStartupURLsInExistingBrowser and mov
ananta
2012/10/16 18:44:49
The function does not open the startup urls. It ac
sky
2012/10/16 21:11:08
Logically this method is called during startup to
ananta
2012/10/16 21:17:44
Fair enough. Done.
|
+ return; |
} else if (!command_line_.HasSwitch(switches::kOpenInNewWindow)) { |
// Always open a list of urls in a window on the native desktop. |
browser = browser::FindBrowserWithProfile(profile_, |
chrome::HOST_DESKTOP_TYPE_NATIVE); |
} |
- |
// This will launch a browser; prevent session restore. |
in_synchronous_profile_launch = true; |
browser = OpenURLsInBrowser(browser, process_startup, adjust_urls); |