Chromium Code Reviews| Index: chrome/browser/ui/startup/startup_browser_creator.cc |
| diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc |
| index 72487b014c39a1440800051a943cef9114e7ccd1..e74cfe1e68b4dc017f43145c3cd1b05ea5edf128 100644 |
| --- a/chrome/browser/ui/startup/startup_browser_creator.cc |
| +++ b/chrome/browser/ui/startup/startup_browser_creator.cc |
| @@ -95,8 +95,13 @@ |
| #endif |
| #if defined(OS_WIN) |
| +#include "chrome/browser/infobars/infobar_service.h" |
| #include "chrome/browser/metrics/jumplist_metrics_win.h" |
| -#include "components/search_engines/desktop_search_win.h" |
| +#include "chrome/browser/ui/browser_list.h" |
| +#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "components/search_engines/desktop_search_infobar_delegate_win.h" |
| +#include "components/search_engines/desktop_search_utils_win.h" |
| +#include "components/search_engines/template_url.h" |
| #endif |
| #if defined(ENABLE_PRINT_PREVIEW) |
| @@ -369,8 +374,9 @@ bool StartupBrowserCreator::LaunchBrowser( |
| if (!silent_launch) { |
| StartupBrowserCreatorImpl lwp(cur_dir, command_line, this, is_first_run); |
| - const std::vector<GURL> urls_to_launch = |
| - GetURLsFromCommandLine(command_line, cur_dir, profile); |
| + bool should_show_desktop_search_infobar = false; |
| + const std::vector<GURL> urls_to_launch = GetURLsFromCommandLine( |
| + command_line, cur_dir, profile, &should_show_desktop_search_infobar); |
| chrome::HostDesktopType host_desktop_type = |
| chrome::HOST_DESKTOP_TYPE_NATIVE; |
| @@ -391,6 +397,26 @@ bool StartupBrowserCreator::LaunchBrowser( |
| LOG(ERROR) << "launch error"; |
| return false; |
| } |
| + |
| +#if defined(OS_WIN) |
| + if (should_show_desktop_search_infobar) { |
| + // Show an infobar informing the user that a desktop search has been |
| + // redirected to the default search engine. |
| + Browser* browser = |
| + BrowserList::GetInstance(host_desktop_type)->GetLastActive(); |
|
Peter Kasting
2016/01/20 03:03:01
We ultimately only need this in order to get the a
fdoray
2016/01/21 21:02:33
Done. I moved this code to StartupBrowserCreatorIm
|
| + if (browser) { |
|
Peter Kasting
2016/01/20 03:03:01
When can this be null?
fdoray
2016/01/21 21:02:33
chrome.exe --no-startup-window
|
| + WindowsDesktopSearchInfobarDelegate::Show( |
| + InfoBarService::FromWebContents( |
| + browser->tab_strip_model()->GetActiveWebContents()), |
| + TemplateURLServiceFactory::GetForProfile(profile) |
| + ->GetDefaultSearchProvider() |
| + ->AdjustedShortNameForLocaleDirection(), |
| + GURL(std::string(chrome::kChromeUISettingsURL) + |
| + chrome::kSearchEnginesSubPage), |
| + profile->GetPrefs()); |
| + } |
| + } |
| +#endif // defined(OS_WIN) |
| } else { |
| in_synchronous_profile_launch_ = false; |
| } |
| @@ -529,7 +555,11 @@ const wchar_t* StartupBrowserCreator::GetDefaultBrowserUrl() { |
| std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( |
| const base::CommandLine& command_line, |
| const base::FilePath& cur_dir, |
| - Profile* profile) { |
| + Profile* profile, |
| + bool* should_show_desktop_search_infobar) { |
| + DCHECK(profile); |
| + DCHECK(should_show_desktop_search_infobar); |
| + |
| std::vector<GURL> urls; |
| const base::CommandLine::StringVector& params = command_line.GetArgs(); |
| @@ -556,21 +586,14 @@ std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( |
| GURL url = GURL(param.MaybeAsASCII()); |
| #if defined(OS_WIN) |
| - if (ShouldRedirectWindowsDesktopSearchToDefaultSearchEngine( |
| - profile->GetPrefs())) { |
| - TemplateURLService* template_url_service = |
| - TemplateURLServiceFactory::GetForProfile(profile); |
| - DCHECK(template_url_service); |
| - base::string16 search_terms; |
| - if (DetectWindowsDesktopSearch( |
| - url, template_url_service->search_terms_data(), &search_terms)) { |
| - const GURL search_url(GetDefaultSearchURLForSearchTerms( |
| - template_url_service, search_terms)); |
| - if (search_url.is_valid()) { |
| - urls.push_back(search_url); |
| - continue; |
| - } |
| - } |
| + // Replace desktop search URL by a default search engine URL if needed. |
| + // Ignore cases where there is multiple command line arguments, because |
|
Peter Kasting
2016/01/20 03:03:01
Nit: is -> are
fdoray
2016/01/21 21:02:33
Done.
|
| + // desktop search never passes multiple URLs to the browser. |
| + if (params.size() == 1) { |
| + ReplaceWindowsDesktopSearchURLWithDefaultSearchURLIfNeeded( |
| + profile->GetPrefs(), |
| + TemplateURLServiceFactory::GetForProfile(profile), &url, |
| + should_show_desktop_search_infobar); |
| } |
| #endif // defined(OS_WIN) |