| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "chrome/browser/prefs/pref_change_registrar.h" | 18 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 19 #include "chrome/browser/profiles/profile_keyed_service.h" | 19 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 20 #include "chrome/browser/search_engines/template_url_id.h" | 20 #include "chrome/browser/search_engines/template_url_id.h" |
| 21 #include "chrome/browser/sync/api/sync_change.h" | 21 #include "chrome/browser/sync/api/sync_change.h" |
| 22 #include "chrome/browser/sync/api/syncable_service.h" | 22 #include "chrome/browser/sync/api/syncable_service.h" |
| 23 #include "chrome/browser/webdata/web_data_service.h" | 23 #include "chrome/browser/webdata/web_data_service.h" |
| 24 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
| 25 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 26 | 26 |
| 27 class Extension; | |
| 28 class GURL; | 27 class GURL; |
| 29 class PrefService; | 28 class PrefService; |
| 30 class Profile; | 29 class Profile; |
| 31 class SearchHostToURLsMap; | 30 class SearchHostToURLsMap; |
| 32 class SearchTermsData; | 31 class SearchTermsData; |
| 33 class SyncData; | 32 class SyncData; |
| 34 class SyncErrorFactory; | 33 class SyncErrorFactory; |
| 35 class TemplateURLServiceObserver; | 34 class TemplateURLServiceObserver; |
| 36 | 35 |
| 36 namespace extensions { |
| 37 class Extension; |
| 38 } |
| 39 |
| 37 namespace history { | 40 namespace history { |
| 38 struct URLVisitedDetails; | 41 struct URLVisitedDetails; |
| 39 } | 42 } |
| 40 | 43 |
| 41 // TemplateURLService is the backend for keywords. It's used by | 44 // TemplateURLService is the backend for keywords. It's used by |
| 42 // KeywordAutocomplete. | 45 // KeywordAutocomplete. |
| 43 // | 46 // |
| 44 // TemplateURLService stores a vector of TemplateURLs. The TemplateURLs are | 47 // TemplateURLService stores a vector of TemplateURLs. The TemplateURLs are |
| 45 // persisted to the database maintained by WebDataService. *ALL* mutations | 48 // persisted to the database maintained by WebDataService. *ALL* mutations |
| 46 // to the TemplateURLs must funnel through TemplateURLService. This allows | 49 // to the TemplateURLs must funnel through TemplateURLService. This allows |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Removes all auto-generated keywords that were created in the specified | 170 // Removes all auto-generated keywords that were created in the specified |
| 168 // range for a specified |origin|. If |origin| is empty, deletes all | 171 // range for a specified |origin|. If |origin| is empty, deletes all |
| 169 // auto-generated keywords in the range. | 172 // auto-generated keywords in the range. |
| 170 void RemoveAutoGeneratedForOriginBetween(const GURL& origin, | 173 void RemoveAutoGeneratedForOriginBetween(const GURL& origin, |
| 171 base::Time created_after, | 174 base::Time created_after, |
| 172 base::Time created_before); | 175 base::Time created_before); |
| 173 | 176 |
| 174 // If the given extension has an omnibox keyword, adds a TemplateURL for that | 177 // If the given extension has an omnibox keyword, adds a TemplateURL for that |
| 175 // keyword. Only 1 keyword is allowed for a given extension. If the keyword | 178 // keyword. Only 1 keyword is allowed for a given extension. If the keyword |
| 176 // already exists for this extension, does nothing. | 179 // already exists for this extension, does nothing. |
| 177 void RegisterExtensionKeyword(const Extension* extension); | 180 void RegisterExtensionKeyword(const extensions::Extension* extension); |
| 178 | 181 |
| 179 // Removes the TemplateURL containing the keyword for the given extension, | 182 // Removes the TemplateURL containing the keyword for the given extension, |
| 180 // if any. | 183 // if any. |
| 181 void UnregisterExtensionKeyword(const Extension* extension); | 184 void UnregisterExtensionKeyword(const extensions::Extension* extension); |
| 182 | 185 |
| 183 // Returns the TemplateURL associated with the keyword for this extension. | 186 // Returns the TemplateURL associated with the keyword for this extension. |
| 184 // This works by checking the extension ID, not the keyword, so it will work | 187 // This works by checking the extension ID, not the keyword, so it will work |
| 185 // even if the user changed the keyword. | 188 // even if the user changed the keyword. |
| 186 TemplateURL* GetTemplateURLForExtension(const Extension* extension); | 189 TemplateURL* GetTemplateURLForExtension( |
| 190 const extensions::Extension* extension); |
| 187 | 191 |
| 188 // Returns the set of URLs describing the keywords. The elements are owned | 192 // Returns the set of URLs describing the keywords. The elements are owned |
| 189 // by TemplateURLService and should not be deleted. | 193 // by TemplateURLService and should not be deleted. |
| 190 TemplateURLVector GetTemplateURLs(); | 194 TemplateURLVector GetTemplateURLs(); |
| 191 | 195 |
| 192 // Increment the usage count of a keyword. | 196 // Increment the usage count of a keyword. |
| 193 // Called when a URL is loaded that was generated from a keyword. | 197 // Called when a URL is loaded that was generated from a keyword. |
| 194 void IncrementUsageCount(TemplateURL* url); | 198 void IncrementUsageCount(TemplateURL* url); |
| 195 | 199 |
| 196 // Resets the title, keyword and search url of the specified TemplateURL. | 200 // Resets the title, keyword and search url of the specified TemplateURL. |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 // from Sync. This is to facilitate the fact that changes to the value of | 629 // from Sync. This is to facilitate the fact that changes to the value of |
| 626 // prefs::kSyncedDefaultSearchProviderGUID do not always come before the | 630 // prefs::kSyncedDefaultSearchProviderGUID do not always come before the |
| 627 // TemplateURL entry it refers to, and to handle the case when we want to use | 631 // TemplateURL entry it refers to, and to handle the case when we want to use |
| 628 // the Synced default when the default search provider becomes unmanaged. | 632 // the Synced default when the default search provider becomes unmanaged. |
| 629 bool pending_synced_default_search_; | 633 bool pending_synced_default_search_; |
| 630 | 634 |
| 631 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 635 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 632 }; | 636 }; |
| 633 | 637 |
| 634 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 638 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |