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

Side by Side Diff: chrome/browser/search/search.cc

Issue 19054012: Reload Local NTP on default search provider change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/search/search_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/search/search.h" 5 #include "chrome/browser/search/search.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "chrome/browser/google/google_util.h" 14 #include "chrome/browser/google/google_util.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/search/instant_service.h" 16 #include "chrome/browser/search/instant_service.h"
17 #include "chrome/browser/search/instant_service_factory.h" 17 #include "chrome/browser/search/instant_service_factory.h"
18 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
19 #include "chrome/browser/search_engines/template_url_service.h" 18 #include "chrome/browser/search_engines/template_url_service.h"
20 #include "chrome/browser/search_engines/template_url_service_factory.h" 19 #include "chrome/browser/search_engines/template_url_service_factory.h"
21 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_instant_controller.h" 21 #include "chrome/browser/ui/browser_instant_controller.h"
23 #include "chrome/browser/ui/browser_iterator.h" 22 #include "chrome/browser/ui/browser_iterator.h"
24 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
27 #include "components/sessions/serialized_navigation_entry.h" 26 #include "components/sessions/serialized_navigation_entry.h"
28 #include "components/user_prefs/pref_registry_syncable.h" 27 #include "components/user_prefs/pref_registry_syncable.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 if (instant_url.SchemeIsSecure() || 340 if (instant_url.SchemeIsSecure() ||
342 google_util::StartsWithCommandLineGoogleBaseURL(instant_url)) 341 google_util::StartsWithCommandLineGoogleBaseURL(instant_url))
343 return instant_url; 342 return instant_url;
344 GURL::Replacements replacements; 343 GURL::Replacements replacements;
345 const std::string secure_scheme(chrome::kHttpsScheme); 344 const std::string secure_scheme(chrome::kHttpsScheme);
346 replacements.SetSchemeStr(secure_scheme); 345 replacements.SetSchemeStr(secure_scheme);
347 return instant_url.ReplaceComponents(replacements); 346 return instant_url.ReplaceComponents(replacements);
348 } 347 }
349 348
350 GURL GetLocalInstantURL(Profile* profile) { 349 GURL GetLocalInstantURL(Profile* profile) {
351 const TemplateURL* default_provider =
352 GetDefaultSearchProviderTemplateURL(profile);
353
354 if (default_provider &&
355 (TemplateURLPrepopulateData::GetEngineType(default_provider->url()) ==
356 SEARCH_ENGINE_GOOGLE)) {
357 return GURL(chrome::kChromeSearchLocalGoogleNtpUrl);
358 }
359 return GURL(chrome::kChromeSearchLocalNtpUrl); 350 return GURL(chrome::kChromeSearchLocalNtpUrl);
360 } 351 }
361 352
362 bool ShouldPreferRemoteNTPOnStartup() { 353 bool ShouldPreferRemoteNTPOnStartup() {
363 // Check the command-line/about:flags setting first, which should have 354 // Check the command-line/about:flags setting first, which should have
364 // precedence and allows the trial to not be reported (if it's never queried). 355 // precedence and allows the trial to not be reported (if it's never queried).
365 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 356 const CommandLine* command_line = CommandLine::ForCurrentProcess();
366 if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) || 357 if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) ||
367 command_line->HasSwitch(switches::kEnableLocalFirstLoadNTP)) { 358 command_line->HasSwitch(switches::kEnableLocalFirstLoadNTP)) {
368 return false; 359 return false;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 bool default_value, 533 bool default_value,
543 const FieldTrialFlags& flags) { 534 const FieldTrialFlags& flags) {
544 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 535 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
545 } 536 }
546 537
547 void ResetInstantExtendedOptInStateGateForTest() { 538 void ResetInstantExtendedOptInStateGateForTest() {
548 instant_extended_opt_in_state_gate = false; 539 instant_extended_opt_in_state_gate = false;
549 } 540 }
550 541
551 } // namespace chrome 542 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/search/search_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698