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

Unified Diff: chrome/browser/search/search.cc

Issue 14715010: Formatting fix. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/search/search_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/search.cc
diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc
index b3f7fd7e7d4c6be093fa8875022e53371d9fc299..e213dd4c0ca762cface9220cb52e4c2f56f51df9 100644
--- a/chrome/browser/search/search.cc
+++ b/chrome/browser/search/search.cc
@@ -132,6 +132,38 @@ void RecordInstantExtendedOptInState(OptInState state) {
}
}
+// Helper for EmbeddedSearchPageVersion. Does not check if in incognito mode.
+uint64 EmbeddedSearchPageVersionHelper() {
+ // No server-side changes if the local-only Instant Extended is enabled.
+ if (IsLocalOnlyInstantExtendedAPIEnabled())
+ return kEmbeddedPageVersionDisabled;
+
+ // Check the command-line/about:flags setting first, which should have
+ // precedence and allows the trial to not be reported (if it's never queried).
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI)) {
+ RecordInstantExtendedOptInState(OPT_OUT);
+ return kEmbeddedPageVersionDisabled;
+ }
+ if (command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) {
+ // The user has set the about:flags switch to Enabled - give the default
+ // UI version.
+ RecordInstantExtendedOptInState(OPT_IN);
+ return kEmbeddedPageVersionDefault;
+ }
+
+ RecordInstantExtendedOptInState(NOT_SET);
+ FieldTrialFlags flags;
+ if (GetFieldTrialInfo(
+ base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName),
+ &flags, NULL)) {
+ return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName,
+ kEmbeddedPageVersionDefault,
+ flags);
+ }
+ return kEmbeddedPageVersionDisabled;
+}
+
// Returns true if |contents| is rendered inside the Instant process for
// |profile|.
bool IsRenderedInInstantProcess(const content::WebContents* contents,
@@ -189,9 +221,6 @@ bool IsInstantURL(const GURL& url, Profile* profile) {
string16 GetSearchTermsImpl(const content::WebContents* contents,
const content::NavigationEntry* entry) {
- if (!IsQueryExtractionEnabled())
- return string16();
-
// For security reasons, don't extract search terms if the page is not being
// rendered in the privileged Instant renderer process. This is to protect
// against a malicious page somehow scripting the search results page and
@@ -201,6 +230,10 @@ string16 GetSearchTermsImpl(const content::WebContents* contents,
// Since iOS and Android doesn't use the instant framework, these checks are
// disabled for the two platforms.
Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
+
+ if (!IsQueryExtractionEnabled(profile))
+ return string16();
+
#if !defined(OS_IOS) && !defined(OS_ANDROID)
if (!IsRenderedInInstantProcess(contents, profile) &&
(contents->GetController().GetLastCommittedEntry() == entry ||
@@ -238,47 +271,26 @@ bool IsInstantExtendedAPIEnabled() {
#if defined(OS_IOS) || defined(OS_ANDROID)
return false;
#else
- // On desktop, query extraction is part of Instant extended, so if one is
- // enabled, the other is too.
- return IsQueryExtractionEnabled() || IsLocalOnlyInstantExtendedAPIEnabled();
+ // TODO(dougw): Switch to EmbeddedSearchPageVersion after the proper
+ // solution to Issue 232065 has been implemented.
+ return EmbeddedSearchPageVersionHelper() ||
+ IsLocalOnlyInstantExtendedAPIEnabled();
#endif // defined(OS_IOS) || defined(OS_ANDROID)
}
// Determine what embedded search page version to request from the user's
// default search provider. If 0, the embedded search UI should not be enabled.
-uint64 EmbeddedSearchPageVersion() {
- // No server-side changes if the local-only Instant Extended is enabled.
- if (IsLocalOnlyInstantExtendedAPIEnabled())
- return kEmbeddedPageVersionDisabled;
-
- // Check the command-line/about:flags setting first, which should have
- // precedence and allows the trial to not be reported (if it's never queried).
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI)) {
- RecordInstantExtendedOptInState(OPT_OUT);
+uint64 EmbeddedSearchPageVersion(Profile* profile) {
+ // Disable for incognito. Temporary fix for Issue 232065.
+#if !defined(OS_IOS) && !defined(OS_ANDROID)
+ if (profile && profile->IsOffTheRecord())
return kEmbeddedPageVersionDisabled;
- }
- if (command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) {
- // The user has set the about:flags switch to Enabled - give the default
- // UI version.
- RecordInstantExtendedOptInState(OPT_IN);
- return kEmbeddedPageVersionDefault;
- }
-
- RecordInstantExtendedOptInState(NOT_SET);
- FieldTrialFlags flags;
- if (GetFieldTrialInfo(
- base::FieldTrialList::FindFullName(kInstantExtendedFieldTrialName),
- &flags, NULL)) {
- return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName,
- kEmbeddedPageVersionDefault,
- flags);
- }
- return kEmbeddedPageVersionDisabled;
+#endif // !defined(OS_IOS) && !defined(OS_ANDROID)
+ return EmbeddedSearchPageVersionHelper();
}
-bool IsQueryExtractionEnabled() {
- return EmbeddedSearchPageVersion() != kEmbeddedPageVersionDisabled;
+bool IsQueryExtractionEnabled(Profile* profile) {
+ return EmbeddedSearchPageVersion(profile) != kEmbeddedPageVersionDisabled;
}
bool IsLocalOnlyInstantExtendedAPIEnabled() {
« 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