OLD | NEW |
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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 return url.ReplaceComponents(rep); | 1270 return url.ReplaceComponents(rep); |
1271 } | 1271 } |
1272 | 1272 |
1273 // static | 1273 // static |
1274 bool TemplateURL::MatchesData(const TemplateURL* t_url, | 1274 bool TemplateURL::MatchesData(const TemplateURL* t_url, |
1275 const TemplateURLData* data, | 1275 const TemplateURLData* data, |
1276 const SearchTermsData& search_terms_data) { | 1276 const SearchTermsData& search_terms_data) { |
1277 if (!t_url || !data) | 1277 if (!t_url || !data) |
1278 return !t_url && !data; | 1278 return !t_url && !data; |
1279 | 1279 |
1280 return (t_url->short_name() == data->short_name) && | 1280 return (t_url->short_name() == data->short_name()) && |
1281 t_url->HasSameKeywordAs(*data, search_terms_data) && | 1281 t_url->HasSameKeywordAs(*data, search_terms_data) && |
1282 (t_url->url() == data->url()) && | 1282 (t_url->url() == data->url()) && |
1283 (t_url->suggestions_url() == data->suggestions_url) && | 1283 (t_url->suggestions_url() == data->suggestions_url) && |
1284 (t_url->instant_url() == data->instant_url) && | 1284 (t_url->instant_url() == data->instant_url) && |
1285 (t_url->image_url() == data->image_url) && | 1285 (t_url->image_url() == data->image_url) && |
1286 (t_url->new_tab_url() == data->new_tab_url) && | 1286 (t_url->new_tab_url() == data->new_tab_url) && |
1287 (t_url->search_url_post_params() == data->search_url_post_params) && | 1287 (t_url->search_url_post_params() == data->search_url_post_params) && |
1288 (t_url->suggestions_url_post_params() == | 1288 (t_url->suggestions_url_post_params() == |
1289 data->suggestions_url_post_params) && | 1289 data->suggestions_url_post_params) && |
1290 (t_url->instant_url_post_params() == data->instant_url_post_params) && | 1290 (t_url->instant_url_post_params() == data->instant_url_post_params) && |
1291 (t_url->image_url_post_params() == data->image_url_post_params) && | 1291 (t_url->image_url_post_params() == data->image_url_post_params) && |
1292 (t_url->favicon_url() == data->favicon_url) && | 1292 (t_url->favicon_url() == data->favicon_url) && |
1293 (t_url->safe_for_autoreplace() == data->safe_for_autoreplace) && | 1293 (t_url->safe_for_autoreplace() == data->safe_for_autoreplace) && |
1294 (t_url->show_in_default_list() == data->show_in_default_list) && | 1294 (t_url->show_in_default_list() == data->show_in_default_list) && |
1295 (t_url->input_encodings() == data->input_encodings) && | 1295 (t_url->input_encodings() == data->input_encodings) && |
1296 (t_url->alternate_urls() == data->alternate_urls) && | 1296 (t_url->alternate_urls() == data->alternate_urls) && |
1297 (t_url->search_terms_replacement_key() == | 1297 (t_url->search_terms_replacement_key() == |
1298 data->search_terms_replacement_key); | 1298 data->search_terms_replacement_key); |
1299 } | 1299 } |
1300 | 1300 |
1301 base::string16 TemplateURL::AdjustedShortNameForLocaleDirection() const { | 1301 base::string16 TemplateURL::AdjustedShortNameForLocaleDirection() const { |
1302 base::string16 bidi_safe_short_name = data_.short_name; | 1302 base::string16 bidi_safe_short_name = data_.short_name(); |
1303 base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name); | 1303 base::i18n::AdjustStringForLocaleDirection(&bidi_safe_short_name); |
1304 return bidi_safe_short_name; | 1304 return bidi_safe_short_name; |
1305 } | 1305 } |
1306 | 1306 |
1307 bool TemplateURL::ShowInDefaultList( | 1307 bool TemplateURL::ShowInDefaultList( |
1308 const SearchTermsData& search_terms_data) const { | 1308 const SearchTermsData& search_terms_data) const { |
1309 return data_.show_in_default_list && | 1309 return data_.show_in_default_list && |
1310 url_ref_.SupportsReplacement(search_terms_data); | 1310 url_ref_.SupportsReplacement(search_terms_data); |
1311 } | 1311 } |
1312 | 1312 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 // patterns. This means that given patterns | 1543 // patterns. This means that given patterns |
1544 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], | 1544 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], |
1545 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would | 1545 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would |
1546 // return false. This is important for at least Google, where such URLs | 1546 // return false. This is important for at least Google, where such URLs |
1547 // are invalid. | 1547 // are invalid. |
1548 return !search_terms->empty(); | 1548 return !search_terms->empty(); |
1549 } | 1549 } |
1550 } | 1550 } |
1551 return false; | 1551 return false; |
1552 } | 1552 } |
OLD | NEW |