Chromium Code Reviews| 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 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 | 406 |
| 407 private: | 407 private: |
| 408 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, TestManagedDefaultSearch); | 408 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, TestManagedDefaultSearch); |
| 409 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, | 409 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, |
| 410 UpdateKeywordSearchTermsForURL); | 410 UpdateKeywordSearchTermsForURL); |
| 411 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, | 411 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, |
| 412 DontUpdateKeywordSearchForNonReplaceable); | 412 DontUpdateKeywordSearchForNonReplaceable); |
| 413 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue); | 413 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue); |
| 414 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders); | 414 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders); |
| 415 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, AddExtensionKeyword); | 415 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, AddExtensionKeyword); |
| 416 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, LastVisitedTimeUpdate); | |
| 416 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword); | 417 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword); |
| 417 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 418 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
| 418 IsLocalTemplateURLBetter); | 419 IsLocalTemplateURLBetter); |
| 419 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 420 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
| 420 ResolveSyncKeywordConflict); | 421 ResolveSyncKeywordConflict); |
| 421 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, PreSyncDeletes); | 422 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, PreSyncDeletes); |
| 422 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, MergeInSyncTemplateURL); | 423 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, MergeInSyncTemplateURL); |
| 423 FRIEND_TEST_ALL_PREFIXES(ToolbarModelTest, GoogleBaseURL); | 424 FRIEND_TEST_ALL_PREFIXES(ToolbarModelTest, GoogleBaseURL); |
| 424 | 425 |
| 425 friend class InstantUnitTestBase; | 426 friend class InstantUnitTestBase; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 // Updates the information in |existing_turl| using the information from | 541 // Updates the information in |existing_turl| using the information from |
| 541 // |new_values|, but the ID for |existing_turl| is retained. Notifying | 542 // |new_values|, but the ID for |existing_turl| is retained. Notifying |
| 542 // observers is the responsibility of the caller. Returns whether | 543 // observers is the responsibility of the caller. Returns whether |
| 543 // |existing_turl| was found in |template_urls_| and thus could be updated. | 544 // |existing_turl| was found in |template_urls_| and thus could be updated. |
| 544 // | 545 // |
| 545 // NOTE: This should not be called with an extension keyword as there are no | 546 // NOTE: This should not be called with an extension keyword as there are no |
| 546 // updates needed in that case. | 547 // updates needed in that case. |
| 547 bool UpdateNoNotify(TemplateURL* existing_turl, | 548 bool UpdateNoNotify(TemplateURL* existing_turl, |
| 548 const TemplateURL& new_values); | 549 const TemplateURL& new_values); |
| 549 | 550 |
| 551 // Calls UpdateNoNotify() and NotifyObservers() if update succeeds. | |
| 552 // Returns the result of UpdateNoNotify(). | |
| 553 bool Update(TemplateURL* existing_turl, const TemplateURL& new_values); | |
| 554 | |
| 550 // If the TemplateURL comes from a prepopulated URL available in the current | 555 // If the TemplateURL comes from a prepopulated URL available in the current |
| 551 // country, update all its fields save for the keyword, short name and id so | 556 // country, update all its fields save for the keyword, short name and id so |
| 552 // that they match the internal prepopulated URL. TemplateURLs not coming from | 557 // that they match the internal prepopulated URL. TemplateURLs not coming from |
| 553 // a prepopulated URL are not modified. | 558 // a prepopulated URL are not modified. |
| 554 static void UpdateTemplateURLIfPrepopulated(TemplateURL* existing_turl, | 559 static void UpdateTemplateURLIfPrepopulated(TemplateURL* existing_turl, |
| 555 PrefService* prefs); | 560 PrefService* prefs); |
| 556 | 561 |
| 557 // If the TemplateURL's sync GUID matches the kSyncedDefaultSearchProviderGUID | 562 // If the TemplateURL's sync GUID matches the kSyncedDefaultSearchProviderGUID |
| 558 // preference it will be used to update the DSE in memory and as persisted in | 563 // preference it will be used to update the DSE in memory and as persisted in |
| 559 // preferences. | 564 // preferences. |
| 560 void MaybeUpdateDSEAfterSync(TemplateURL* synced_turl); | 565 void MaybeUpdateDSEAfterSync(TemplateURL* synced_turl); |
| 561 | 566 |
| 562 // Iterates through the TemplateURLs to see if one matches the visited url. | 567 // Iterates through the TemplateURLs to see if one matches the visited url. |
| 563 // For each TemplateURL whose url matches the visited url | 568 // For each TemplateURL whose url matches the visited url |
| 564 // SetKeywordSearchTermsForURL is invoked. | 569 // SetKeywordSearchTermsForURL is invoked. |
| 565 void UpdateKeywordSearchTermsForURL(const URLVisitedDetails& details); | 570 void UpdateKeywordSearchTermsForURL(const URLVisitedDetails& details); |
| 566 | 571 |
| 572 // Updates the last_visited time of TemplateURL to the current time. | |
|
Peter Kasting
2016/12/02 21:31:13
Nit: TemplateURL -> |url|
| |
| 573 void UpdateTemplateURLVisitTime(TemplateURL* url); | |
| 574 | |
| 567 // If necessary, generates a visit for the site http:// + t_url.keyword(). | 575 // If necessary, generates a visit for the site http:// + t_url.keyword(). |
| 568 void AddTabToSearchVisit(const TemplateURL& t_url); | 576 void AddTabToSearchVisit(const TemplateURL& t_url); |
| 569 | 577 |
| 570 // Requests the Google URL tracker to check the server if necessary. | 578 // Requests the Google URL tracker to check the server if necessary. |
| 571 void RequestGoogleURLTrackerServerCheckIfNecessary(); | 579 void RequestGoogleURLTrackerServerCheckIfNecessary(); |
| 572 | 580 |
| 573 // Invoked when the Google base URL has changed. Updates the mapping for all | 581 // Invoked when the Google base URL has changed. Updates the mapping for all |
| 574 // TemplateURLs that have a replacement term of {google:baseURL} or | 582 // TemplateURLs that have a replacement term of {google:baseURL} or |
| 575 // {google:baseSuggestURL}. | 583 // {google:baseSuggestURL}. |
| 576 void GoogleBaseURLChanged(); | 584 void GoogleBaseURLChanged(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 // Helper class to manage the default search engine. | 832 // Helper class to manage the default search engine. |
| 825 DefaultSearchManager default_search_manager_; | 833 DefaultSearchManager default_search_manager_; |
| 826 | 834 |
| 827 std::unique_ptr<GoogleURLTracker::Subscription> | 835 std::unique_ptr<GoogleURLTracker::Subscription> |
| 828 google_url_updated_subscription_; | 836 google_url_updated_subscription_; |
| 829 | 837 |
| 830 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 838 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 831 }; | 839 }; |
| 832 | 840 |
| 833 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 841 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |