| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class Profile; | 28 class Profile; |
| 29 class SearchHostToURLsMap; | 29 class SearchHostToURLsMap; |
| 30 class SearchTermsData; | 30 class SearchTermsData; |
| 31 class TemplateURLServiceObserver; | 31 class TemplateURLServiceObserver; |
| 32 | 32 |
| 33 namespace syncer { | 33 namespace syncer { |
| 34 class SyncData; | 34 class SyncData; |
| 35 class SyncErrorFactory; | 35 class SyncErrorFactory; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace extensions { | |
| 39 class Extension; | |
| 40 } | |
| 41 | |
| 42 namespace history { | 38 namespace history { |
| 43 struct URLVisitedDetails; | 39 struct URLVisitedDetails; |
| 44 } | 40 } |
| 45 | 41 |
| 46 // TemplateURLService is the backend for keywords. It's used by | 42 // TemplateURLService is the backend for keywords. It's used by |
| 47 // KeywordAutocomplete. | 43 // KeywordAutocomplete. |
| 48 // | 44 // |
| 49 // TemplateURLService stores a vector of TemplateURLs. The TemplateURLs are | 45 // TemplateURLService stores a vector of TemplateURLs. The TemplateURLs are |
| 50 // persisted to the database maintained by WebDataService. *ALL* mutations | 46 // persisted to the database maintained by WebDataService. *ALL* mutations |
| 51 // to the TemplateURLs must funnel through TemplateURLService. This allows | 47 // to the TemplateURLs must funnel through TemplateURLService. This allows |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 void RemoveAutoGeneratedBetween(base::Time created_after, | 165 void RemoveAutoGeneratedBetween(base::Time created_after, |
| 170 base::Time created_before); | 166 base::Time created_before); |
| 171 | 167 |
| 172 // Removes all auto-generated keywords that were created in the specified | 168 // Removes all auto-generated keywords that were created in the specified |
| 173 // range for a specified |origin|. If |origin| is empty, deletes all | 169 // range for a specified |origin|. If |origin| is empty, deletes all |
| 174 // auto-generated keywords in the range. | 170 // auto-generated keywords in the range. |
| 175 void RemoveAutoGeneratedForOriginBetween(const GURL& origin, | 171 void RemoveAutoGeneratedForOriginBetween(const GURL& origin, |
| 176 base::Time created_after, | 172 base::Time created_after, |
| 177 base::Time created_before); | 173 base::Time created_before); |
| 178 | 174 |
| 179 // If the given extension has an omnibox keyword, adds a TemplateURL for that | 175 // Adds a TemplateURL for an extension with an omnibox keyword. |
| 180 // keyword. Only 1 keyword is allowed for a given extension. If the keyword | 176 // Only 1 keyword is allowed for a given extension. If a keyword |
| 181 // already exists for this extension, does nothing. | 177 // already exists for this extension, does nothing. |
| 182 void RegisterExtensionKeyword(const extensions::Extension* extension); | 178 void RegisterExtensionKeyword(const std::string& extension_id, |
| 179 const std::string& extension_name, |
| 180 const std::string& keyword); |
| 183 | 181 |
| 184 // Removes the TemplateURL containing the keyword for the given extension, | 182 // Removes the TemplateURL containing the keyword for the extension with the |
| 185 // if any. | 183 // given ID, if any. |
| 186 void UnregisterExtensionKeyword(const extensions::Extension* extension); | 184 void UnregisterExtensionKeyword(const std::string& extension_id); |
| 187 | 185 |
| 188 // Returns the TemplateURL associated with the keyword for this extension. | 186 // Returns the TemplateURL associated with the keyword for this extension. |
| 189 // This works by checking the extension ID, not the keyword, so it will work | 187 // This will work even if the user changed the keyword. |
| 190 // even if the user changed the keyword. | 188 TemplateURL* GetTemplateURLForExtension(const std::string& extension_id); |
| 191 TemplateURL* GetTemplateURLForExtension( | |
| 192 const extensions::Extension* extension); | |
| 193 | 189 |
| 194 // Returns the set of URLs describing the keywords. The elements are owned | 190 // Returns the set of URLs describing the keywords. The elements are owned |
| 195 // by TemplateURLService and should not be deleted. | 191 // by TemplateURLService and should not be deleted. |
| 196 TemplateURLVector GetTemplateURLs(); | 192 TemplateURLVector GetTemplateURLs(); |
| 197 | 193 |
| 198 // Increment the usage count of a keyword. | 194 // Increment the usage count of a keyword. |
| 199 // Called when a URL is loaded that was generated from a keyword. | 195 // Called when a URL is loaded that was generated from a keyword. |
| 200 void IncrementUsageCount(TemplateURL* url); | 196 void IncrementUsageCount(TemplateURL* url); |
| 201 | 197 |
| 202 // Resets the title, keyword and search url of the specified TemplateURL. | 198 // Resets the title, keyword and search url of the specified TemplateURL. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 ResolveSyncKeywordConflict); | 352 ResolveSyncKeywordConflict); |
| 357 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, PreSyncDeletes); | 353 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, PreSyncDeletes); |
| 358 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, | 354 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, |
| 359 IsLocalTemplateURLBetter); | 355 IsLocalTemplateURLBetter); |
| 360 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, MergeInSyncTemplateURL); | 356 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, MergeInSyncTemplateURL); |
| 361 | 357 |
| 362 friend class TemplateURLServiceTestUtil; | 358 friend class TemplateURLServiceTestUtil; |
| 363 | 359 |
| 364 typedef std::map<string16, TemplateURL*> KeywordToTemplateMap; | 360 typedef std::map<string16, TemplateURL*> KeywordToTemplateMap; |
| 365 typedef std::map<std::string, TemplateURL*> GUIDToTemplateMap; | 361 typedef std::map<std::string, TemplateURL*> GUIDToTemplateMap; |
| 366 typedef std::list<std::string> PendingExtensionIDs; | |
| 367 | 362 |
| 368 // Declaration of values to be used in an enumerated histogram to tally | 363 // Declaration of values to be used in an enumerated histogram to tally |
| 369 // changes to the default search provider from various entry points. In | 364 // changes to the default search provider from various entry points. In |
| 370 // particular, we use this to see what proportion of changes are from Sync | 365 // particular, we use this to see what proportion of changes are from Sync |
| 371 // entry points, to help spot erroneous Sync activity. | 366 // entry points, to help spot erroneous Sync activity. |
| 372 enum DefaultSearchChangeOrigin { | 367 enum DefaultSearchChangeOrigin { |
| 373 // Various known Sync entry points. | 368 // Various known Sync entry points. |
| 374 DSP_CHANGE_SYNC_PREF, | 369 DSP_CHANGE_SYNC_PREF, |
| 375 DSP_CHANGE_SYNC_ADD, | 370 DSP_CHANGE_SYNC_ADD, |
| 376 DSP_CHANGE_SYNC_DELETE, | 371 DSP_CHANGE_SYNC_DELETE, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 // if we haven't been loaded or loading failed. | 628 // if we haven't been loaded or loading failed. |
| 634 scoped_ptr<TemplateURL> initial_default_search_provider_; | 629 scoped_ptr<TemplateURL> initial_default_search_provider_; |
| 635 | 630 |
| 636 // Whether the default search is managed via policy. | 631 // Whether the default search is managed via policy. |
| 637 bool is_default_search_managed_; | 632 bool is_default_search_managed_; |
| 638 | 633 |
| 639 // ID assigned to next TemplateURL added to this model. This is an ever | 634 // ID assigned to next TemplateURL added to this model. This is an ever |
| 640 // increasing integer that is initialized from the database. | 635 // increasing integer that is initialized from the database. |
| 641 TemplateURLID next_id_; | 636 TemplateURLID next_id_; |
| 642 | 637 |
| 643 // List of extension IDs waiting for Load to have keywords registered. | |
| 644 PendingExtensionIDs pending_extension_ids_; | |
| 645 | |
| 646 // Function returning current time in base::Time units. | 638 // Function returning current time in base::Time units. |
| 647 TimeProvider* time_provider_; | 639 TimeProvider* time_provider_; |
| 648 | 640 |
| 649 // Do we have an active association between the TemplateURLs and sync models? | 641 // Do we have an active association between the TemplateURLs and sync models? |
| 650 // Set in MergeDataAndStartSyncing, reset in StopSyncing. While this is not | 642 // Set in MergeDataAndStartSyncing, reset in StopSyncing. While this is not |
| 651 // set, we ignore any local search engine changes (when we start syncing we | 643 // set, we ignore any local search engine changes (when we start syncing we |
| 652 // will look up the most recent values anyways). | 644 // will look up the most recent values anyways). |
| 653 bool models_associated_; | 645 bool models_associated_; |
| 654 | 646 |
| 655 // Whether we're currently processing changes from the syncer. While this is | 647 // Whether we're currently processing changes from the syncer. While this is |
| (...skipping 21 matching lines...) Expand all Loading... |
| 677 | 669 |
| 678 // This is used to log the origin of changes to the default search provider. | 670 // This is used to log the origin of changes to the default search provider. |
| 679 // We set this value to increasingly specific values when we know what is the | 671 // We set this value to increasingly specific values when we know what is the |
| 680 // cause/origin of a default search change. | 672 // cause/origin of a default search change. |
| 681 DefaultSearchChangeOrigin dsp_change_origin_; | 673 DefaultSearchChangeOrigin dsp_change_origin_; |
| 682 | 674 |
| 683 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 675 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 684 }; | 676 }; |
| 685 | 677 |
| 686 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 678 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |