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

Side by Side Diff: components/search_engines/template_url.cc

Issue 2623833005: Revert of Make extensions DSE persistent in browser prefs (Closed)
Patch Set: Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/search_engines/template_url.h" 5 #include "components/search_engines/template_url.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 parameter_position->begin = begin; 158 parameter_position->begin = begin;
159 parameter_position->len = arraysize(kSearchTermsParameterFullEscaped) - 1; 159 parameter_position->len = arraysize(kSearchTermsParameterFullEscaped) - 1;
160 return true; 160 return true;
161 } 161 }
162 162
163 bool IsTemplateParameterString(const std::string& param) { 163 bool IsTemplateParameterString(const std::string& param) {
164 return (param.length() > 2) && (*(param.begin()) == kStartParameter) && 164 return (param.length() > 2) && (*(param.begin()) == kStartParameter) &&
165 (*(param.rbegin()) == kEndParameter); 165 (*(param.rbegin()) == kEndParameter);
166 } 166 }
167 167
168 // Special case for search_terms_replacement_key comparison, because of
169 // its special initialization in TemplateUrl constructor.
170 bool SearchTermsReplacementKeysMatch(
171 const std::string& search_terms_replacement_key1,
172 const std::string& search_terms_replacement_key2) {
173 if (search_terms_replacement_key1 == search_terms_replacement_key2)
174 return true;
175 if (search_terms_replacement_key1 == google_util::kInstantExtendedAPIParam &&
176 search_terms_replacement_key2 == kGoogleInstantExtendedEnabledKeyFull)
177 return true;
178 if (search_terms_replacement_key2 == google_util::kInstantExtendedAPIParam &&
179 search_terms_replacement_key1 == kGoogleInstantExtendedEnabledKeyFull)
180 return true;
181 return false;
182 }
183
168 } // namespace 184 } // namespace
169 185
170 186
171 // TemplateURLRef::SearchTermsArgs -------------------------------------------- 187 // TemplateURLRef::SearchTermsArgs --------------------------------------------
172 188
173 TemplateURLRef::SearchTermsArgs::SearchTermsArgs( 189 TemplateURLRef::SearchTermsArgs::SearchTermsArgs(
174 const base::string16& search_terms) 190 const base::string16& search_terms)
175 : search_terms(search_terms), 191 : search_terms(search_terms),
176 input_type(metrics::OmniboxInputType::INVALID), 192 input_type(metrics::OmniboxInputType::INVALID),
177 accepted_suggestion(NO_SUGGESTIONS_AVAILABLE), 193 accepted_suggestion(NO_SUGGESTIONS_AVAILABLE),
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 (t_url->instant_url_post_params() == data->instant_url_post_params) && 1274 (t_url->instant_url_post_params() == data->instant_url_post_params) &&
1259 (t_url->image_url_post_params() == data->image_url_post_params) && 1275 (t_url->image_url_post_params() == data->image_url_post_params) &&
1260 (t_url->favicon_url() == data->favicon_url) && 1276 (t_url->favicon_url() == data->favicon_url) &&
1261 (t_url->safe_for_autoreplace() == data->safe_for_autoreplace) && 1277 (t_url->safe_for_autoreplace() == data->safe_for_autoreplace) &&
1262 (t_url->input_encodings() == data->input_encodings) && 1278 (t_url->input_encodings() == data->input_encodings) &&
1263 (t_url->alternate_urls() == data->alternate_urls) && 1279 (t_url->alternate_urls() == data->alternate_urls) &&
1264 SearchTermsReplacementKeysMatch(t_url->search_terms_replacement_key(), 1280 SearchTermsReplacementKeysMatch(t_url->search_terms_replacement_key(),
1265 data->search_terms_replacement_key); 1281 data->search_terms_replacement_key);
1266 } 1282 }
1267 1283
1268 // static
1269 bool TemplateURL::SearchTermsReplacementKeysMatch(
1270 const std::string& search_terms_replacement_key1,
1271 const std::string& search_terms_replacement_key2) {
1272 if (search_terms_replacement_key1 == google_util::kInstantExtendedAPIParam &&
1273 search_terms_replacement_key2 == kGoogleInstantExtendedEnabledKeyFull)
1274 return true;
1275 if (search_terms_replacement_key2 == google_util::kInstantExtendedAPIParam &&
1276 search_terms_replacement_key1 == kGoogleInstantExtendedEnabledKeyFull)
1277 return true;
1278 return search_terms_replacement_key1 == search_terms_replacement_key2;
1279 }
1280
1281 base::string16 TemplateURL::AdjustedShortNameForLocaleDirection() const { 1284 base::string16 TemplateURL::AdjustedShortNameForLocaleDirection() const {
1282 base::string16 bidi_safe_short_name = data_.short_name(); 1285 base::string16 bidi_safe_short_name = data_.short_name();
1283 base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name); 1286 base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name);
1284 return bidi_safe_short_name; 1287 return bidi_safe_short_name;
1285 } 1288 }
1286 1289
1287 bool TemplateURL::SupportsReplacement( 1290 bool TemplateURL::SupportsReplacement(
1288 const SearchTermsData& search_terms_data) const { 1291 const SearchTermsData& search_terms_data) const {
1289 return url_ref_->SupportsReplacement(search_terms_data); 1292 return url_ref_->SupportsReplacement(search_terms_data);
1290 } 1293 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 // patterns. This means that given patterns 1546 // patterns. This means that given patterns
1544 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], 1547 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ],
1545 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would 1548 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would
1546 // return false. This is important for at least Google, where such URLs 1549 // return false. This is important for at least Google, where such URLs
1547 // are invalid. 1550 // are invalid.
1548 return !search_terms->empty(); 1551 return !search_terms->empty();
1549 } 1552 }
1550 } 1553 }
1551 return false; 1554 return false;
1552 } 1555 }
OLDNEW
« no previous file with comments | « components/search_engines/template_url.h ('k') | components/search_engines/template_url_prepopulate_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698