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

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

Issue 11876045: [Search] Store and recall search terms using NavigationEntry to improve search term extraction (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: reupload Created 7 years, 10 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
« no previous file with comments | « chrome/browser/ui/search/search.h ('k') | content/browser/web_contents/navigation_entry_impl.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/ui/search/search.h" 5 #include "chrome/browser/ui/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/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/chrome_version_info.h" 14 #include "chrome/common/chrome_version_info.h"
15 #include "content/public/browser/navigation_entry.h"
15 16
16 #if !defined(OS_ANDROID) 17 #if !defined(OS_ANDROID)
17 #include "chrome/browser/themes/theme_service.h" 18 #include "chrome/browser/themes/theme_service.h"
18 #include "chrome/browser/themes/theme_service_factory.h" 19 #include "chrome/browser/themes/theme_service_factory.h"
19 #endif 20 #endif
20 21
21 namespace { 22 namespace {
22 23
23 // Configuration options for Embedded Search. 24 // Configuration options for Embedded Search.
24 // InstantExtended field trials are named in such a way that we can parse out 25 // InstantExtended field trials are named in such a way that we can parse out
(...skipping 14 matching lines...) Expand all
39 40
40 // If the field trial's group name ends with this string its configuration will 41 // If the field trial's group name ends with this string its configuration will
41 // be ignored and Instant Extended will not be enabled by default. 42 // be ignored and Instant Extended will not be enabled by default.
42 const char kDisablingSuffix[] = "DISABLED"; 43 const char kDisablingSuffix[] = "DISABLED";
43 44
44 } // namespace 45 } // namespace
45 46
46 namespace chrome { 47 namespace chrome {
47 namespace search { 48 namespace search {
48 49
50 // static
51 const char kInstantExtendedSearchTermsKey[] = "search_terms";
52
49 // Check whether or not the Extended API should be used on the given profile. 53 // Check whether or not the Extended API should be used on the given profile.
50 bool IsInstantExtendedAPIEnabled(Profile* profile) { 54 bool IsInstantExtendedAPIEnabled(Profile* profile) {
51 return EmbeddedSearchPageVersion(profile) != 0; 55 return EmbeddedSearchPageVersion(profile) != 0;
52 } 56 }
53 57
54 // Determine what embedded search page version to request from the user's 58 // Determine what embedded search page version to request from the user's
55 // default search provider. If 0, the embedded search UI should not be enabled. 59 // default search provider. If 0, the embedded search UI should not be enabled.
56 // Note that the profile object here isn't const because we need to determine 60 // Note that the profile object here isn't const because we need to determine
57 // whether or not the user has a theme installed as part of this check, and 61 // whether or not the user has a theme installed as part of this check, and
58 // that logic requires a non-const profile for whatever reason. 62 // that logic requires a non-const profile for whatever reason.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 CommandLine::ForCurrentProcess()->AppendSwitch( 136 CommandLine::ForCurrentProcess()->AppendSwitch(
133 switches::kEnableQueryExtraction); 137 switches::kEnableQueryExtraction);
134 #else 138 #else
135 // On desktop, query extraction is controlled by the instant-extended-api 139 // On desktop, query extraction is controlled by the instant-extended-api
136 // flag. 140 // flag.
137 CommandLine::ForCurrentProcess()->AppendSwitch( 141 CommandLine::ForCurrentProcess()->AppendSwitch(
138 switches::kEnableInstantExtendedAPI); 142 switches::kEnableInstantExtendedAPI);
139 #endif 143 #endif
140 } 144 }
141 145
146 string16 GetSearchTermsFromNavigationEntry(
147 const content::NavigationEntry* entry) {
148 string16 search_terms;
149 entry->GetExtraData(kInstantExtendedSearchTermsKey, &search_terms);
150 return search_terms;
151 }
152
142 bool IsForcedInstantURL(const GURL& url) { 153 bool IsForcedInstantURL(const GURL& url) {
143 CommandLine* command_line = CommandLine::ForCurrentProcess(); 154 CommandLine* command_line = CommandLine::ForCurrentProcess();
144 if (!command_line->HasSwitch(switches::kInstantURL)) 155 if (!command_line->HasSwitch(switches::kInstantURL))
145 return false; 156 return false;
146 157
147 GURL instant_url(command_line->GetSwitchValueASCII(switches::kInstantURL)); 158 GURL instant_url(command_line->GetSwitchValueASCII(switches::kInstantURL));
148 return url.scheme() == instant_url.scheme() && 159 return url.scheme() == instant_url.scheme() &&
149 url.host() == instant_url.host() && 160 url.host() == instant_url.host() &&
150 url.port() == instant_url.port() && 161 url.port() == instant_url.port() &&
151 url.path() == instant_url.path(); 162 url.path() == instant_url.path();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 214
204 // Given a FieldTrialFlags object, returns the boolean value of the provided 215 // Given a FieldTrialFlags object, returns the boolean value of the provided
205 // flag. 216 // flag.
206 bool GetBoolValueForFlagWithDefault( 217 bool GetBoolValueForFlagWithDefault(
207 const std::string& flag, bool default_value, FieldTrialFlags& flags) { 218 const std::string& flag, bool default_value, FieldTrialFlags& flags) {
208 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 219 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
209 } 220 }
210 221
211 } // namespace search 222 } // namespace search
212 } // namespace chrome 223 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search.h ('k') | content/browser/web_contents/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698