Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/startup/startup_browser_creator_win.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_win.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/win/metro.h" | 8 #include "base/win/metro.h" |
| 9 #include "chrome/browser/search_engines/template_url.h" | 9 #include "chrome/browser/search_engines/util.h" |
| 10 #include "chrome/browser/search_engines/template_url_service.h" | |
| 11 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
| 12 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 12 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 15 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 16 #include "win8/util/win8_util.h" | 14 #include "win8/util/win8_util.h" |
| 17 | 15 |
| 18 namespace chrome { | 16 namespace chrome { |
| 19 | 17 |
| 20 GURL GetURLToOpen(Profile* profile) { | 18 GURL GetURLToOpen(Profile* profile) { |
| 21 string16 params; | 19 string16 params; |
|
Jered
2013/06/28 21:57:28
"params" sounds confusingly plural.
Peter Kasting
2013/06/28 22:16:02
It can be plural, AFAICT, in that we can have mult
| |
| 22 base::win::MetroLaunchType launch_type = | 20 base::win::MetroLaunchType launch_type = |
| 23 base::win::GetMetroLaunchParams(¶ms); | 21 base::win::GetMetroLaunchParams(¶ms); |
| 24 | |
| 25 if ((launch_type == base::win::METRO_PROTOCOL) || | 22 if ((launch_type == base::win::METRO_PROTOCOL) || |
| 26 (launch_type == base::win::METRO_LAUNCH)) { | 23 (launch_type == base::win::METRO_LAUNCH)) |
| 27 return GURL(params); | 24 return GURL(params); |
| 28 } else if (launch_type == base::win::METRO_SEARCH) { | 25 return (launch_type == base::win::METRO_SEARCH) ? |
| 29 const TemplateURL* default_provider = | 26 GetDefaultSearchURLForSearchTerms(profile, params) : GURL(); |
| 30 TemplateURLServiceFactory::GetForProfile(profile)-> | |
| 31 GetDefaultSearchProvider(); | |
| 32 if (default_provider) { | |
| 33 const TemplateURLRef& search_url = default_provider->url_ref(); | |
| 34 DCHECK(search_url.SupportsReplacement()); | |
| 35 return GURL(search_url.ReplaceSearchTerms( | |
| 36 TemplateURLRef::SearchTermsArgs(params))); | |
| 37 } | |
| 38 } | |
| 39 return GURL(); | |
| 40 } | 27 } |
| 41 | 28 |
| 42 } // namespace chrome | 29 } // namespace chrome |
| 43 | 30 |
| 44 // static | 31 // static |
| 45 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( | 32 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( |
| 46 Profile* profile, | 33 Profile* profile, |
| 47 const std::vector<GURL>& startup_urls) { | 34 const std::vector<GURL>& startup_urls) { |
| 48 if (!win8::IsSingleWindowMetroMode()) | 35 if (!win8::IsSingleWindowMetroMode()) |
| 49 return false; | 36 return false; |
| 50 | 37 |
| 51 // We activate an existing browser window if we are opening just the new tab | 38 // We activate an existing browser window if we are opening just the new tab |
| 52 // page in metro mode. | 39 // page in metro mode. |
| 53 if (startup_urls.size() > 1) | 40 if (startup_urls.size() > 1) |
| 54 return false; | 41 return false; |
| 55 | 42 |
| 56 if (startup_urls[0] != GURL(chrome::kChromeUINewTabURL)) | 43 if (startup_urls[0] != GURL(chrome::kChromeUINewTabURL)) |
| 57 return false; | 44 return false; |
| 58 | 45 |
| 59 Browser* browser = chrome::FindBrowserWithProfile( | 46 Browser* browser = chrome::FindBrowserWithProfile( |
| 60 profile, chrome::HOST_DESKTOP_TYPE_NATIVE); | 47 profile, chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 61 | 48 |
| 62 if (!browser) | 49 if (!browser) |
| 63 return false; | 50 return false; |
| 64 | 51 |
| 65 browser->window()->Show(); | 52 browser->window()->Show(); |
| 66 return true; | 53 return true; |
| 67 } | 54 } |
| OLD | NEW |