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

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

Issue 13905008: Merge local_omnibox_popup into local_ntp. Render the Google logo and fakebox if Google is the sear… (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Addressing comments. Created 7 years, 8 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
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/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/search/instant_service.h" 14 #include "chrome/browser/search/instant_service.h"
15 #include "chrome/browser/search/instant_service_factory.h" 15 #include "chrome/browser/search/instant_service_factory.h"
16 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
16 #include "chrome/browser/search_engines/template_url_service.h" 17 #include "chrome/browser/search_engines/template_url_service.h"
17 #include "chrome/browser/search_engines/template_url_service_factory.h" 18 #include "chrome/browser/search_engines/template_url_service_factory.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
21 #include "components/user_prefs/pref_registry_syncable.h" 22 #include "components/user_prefs/pref_registry_syncable.h"
22 #include "content/public/browser/navigation_entry.h" 23 #include "content/public/browser/navigation_entry.h"
23 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 26
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 329
329 bool NavEntryIsInstantNTP(const content::WebContents* contents, 330 bool NavEntryIsInstantNTP(const content::WebContents* contents,
330 const content::NavigationEntry* entry) { 331 const content::NavigationEntry* entry) {
331 if (!contents || !entry) 332 if (!contents || !entry)
332 return false; 333 return false;
333 334
334 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 335 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
335 return IsInstantExtendedAPIEnabled() && 336 return IsInstantExtendedAPIEnabled() &&
336 IsRenderedInInstantProcess(contents, profile) && 337 IsRenderedInInstantProcess(contents, profile) &&
337 (IsInstantURL(entry->GetVirtualURL(), profile) || 338 (IsInstantURL(entry->GetVirtualURL(), profile) ||
338 entry->GetVirtualURL() == GURL(chrome::kChromeSearchLocalNtpUrl)) && 339 entry->GetVirtualURL() == GetLocalInstantURL(profile)) &&
339 GetSearchTermsImpl(contents, entry).empty(); 340 GetSearchTermsImpl(contents, entry).empty();
340 } 341 }
341 342
342 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) { 343 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) {
343 return url.is_valid() && 344 return url.is_valid() &&
344 profile && 345 profile &&
345 (url.SchemeIs(chrome::kChromeSearchScheme) || 346 (url.SchemeIs(chrome::kChromeSearchScheme) ||
346 IsInstantURL(url, profile)); 347 IsInstantURL(url, profile));
347 } 348 }
348 349
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 const std::string secure_scheme = chrome::kHttpsScheme; 460 const std::string secure_scheme = chrome::kHttpsScheme;
460 GURL::Replacements replacements; 461 GURL::Replacements replacements;
461 replacements.SetSchemeStr(secure_scheme); 462 replacements.SetSchemeStr(secure_scheme);
462 instant_url = instant_url.ReplaceComponents(replacements); 463 instant_url = instant_url.ReplaceComponents(replacements);
463 } 464 }
464 } 465 }
465 466
466 return instant_url; 467 return instant_url;
467 } 468 }
468 469
470 GURL GetLocalInstantURL(Profile* profile) {
471 const TemplateURL* default_provider =
472 GetDefaultSearchProviderTemplateURL(profile);
473
474 if (default_provider &&
475 (TemplateURLPrepopulateData::GetEngineType(default_provider->url()) ==
476 SEARCH_ENGINE_GOOGLE)) {
477 return GURL(chrome::kChromeSearchLocalGoogleNtpUrl);
478 }
479 return GURL(chrome::kChromeSearchLocalNtpUrl);
480 }
481
469 bool IsInstantEnabled(Profile* profile) { 482 bool IsInstantEnabled(Profile* profile) {
470 return GetInstantURL(profile, kDisableStartMargin).is_valid(); 483 return GetInstantURL(profile, kDisableStartMargin).is_valid();
471 } 484 }
472 485
473 bool IsAggressiveLocalNTPFallbackEnabled() { 486 bool IsAggressiveLocalNTPFallbackEnabled() {
474 // Check the command-line/about:flags setting first, which should have 487 // Check the command-line/about:flags setting first, which should have
475 // precedence and allows the trial to not be reported (if it's never queried). 488 // precedence and allows the trial to not be reported (if it's never queried).
476 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 489 const CommandLine* command_line = CommandLine::ForCurrentProcess();
477 if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) || 490 if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) ||
478 command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) { 491 command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 replacements.SetHostStr(search_host); 611 replacements.SetHostStr(search_host);
599 replacements.SetPortStr(search_port); 612 replacements.SetPortStr(search_port);
600 return instant_url.ReplaceComponents(replacements); 613 return instant_url.ReplaceComponents(replacements);
601 } 614 }
602 615
603 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) { 616 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) {
604 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path(); 617 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path();
605 } 618 }
606 619
607 } // namespace chrome 620 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698