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

Side by Side Diff: chrome/browser/search_engines/template_url.cc

Issue 25324003: search: Log when bookmark bar is pinned. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
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/search_engines/template_url.h" 5 #include "chrome/browser/search_engines/template_url.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/guid.h" 10 #include "base/guid.h"
11 #include "base/i18n/case_conversion.h" 11 #include "base/i18n/case_conversion.h"
12 #include "base/i18n/icu_string_conversions.h" 12 #include "base/i18n/icu_string_conversions.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "base/rand_util.h" 16 #include "base/rand_util.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_split.h" 18 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "chrome/browser/google/google_util.h" 22 #include "chrome/browser/google/google_util.h"
23 #include "chrome/browser/search/search.h"
23 #include "chrome/browser/search_engines/search_terms_data.h" 24 #include "chrome/browser/search_engines/search_terms_data.h"
24 #include "chrome/browser/search_engines/template_url_service.h" 25 #include "chrome/browser/search_engines/template_url_service.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/chrome_version_info.h" 27 #include "chrome/common/chrome_version_info.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
28 #include "extensions/common/constants.h" 29 #include "extensions/common/constants.h"
29 #include "google_apis/google_api_keys.h" 30 #include "google_apis/google_api_keys.h"
30 #include "net/base/escape.h" 31 #include "net/base/escape.h"
31 #include "net/base/mime_util.h" 32 #include "net/base/mime_util.h"
32 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
(...skipping 20 matching lines...) Expand all
53 54
54 const char kGoogleAssistedQueryStatsParameter[] = "google:assistedQueryStats"; 55 const char kGoogleAssistedQueryStatsParameter[] = "google:assistedQueryStats";
55 56
56 // Host/Domain Google searches are relative to. 57 // Host/Domain Google searches are relative to.
57 const char kGoogleBaseURLParameter[] = "google:baseURL"; 58 const char kGoogleBaseURLParameter[] = "google:baseURL";
58 const char kGoogleBaseURLParameterFull[] = "{google:baseURL}"; 59 const char kGoogleBaseURLParameterFull[] = "{google:baseURL}";
59 60
60 // Like google:baseURL, but for the Search Suggest capability. 61 // Like google:baseURL, but for the Search Suggest capability.
61 const char kGoogleBaseSuggestURLParameter[] = "google:baseSuggestURL"; 62 const char kGoogleBaseSuggestURLParameter[] = "google:baseSuggestURL";
62 const char kGoogleBaseSuggestURLParameterFull[] = "{google:baseSuggestURL}"; 63 const char kGoogleBaseSuggestURLParameterFull[] = "{google:baseSuggestURL}";
64 const char kGoogleBookmarkBarPinnedParameter[] = "google:bookmarkBarPinned";
63 const char kGoogleCursorPositionParameter[] = "google:cursorPosition"; 65 const char kGoogleCursorPositionParameter[] = "google:cursorPosition";
64 const char kGoogleInstantEnabledParameter[] = "google:instantEnabledParameter"; 66 const char kGoogleInstantEnabledParameter[] = "google:instantEnabledParameter";
65 const char kGoogleInstantExtendedEnabledParameter[] = 67 const char kGoogleInstantExtendedEnabledParameter[] =
66 "google:instantExtendedEnabledParameter"; 68 "google:instantExtendedEnabledParameter";
67 const char kGoogleInstantExtendedEnabledKey[] = 69 const char kGoogleInstantExtendedEnabledKey[] =
68 "google:instantExtendedEnabledKey"; 70 "google:instantExtendedEnabledKey";
69 const char kGoogleInstantExtendedEnabledKeyFull[] = 71 const char kGoogleInstantExtendedEnabledKeyFull[] =
70 "{google:instantExtendedEnabledKey}"; 72 "{google:instantExtendedEnabledKey}";
71 const char kGoogleNTPIsThemedParameter[] = "google:ntpIsThemedParameter"; 73 const char kGoogleNTPIsThemedParameter[] = "google:ntpIsThemedParameter";
72 const char kGoogleOmniboxStartMarginParameter[] = 74 const char kGoogleOmniboxStartMarginParameter[] =
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 188
187 189
188 // TemplateURLRef::SearchTermsArgs -------------------------------------------- 190 // TemplateURLRef::SearchTermsArgs --------------------------------------------
189 191
190 TemplateURLRef::SearchTermsArgs::SearchTermsArgs(const string16& search_terms) 192 TemplateURLRef::SearchTermsArgs::SearchTermsArgs(const string16& search_terms)
191 : search_terms(search_terms), 193 : search_terms(search_terms),
192 accepted_suggestion(NO_SUGGESTIONS_AVAILABLE), 194 accepted_suggestion(NO_SUGGESTIONS_AVAILABLE),
193 cursor_position(string16::npos), 195 cursor_position(string16::npos),
194 omnibox_start_margin(-1), 196 omnibox_start_margin(-1),
195 page_classification(AutocompleteInput::INVALID_SPEC), 197 page_classification(AutocompleteInput::INVALID_SPEC),
196 append_extra_query_params(false) { 198 append_extra_query_params(false),
199 bookmark_bar_pinned(false) {
197 } 200 }
198 201
199 TemplateURLRef::SearchTermsArgs::~SearchTermsArgs() { 202 TemplateURLRef::SearchTermsArgs::~SearchTermsArgs() {
200 } 203 }
201 204
202 205
203 // TemplateURLRef ------------------------------------------------------------- 206 // TemplateURLRef -------------------------------------------------------------
204 207
205 TemplateURLRef::TemplateURLRef(TemplateURL* owner, Type type) 208 TemplateURLRef::TemplateURLRef(TemplateURL* owner, Type type)
206 : owner_(owner), 209 : owner_(owner),
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 replacements->push_back(Replacement(SEARCH_TERMS, start)); 532 replacements->push_back(Replacement(SEARCH_TERMS, start));
530 } else if (parameter == kCountParameter) { 533 } else if (parameter == kCountParameter) {
531 if (!optional) 534 if (!optional)
532 url->insert(start, kDefaultCount); 535 url->insert(start, kDefaultCount);
533 } else if (parameter == kGoogleAssistedQueryStatsParameter) { 536 } else if (parameter == kGoogleAssistedQueryStatsParameter) {
534 replacements->push_back(Replacement(GOOGLE_ASSISTED_QUERY_STATS, start)); 537 replacements->push_back(Replacement(GOOGLE_ASSISTED_QUERY_STATS, start));
535 } else if (parameter == kGoogleBaseURLParameter) { 538 } else if (parameter == kGoogleBaseURLParameter) {
536 replacements->push_back(Replacement(GOOGLE_BASE_URL, start)); 539 replacements->push_back(Replacement(GOOGLE_BASE_URL, start));
537 } else if (parameter == kGoogleBaseSuggestURLParameter) { 540 } else if (parameter == kGoogleBaseSuggestURLParameter) {
538 replacements->push_back(Replacement(GOOGLE_BASE_SUGGEST_URL, start)); 541 replacements->push_back(Replacement(GOOGLE_BASE_SUGGEST_URL, start));
542 } else if (parameter == kGoogleBookmarkBarPinnedParameter) {
543 replacements->push_back(Replacement(GOOGLE_BOOKMARK_BAR_PINNED, start));
539 } else if (parameter == kGoogleCursorPositionParameter) { 544 } else if (parameter == kGoogleCursorPositionParameter) {
540 replacements->push_back(Replacement(GOOGLE_CURSOR_POSITION, start)); 545 replacements->push_back(Replacement(GOOGLE_CURSOR_POSITION, start));
541 } else if (parameter == kGoogleImageOriginalHeight) { 546 } else if (parameter == kGoogleImageOriginalHeight) {
542 replacements->push_back( 547 replacements->push_back(
543 Replacement(TemplateURLRef::GOOGLE_IMAGE_ORIGINAL_HEIGHT, start)); 548 Replacement(TemplateURLRef::GOOGLE_IMAGE_ORIGINAL_HEIGHT, start));
544 } else if (parameter == kGoogleImageOriginalWidth) { 549 } else if (parameter == kGoogleImageOriginalWidth) {
545 replacements->push_back( 550 replacements->push_back(
546 Replacement(TemplateURLRef::GOOGLE_IMAGE_ORIGINAL_WIDTH, start)); 551 Replacement(TemplateURLRef::GOOGLE_IMAGE_ORIGINAL_WIDTH, start));
547 } else if (parameter == kGoogleImageSearchSource) { 552 } else if (parameter == kGoogleImageSearchSource) {
548 url->insert(start, GetGoogleImageSearchSource()); 553 url->insert(start, GetGoogleImageSearchSource());
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 std::string(), search_terms_data.GoogleBaseURLValue(), *i, &url); 826 std::string(), search_terms_data.GoogleBaseURLValue(), *i, &url);
822 break; 827 break;
823 828
824 case GOOGLE_BASE_SUGGEST_URL: 829 case GOOGLE_BASE_SUGGEST_URL:
825 DCHECK(!i->is_post_param); 830 DCHECK(!i->is_post_param);
826 HandleReplacement( 831 HandleReplacement(
827 std::string(), search_terms_data.GoogleBaseSuggestURLValue(), *i, 832 std::string(), search_terms_data.GoogleBaseSuggestURLValue(), *i,
828 &url); 833 &url);
829 break; 834 break;
830 835
836 case GOOGLE_BOOKMARK_BAR_PINNED:
837 if (chrome::IsInstantExtendedAPIEnabled() &&
838 !chrome::ShouldSuppressInstantExtendedOnSRP()) {
839 // Log whether the bookmark bar is pinned when the user is seeing
840 // InstantExtended on the SRP.
841 DCHECK(!i->is_post_param);
842 HandleReplacement(
843 "bmbp",
844 base::StringPrintf("%d", search_terms_args.bookmark_bar_pinned),
Peter Kasting 2013/10/01 01:03:31 Nit: What about just search_terms_args.bookmark
Jered 2013/10/01 18:46:15 Thanks, that's much better. Done.
845 *i,
846 &url);
847 }
848 break;
849
831 case GOOGLE_CURSOR_POSITION: 850 case GOOGLE_CURSOR_POSITION:
832 DCHECK(!i->is_post_param); 851 DCHECK(!i->is_post_param);
833 if (search_terms_args.cursor_position != string16::npos) 852 if (search_terms_args.cursor_position != string16::npos)
834 HandleReplacement( 853 HandleReplacement(
835 "cp", 854 "cp",
836 base::StringPrintf("%" PRIuS, search_terms_args.cursor_position), 855 base::StringPrintf("%" PRIuS, search_terms_args.cursor_position),
837 *i, 856 *i,
838 &url); 857 &url);
839 break; 858 break;
840 859
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 // patterns. This means that given patterns 1297 // patterns. This means that given patterns
1279 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], 1298 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ],
1280 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would 1299 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would
1281 // return false. This is important for at least Google, where such URLs 1300 // return false. This is important for at least Google, where such URLs
1282 // are invalid. 1301 // are invalid.
1283 return !search_terms->empty(); 1302 return !search_terms->empty();
1284 } 1303 }
1285 } 1304 }
1286 return false; 1305 return false;
1287 } 1306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698