| 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_service.h" | 5 #include "components/search_engines/template_url_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 SyncDataMap TemplateURLService::CreateGUIDToSyncDataMap( | 1401 SyncDataMap TemplateURLService::CreateGUIDToSyncDataMap( |
| 1402 const syncer::SyncDataList& sync_data) { | 1402 const syncer::SyncDataList& sync_data) { |
| 1403 SyncDataMap data_map; | 1403 SyncDataMap data_map; |
| 1404 for (syncer::SyncDataList::const_iterator i(sync_data.begin()); | 1404 for (syncer::SyncDataList::const_iterator i(sync_data.begin()); |
| 1405 i != sync_data.end(); | 1405 i != sync_data.end(); |
| 1406 ++i) | 1406 ++i) |
| 1407 data_map[i->GetSpecifics().search_engine().sync_guid()] = *i; | 1407 data_map[i->GetSpecifics().search_engine().sync_guid()] = *i; |
| 1408 return data_map; | 1408 return data_map; |
| 1409 } | 1409 } |
| 1410 | 1410 |
| 1411 void TemplateURLService::SetKeywordSearchTermsForURL( | |
| 1412 const TemplateURL* t_url, | |
| 1413 const GURL& url, | |
| 1414 const base::string16& term) { | |
| 1415 if (client_) | |
| 1416 client_->SetKeywordSearchTermsForURL(url, t_url->id(), term); | |
| 1417 } | |
| 1418 | |
| 1419 void TemplateURLService::Init(const Initializer* initializers, | 1411 void TemplateURLService::Init(const Initializer* initializers, |
| 1420 int num_initializers) { | 1412 int num_initializers) { |
| 1421 if (client_) | 1413 if (client_) |
| 1422 client_->SetOwner(this); | 1414 client_->SetOwner(this); |
| 1423 | 1415 |
| 1424 // GoogleURLTracker is not created in tests. | 1416 // GoogleURLTracker is not created in tests. |
| 1425 if (google_url_tracker_) { | 1417 if (google_url_tracker_) { |
| 1426 google_url_updated_subscription_ = | 1418 google_url_updated_subscription_ = |
| 1427 google_url_tracker_->RegisterCallback(base::Bind( | 1419 google_url_tracker_->RegisterCallback(base::Bind( |
| 1428 &TemplateURLService::GoogleBaseURLChanged, base::Unretained(this))); | 1420 &TemplateURLService::GoogleBaseURLChanged, base::Unretained(this))); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 base::string16 search_terms; | 1732 base::string16 search_terms; |
| 1741 if ((*i)->ExtractSearchTermsFromURL(details.url, search_terms_data(), | 1733 if ((*i)->ExtractSearchTermsFromURL(details.url, search_terms_data(), |
| 1742 &search_terms) && | 1734 &search_terms) && |
| 1743 !search_terms.empty()) { | 1735 !search_terms.empty()) { |
| 1744 if (details.is_keyword_transition) { | 1736 if (details.is_keyword_transition) { |
| 1745 // The visit is the result of the user entering a keyword, generate a | 1737 // The visit is the result of the user entering a keyword, generate a |
| 1746 // KEYWORD_GENERATED visit for the KEYWORD so that the keyword typed | 1738 // KEYWORD_GENERATED visit for the KEYWORD so that the keyword typed |
| 1747 // count is boosted. | 1739 // count is boosted. |
| 1748 AddTabToSearchVisit(**i); | 1740 AddTabToSearchVisit(**i); |
| 1749 } | 1741 } |
| 1750 SetKeywordSearchTermsForURL(*i, details.url, search_terms); | 1742 if (client_) { |
| 1743 client_->SetKeywordSearchTermsForURL( |
| 1744 details.url, (*i)->id(), search_terms); |
| 1745 } |
| 1751 } | 1746 } |
| 1752 } | 1747 } |
| 1753 } | 1748 } |
| 1754 | 1749 |
| 1755 void TemplateURLService::AddTabToSearchVisit(const TemplateURL& t_url) { | 1750 void TemplateURLService::AddTabToSearchVisit(const TemplateURL& t_url) { |
| 1756 // Only add visits for entries the user hasn't modified. If the user modified | 1751 // Only add visits for entries the user hasn't modified. If the user modified |
| 1757 // the entry the keyword may no longer correspond to the host name. It may be | 1752 // the entry the keyword may no longer correspond to the host name. It may be |
| 1758 // possible to do something more sophisticated here, but it's so rare as to | 1753 // possible to do something more sophisticated here, but it's so rare as to |
| 1759 // not be worth it. | 1754 // not be worth it. |
| 1760 if (!t_url.safe_for_autoreplace()) | 1755 if (!t_url.safe_for_autoreplace()) |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 | 2364 |
| 2370 if (most_recently_intalled_default) { | 2365 if (most_recently_intalled_default) { |
| 2371 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2366 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
| 2372 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2367 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
| 2373 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2368 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
| 2374 most_recently_intalled_default->data()); | 2369 most_recently_intalled_default->data()); |
| 2375 } else { | 2370 } else { |
| 2376 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2371 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
| 2377 } | 2372 } |
| 2378 } | 2373 } |
| OLD | NEW |