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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 // |url| is the URL of the search query. This is used to prevent auto-adding | 130 // |url| is the URL of the search query. This is used to prevent auto-adding |
| 131 // a keyword for hosts already associated with a manually-edited keyword. | 131 // a keyword for hosts already associated with a manually-edited keyword. |
| 132 bool CanAddAutogeneratedKeyword(const base::string16& keyword, | 132 bool CanAddAutogeneratedKeyword(const base::string16& keyword, |
| 133 const GURL& url, | 133 const GURL& url, |
| 134 TemplateURL** template_url_to_replace); | 134 TemplateURL** template_url_to_replace); |
| 135 | 135 |
| 136 // Returns whether the engine is a "pre-existing" engine, either from the | 136 // Returns whether the engine is a "pre-existing" engine, either from the |
| 137 // prepopulate list or created by policy. | 137 // prepopulate list or created by policy. |
| 138 bool IsPrepopulatedOrCreatedByPolicy(const TemplateURL* template_url); | 138 bool IsPrepopulatedOrCreatedByPolicy(const TemplateURL* template_url); |
| 139 | 139 |
| 140 // Returns whether |template_url| is the current default or return true for | 140 // Returns whether |template_url| should be shown in the list of engines |
| 141 // IsPrepopulatedOrCreatedByPolicy(). This is meant to highlight the current, | 141 // most likely to be selected as a default engine. This is meant to highlight |
| 142 // default, as well as the other most likely choices of default engine, | 142 // the current default, as well as the other most likely choices of default |
| 143 // separately from a full list of all TemplateURLs (which might be very long). | 143 // engine, separately from a full list of all TemplateURLs (which might be |
| 144 // very long). | |
| 144 bool ShowInDefaultList(const TemplateURL* template_url); | 145 bool ShowInDefaultList(const TemplateURL* template_url); |
| 145 | 146 |
| 146 // Adds to |matches| all TemplateURLs whose keywords begin with |prefix|, | 147 // Adds to |matches| all TemplateURLs whose keywords begin with |prefix|, |
| 147 // sorted shortest-keyword-first. If |supports_replacement_only| is true, only | 148 // sorted shortest-keyword-first. If |supports_replacement_only| is true, only |
| 148 // TemplateURLs that support replacement are returned. | 149 // TemplateURLs that support replacement are returned. |
| 149 void AddMatchingKeywords(const base::string16& prefix, | 150 void AddMatchingKeywords(const base::string16& prefix, |
| 150 bool supports_replacement_only, | 151 bool supports_replacement_only, |
| 151 TURLsAndMeaningfulLengths* matches); | 152 TURLsAndMeaningfulLengths* matches); |
| 152 | 153 |
| 153 // Adds to |matches| all TemplateURLs for search engines with the domain | 154 // Adds to |matches| all TemplateURLs for search engines with the domain |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 // Returns a SearchTermsData which can be used to call TemplateURL methods. | 371 // Returns a SearchTermsData which can be used to call TemplateURL methods. |
| 371 const SearchTermsData& search_terms_data() const { | 372 const SearchTermsData& search_terms_data() const { |
| 372 return *search_terms_data_; | 373 return *search_terms_data_; |
| 373 } | 374 } |
| 374 | 375 |
| 375 // Returns a SyncData with a sync representation of the search engine data | 376 // Returns a SyncData with a sync representation of the search engine data |
| 376 // from |turl|. | 377 // from |turl|. |
| 377 static syncer::SyncData CreateSyncDataFromTemplateURL( | 378 static syncer::SyncData CreateSyncDataFromTemplateURL( |
| 378 const TemplateURL& turl); | 379 const TemplateURL& turl); |
| 379 | 380 |
| 381 // Updates the last_visited time of |url| to the current time. | |
| 382 void UpdateTemplateURLVisitTime(TemplateURL* url); | |
|
Peter Kasting
2016/12/16 08:37:18
Nit: If you're going to move this, you need to mov
| |
| 383 | |
| 380 // Creates a new heap-allocated TemplateURL* which is populated by overlaying | 384 // Creates a new heap-allocated TemplateURL* which is populated by overlaying |
| 381 // |sync_data| atop |existing_turl|. |existing_turl| may be NULL; if not it | 385 // |sync_data| atop |existing_turl|. |existing_turl| may be NULL; if not it |
| 382 // remains unmodified. The caller owns the returned TemplateURL*. | 386 // remains unmodified. The caller owns the returned TemplateURL*. |
| 383 // | 387 // |
| 384 // If the created TemplateURL is migrated in some way from out-of-date sync | 388 // If the created TemplateURL is migrated in some way from out-of-date sync |
| 385 // data, an appropriate SyncChange is added to |change_list|. If the sync | 389 // data, an appropriate SyncChange is added to |change_list|. If the sync |
| 386 // data is bad for some reason, an ACTION_DELETE change is added and the | 390 // data is bad for some reason, an ACTION_DELETE change is added and the |
| 387 // function returns NULL. | 391 // function returns NULL. |
| 388 static std::unique_ptr<TemplateURL> | 392 static std::unique_ptr<TemplateURL> |
| 389 CreateTemplateURLFromTemplateURLAndSyncData( | 393 CreateTemplateURLFromTemplateURLAndSyncData( |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 // If the TemplateURL's sync GUID matches the kSyncedDefaultSearchProviderGUID | 566 // If the TemplateURL's sync GUID matches the kSyncedDefaultSearchProviderGUID |
| 563 // preference it will be used to update the DSE in memory and as persisted in | 567 // preference it will be used to update the DSE in memory and as persisted in |
| 564 // preferences. | 568 // preferences. |
| 565 void MaybeUpdateDSEAfterSync(TemplateURL* synced_turl); | 569 void MaybeUpdateDSEAfterSync(TemplateURL* synced_turl); |
| 566 | 570 |
| 567 // Iterates through the TemplateURLs to see if one matches the visited url. | 571 // Iterates through the TemplateURLs to see if one matches the visited url. |
| 568 // For each TemplateURL whose url matches the visited url | 572 // For each TemplateURL whose url matches the visited url |
| 569 // SetKeywordSearchTermsForURL is invoked. | 573 // SetKeywordSearchTermsForURL is invoked. |
| 570 void UpdateKeywordSearchTermsForURL(const URLVisitedDetails& details); | 574 void UpdateKeywordSearchTermsForURL(const URLVisitedDetails& details); |
| 571 | 575 |
| 572 // Updates the last_visited time of |url| to the current time. | |
| 573 void UpdateTemplateURLVisitTime(TemplateURL* url); | |
| 574 | |
| 575 // If necessary, generates a visit for the site http:// + t_url.keyword(). | 576 // If necessary, generates a visit for the site http:// + t_url.keyword(). |
| 576 void AddTabToSearchVisit(const TemplateURL& t_url); | 577 void AddTabToSearchVisit(const TemplateURL& t_url); |
| 577 | 578 |
| 578 // Requests the Google URL tracker to check the server if necessary. | 579 // Requests the Google URL tracker to check the server if necessary. |
| 579 void RequestGoogleURLTrackerServerCheckIfNecessary(); | 580 void RequestGoogleURLTrackerServerCheckIfNecessary(); |
| 580 | 581 |
| 581 // Invoked when the Google base URL has changed. Updates the mapping for all | 582 // Invoked when the Google base URL has changed. Updates the mapping for all |
| 582 // TemplateURLs that have a replacement term of {google:baseURL} or | 583 // TemplateURLs that have a replacement term of {google:baseURL} or |
| 583 // {google:baseSuggestURL}. | 584 // {google:baseSuggestURL}. |
| 584 void GoogleBaseURLChanged(); | 585 void GoogleBaseURLChanged(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 // Helper class to manage the default search engine. | 833 // Helper class to manage the default search engine. |
| 833 DefaultSearchManager default_search_manager_; | 834 DefaultSearchManager default_search_manager_; |
| 834 | 835 |
| 835 std::unique_ptr<GoogleURLTracker::Subscription> | 836 std::unique_ptr<GoogleURLTracker::Subscription> |
| 836 google_url_updated_subscription_; | 837 google_url_updated_subscription_; |
| 837 | 838 |
| 838 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 839 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 839 }; | 840 }; |
| 840 | 841 |
| 841 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 842 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |