| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 // Returns the default search provider. If the TemplateURLService hasn't been | 196 // Returns the default search provider. If the TemplateURLService hasn't been |
| 197 // loaded, the default search provider is pulled from preferences. | 197 // loaded, the default search provider is pulled from preferences. |
| 198 // | 198 // |
| 199 // NOTE: At least in unittest mode, this may return NULL. | 199 // NOTE: At least in unittest mode, this may return NULL. |
| 200 const TemplateURL* GetDefaultSearchProvider(); | 200 const TemplateURL* GetDefaultSearchProvider(); |
| 201 | 201 |
| 202 // Returns true if the default search is managed through group policy. | 202 // Returns true if the default search is managed through group policy. |
| 203 bool is_default_search_managed() const { return is_default_search_managed_; } | 203 bool is_default_search_managed() const { return is_default_search_managed_; } |
| 204 | 204 |
| 205 // Returns the default search specified in the prepopulated data, if it |
| 206 // exists. If not, returns first URL in |template_urls_|, or NULL if that's |
| 207 // empty. The returned object is owned by TemplateURLService and can be |
| 208 // destroyed at any time so should be used right after the call. |
| 209 const TemplateURL* FindNewDefaultSearchProvider(); |
| 210 |
| 205 // Observers used to listen for changes to the model. | 211 // Observers used to listen for changes to the model. |
| 206 // TemplateURLService does NOT delete the observers when deleted. | 212 // TemplateURLService does NOT delete the observers when deleted. |
| 207 void AddObserver(TemplateURLServiceObserver* observer); | 213 void AddObserver(TemplateURLServiceObserver* observer); |
| 208 void RemoveObserver(TemplateURLServiceObserver* observer); | 214 void RemoveObserver(TemplateURLServiceObserver* observer); |
| 209 | 215 |
| 210 // Loads the keywords. This has no effect if the keywords have already been | 216 // Loads the keywords. This has no effect if the keywords have already been |
| 211 // loaded. | 217 // loaded. |
| 212 // Observers are notified when loading completes via the method | 218 // Observers are notified when loading completes via the method |
| 213 // OnTemplateURLServiceChanged. | 219 // OnTemplateURLServiceChanged. |
| 214 void Load(); | 220 void Load(); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 424 |
| 419 // Invoked when the Google base URL has changed. Updates the mapping for all | 425 // Invoked when the Google base URL has changed. Updates the mapping for all |
| 420 // TemplateURLs that have a replacement term of {google:baseURL} or | 426 // TemplateURLs that have a replacement term of {google:baseURL} or |
| 421 // {google:baseSuggestURL}. | 427 // {google:baseSuggestURL}. |
| 422 void GoogleBaseURLChanged(); | 428 void GoogleBaseURLChanged(); |
| 423 | 429 |
| 424 // Update the default search. Called at initialization or when a managed | 430 // Update the default search. Called at initialization or when a managed |
| 425 // preference has changed. | 431 // preference has changed. |
| 426 void UpdateDefaultSearch(); | 432 void UpdateDefaultSearch(); |
| 427 | 433 |
| 428 // Returns the default search specified in the prepopulated data, if it | |
| 429 // exists. If not, returns first URL in |template_urls_|, or NULL if that's | |
| 430 // empty. | |
| 431 const TemplateURL* FindNewDefaultSearchProvider(); | |
| 432 | |
| 433 // Set the default search provider even if it is managed. |url| may be null. | 434 // Set the default search provider even if it is managed. |url| may be null. |
| 434 // Caller is responsible for notifying observers. | 435 // Caller is responsible for notifying observers. |
| 435 void SetDefaultSearchProviderNoNotify(const TemplateURL* url); | 436 void SetDefaultSearchProviderNoNotify(const TemplateURL* url); |
| 436 | 437 |
| 437 // Adds a new TemplateURL to this model. TemplateURLService will own the | 438 // Adds a new TemplateURL to this model. TemplateURLService will own the |
| 438 // reference, and delete it when the TemplateURL is removed. | 439 // reference, and delete it when the TemplateURL is removed. |
| 439 // Caller is responsible for notifying observers. | 440 // Caller is responsible for notifying observers. |
| 440 void AddNoNotify(TemplateURL* template_url); | 441 void AddNoNotify(TemplateURL* template_url); |
| 441 | 442 |
| 442 // Removes the keyword from the model. This deletes the supplied TemplateURL. | 443 // Removes the keyword from the model. This deletes the supplied TemplateURL. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 // true, we ignore any local search engine changes, since we triggered them. | 571 // true, we ignore any local search engine changes, since we triggered them. |
| 571 bool processing_syncer_changes_; | 572 bool processing_syncer_changes_; |
| 572 | 573 |
| 573 // Sync's SyncChange handler. We push all our changes through this. | 574 // Sync's SyncChange handler. We push all our changes through this. |
| 574 SyncChangeProcessor* sync_processor_; | 575 SyncChangeProcessor* sync_processor_; |
| 575 | 576 |
| 576 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 577 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 577 }; | 578 }; |
| 578 | 579 |
| 579 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 580 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |