| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_service.h" | 5 #include "chrome/browser/search_engines/template_url_service.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 | 1255 |
| 1256 if (search_ref && search_ref->GetHost() == row.url().host() && | 1256 if (search_ref && search_ref->GetHost() == row.url().host() && |
| 1257 search_ref->GetPath() == path) { | 1257 search_ref->GetPath() == path) { |
| 1258 if (!built_terms && !BuildQueryTerms(row.url(), &query_terms)) { | 1258 if (!built_terms && !BuildQueryTerms(row.url(), &query_terms)) { |
| 1259 // No query terms. No need to continue with the rest of the | 1259 // No query terms. No need to continue with the rest of the |
| 1260 // TemplateURLs. | 1260 // TemplateURLs. |
| 1261 return; | 1261 return; |
| 1262 } | 1262 } |
| 1263 built_terms = true; | 1263 built_terms = true; |
| 1264 | 1264 |
| 1265 if (PageTransition::StripQualifier(details.transition) == | 1265 if (content::PageTransitionStripQualifier(details.transition) == |
| 1266 PageTransition::KEYWORD) { | 1266 content::PAGE_TRANSITION_KEYWORD) { |
| 1267 // The visit is the result of the user entering a keyword, generate a | 1267 // The visit is the result of the user entering a keyword, generate a |
| 1268 // KEYWORD_GENERATED visit for the KEYWORD so that the keyword typed | 1268 // KEYWORD_GENERATED visit for the KEYWORD so that the keyword typed |
| 1269 // count is boosted. | 1269 // count is boosted. |
| 1270 AddTabToSearchVisit(**i); | 1270 AddTabToSearchVisit(**i); |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 QueryTerms::iterator terms_iterator = | 1273 QueryTerms::iterator terms_iterator = |
| 1274 query_terms.find(search_ref->GetSearchTermKey()); | 1274 query_terms.find(search_ref->GetSearchTermKey()); |
| 1275 if (terms_iterator != query_terms.end() && | 1275 if (terms_iterator != query_terms.end() && |
| 1276 !terms_iterator->second.empty()) { | 1276 !terms_iterator->second.empty()) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1299 return; | 1299 return; |
| 1300 | 1300 |
| 1301 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(t_url.keyword()), | 1301 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(t_url.keyword()), |
| 1302 std::string())); | 1302 std::string())); |
| 1303 if (!url.is_valid()) | 1303 if (!url.is_valid()) |
| 1304 return; | 1304 return; |
| 1305 | 1305 |
| 1306 // Synthesize a visit for the keyword. This ensures the url for the keyword is | 1306 // Synthesize a visit for the keyword. This ensures the url for the keyword is |
| 1307 // autocompleted even if the user doesn't type the url in directly. | 1307 // autocompleted even if the user doesn't type the url in directly. |
| 1308 history->AddPage(url, NULL, 0, GURL(), | 1308 history->AddPage(url, NULL, 0, GURL(), |
| 1309 PageTransition::KEYWORD_GENERATED, | 1309 content::PAGE_TRANSITION_KEYWORD_GENERATED, |
| 1310 history::RedirectList(), history::SOURCE_BROWSED, false); | 1310 history::RedirectList(), history::SOURCE_BROWSED, false); |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 // static | 1313 // static |
| 1314 bool TemplateURLService::BuildQueryTerms(const GURL& url, | 1314 bool TemplateURLService::BuildQueryTerms(const GURL& url, |
| 1315 QueryTerms* query_terms) { | 1315 QueryTerms* query_terms) { |
| 1316 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query; | 1316 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query; |
| 1317 url_parse::Component key, value; | 1317 url_parse::Component key, value; |
| 1318 size_t valid_term_count = 0; | 1318 size_t valid_term_count = 0; |
| 1319 while (url_parse::ExtractQueryKeyValue(url.spec().c_str(), &query, &key, | 1319 while (url_parse::ExtractQueryKeyValue(url.spec().c_str(), &query, &key, |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 } else { | 1708 } else { |
| 1709 // Change the local TURL's GUID to the server's GUID and push an update to | 1709 // Change the local TURL's GUID to the server's GUID and push an update to |
| 1710 // Sync. This ensures that the rest of local_url's fields are sync'd up to | 1710 // Sync. This ensures that the rest of local_url's fields are sync'd up to |
| 1711 // the server, and the next time local_url is synced, it is recognized by | 1711 // the server, and the next time local_url is synced, it is recognized by |
| 1712 // having the same GUID. | 1712 // having the same GUID. |
| 1713 ResetTemplateURLGUID(local_turl, sync_turl->sync_guid()); | 1713 ResetTemplateURLGUID(local_turl, sync_turl->sync_guid()); |
| 1714 SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl); | 1714 SyncData sync_data = CreateSyncDataFromTemplateURL(*local_turl); |
| 1715 change_list->push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data)); | 1715 change_list->push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data)); |
| 1716 } | 1716 } |
| 1717 } | 1717 } |
| OLD | NEW |