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

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: const 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
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/string16.h"
sreeram 2013/01/30 21:41:39 Nit: No need for this (since it's already included
Mathieu 2013/01/30 21:55:12 Done.
9 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 11 #include "base/string_split.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/chrome_version_info.h" 15 #include "chrome/common/chrome_version_info.h"
16 #include "content/public/browser/navigation_entry.h"
15 17
16 #if !defined(OS_ANDROID) 18 #if !defined(OS_ANDROID)
17 #include "chrome/browser/themes/theme_service.h" 19 #include "chrome/browser/themes/theme_service.h"
18 #include "chrome/browser/themes/theme_service_factory.h" 20 #include "chrome/browser/themes/theme_service_factory.h"
19 #endif 21 #endif
20 22
21 namespace { 23 namespace {
22 24
23 // Configuration options for Embedded Search. 25 // Configuration options for Embedded Search.
24 // InstantExtended field trials are named in such a way that we can parse out 26 // InstantExtended field trials are named in such a way that we can parse out
(...skipping 14 matching lines...) Expand all
39 41
40 // If the field trial's group name ends with this string its configuration will 42 // 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. 43 // be ignored and Instant Extended will not be enabled by default.
42 const char kDisablingSuffix[] = "DISABLED"; 44 const char kDisablingSuffix[] = "DISABLED";
43 45
44 } // namespace 46 } // namespace
45 47
46 namespace chrome { 48 namespace chrome {
47 namespace search { 49 namespace search {
48 50
51 // static
52 const char kInstantExtendedSearchTermsKey[] = "search_terms";
53
49 // Check whether or not the Extended API should be used on the given profile. 54 // Check whether or not the Extended API should be used on the given profile.
50 bool IsInstantExtendedAPIEnabled(Profile* profile) { 55 bool IsInstantExtendedAPIEnabled(Profile* profile) {
51 return EmbeddedSearchPageVersion(profile) != 0; 56 return EmbeddedSearchPageVersion(profile) != 0;
52 } 57 }
53 58
54 // Determine what embedded search page version to request from the user's 59 // 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. 60 // 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 61 // 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 62 // 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. 63 // 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( 137 CommandLine::ForCurrentProcess()->AppendSwitch(
133 switches::kEnableQueryExtraction); 138 switches::kEnableQueryExtraction);
134 #else 139 #else
135 // On desktop, query extraction is controlled by the instant-extended-api 140 // On desktop, query extraction is controlled by the instant-extended-api
136 // flag. 141 // flag.
137 CommandLine::ForCurrentProcess()->AppendSwitch( 142 CommandLine::ForCurrentProcess()->AppendSwitch(
138 switches::kEnableInstantExtendedAPI); 143 switches::kEnableInstantExtendedAPI);
139 #endif 144 #endif
140 } 145 }
141 146
147 string16 GetSearchTermsFromNavigationEntry(
148 const content::NavigationEntry* entry) {
149 string16 out_value;
150 if (entry->GetExtraData(
151 std::string(kInstantExtendedSearchTermsKey),
152 &out_value))
153 return out_value;
154 return string16();
sreeram 2013/01/30 21:41:39 Nit: If you rewrite this as the following, it will
Mathieu 2013/01/30 21:55:12 Done.
155 }
156
142 bool IsForcedInstantURL(const GURL& url) { 157 bool IsForcedInstantURL(const GURL& url) {
143 CommandLine* command_line = CommandLine::ForCurrentProcess(); 158 CommandLine* command_line = CommandLine::ForCurrentProcess();
144 if (!command_line->HasSwitch(switches::kInstantURL)) 159 if (!command_line->HasSwitch(switches::kInstantURL))
145 return false; 160 return false;
146 161
147 GURL instant_url(command_line->GetSwitchValueASCII(switches::kInstantURL)); 162 GURL instant_url(command_line->GetSwitchValueASCII(switches::kInstantURL));
148 return url.scheme() == instant_url.scheme() && 163 return url.scheme() == instant_url.scheme() &&
149 url.host() == instant_url.host() && 164 url.host() == instant_url.host() &&
150 url.port() == instant_url.port() && 165 url.port() == instant_url.port() &&
151 url.path() == instant_url.path(); 166 url.path() == instant_url.path();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 218
204 // Given a FieldTrialFlags object, returns the boolean value of the provided 219 // Given a FieldTrialFlags object, returns the boolean value of the provided
205 // flag. 220 // flag.
206 bool GetBoolValueForFlagWithDefault( 221 bool GetBoolValueForFlagWithDefault(
207 const std::string& flag, bool default_value, FieldTrialFlags& flags) { 222 const std::string& flag, bool default_value, FieldTrialFlags& flags) {
208 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 223 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
209 } 224 }
210 225
211 } // namespace search 226 } // namespace search
212 } // namespace chrome 227 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698