Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: chrome/browser/ui/startup/startup_browser_creator.cc

Issue 1598553003: Implement the Windows desktop search redirection feature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build errors due to prefs being moved in components Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 fe1a914f533d9fb27c46d1cd32335c9f92b3372c..f361b35ea37031243b7617047d14f158120c8b0b 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -98,7 +98,7 @@
#if defined(OS_WIN)
#include "chrome/browser/metrics/jumplist_metrics_win.h"
-#include "components/search_engines/desktop_search_win.h"
+#include "components/search_engines/desktop_search_utils.h"
#endif
#if defined(ENABLE_PRINT_PREVIEW)
@@ -307,8 +307,8 @@ bool ShowUserManagerOnStartupIfNeeded(
StartupBrowserCreator::StartupBrowserCreator()
: is_default_browser_dialog_suppressed_(false),
- show_main_browser_window_(true) {
-}
+ show_main_browser_window_(true),
+ show_desktop_search_redirection_infobar_(false) {}
StartupBrowserCreator::~StartupBrowserCreator() {}
@@ -372,7 +372,8 @@ 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);
+ GetURLsFromCommandLine(command_line, cur_dir, profile,
+ &show_desktop_search_redirection_infobar_);
chrome::HostDesktopType host_desktop_type =
chrome::HOST_DESKTOP_TYPE_NATIVE;
@@ -531,7 +532,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* show_desktop_search_redirection_infobar) {
+ DCHECK(profile);
+ DCHECK(show_desktop_search_redirection_infobar);
+
std::vector<GURL> urls;
const base::CommandLine::StringVector& params = command_line.GetArgs();
@@ -558,23 +563,14 @@ std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine(
GURL url = GURL(param.MaybeAsASCII());
#if defined(OS_WIN)
- 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)) {
- base::RecordAction(base::UserMetricsAction("DesktopSearch"));
-
- if (ShouldRedirectWindowsDesktopSearchToDefaultSearchEngine(
- profile->GetPrefs())) {
- 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 are multiple command line arguments, because
+ // desktop search never passes multiple URLs to the browser.
+ if (params.size() == 1) {
+ *show_desktop_search_redirection_infobar =
+ ReplaceDesktopSearchURLWithDefaultSearchURLIfNeeded(
+ profile->GetPrefs(),
+ TemplateURLServiceFactory::GetForProfile(profile), &url);
}
#endif // defined(OS_WIN)
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator.h ('k') | chrome/browser/ui/startup/startup_browser_creator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698