OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/startup/startup_browser_creator_win.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/win/metro.h" | |
9 #include "chrome/browser/search_engines/util.h" | |
10 #include "chrome/browser/ui/browser_finder.h" | |
11 #include "chrome/browser/ui/browser_window.h" | |
12 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | |
13 #include "chrome/common/url_constants.h" | |
14 #include "win8/util/win8_util.h" | |
15 | |
16 namespace chrome { | |
17 | |
18 GURL GetURLToOpen(Profile* profile) { | |
19 base::string16 params; | |
20 base::win::MetroLaunchType launch_type = | |
21 base::win::GetMetroLaunchParams(¶ms); | |
22 if ((launch_type == base::win::METRO_PROTOCOL) || | |
23 (launch_type == base::win::METRO_LAUNCH)) | |
24 return GURL(params); | |
25 return (launch_type == base::win::METRO_SEARCH) ? | |
26 GetDefaultSearchURLForSearchTerms(profile, params) : GURL(); | |
27 } | |
28 | |
29 } // namespace chrome | |
30 | |
31 // static | |
32 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( | |
33 Profile* profile, | |
34 const std::vector<GURL>& startup_urls) { | |
35 if (!win8::IsSingleWindowMetroMode()) | |
36 return false; | |
37 | |
38 // We activate an existing browser window if we are opening just the new tab | |
39 // page in metro mode. | |
40 if (startup_urls.size() > 1) | |
41 return false; | |
42 | |
43 if (startup_urls[0] != GURL(chrome::kChromeUINewTabURL)) | |
44 return false; | |
45 | |
46 Browser* browser = chrome::FindBrowserWithProfile( | |
47 profile, chrome::HOST_DESKTOP_TYPE_NATIVE); | |
48 | |
49 if (!browser) | |
50 return false; | |
51 | |
52 browser->window()->Show(); | |
53 return true; | |
54 } | |
OLD | NEW |