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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "chrome/browser/profiles/profile_keyed_service.h" | 17 #include "chrome/browser/profiles/profile_keyed_service.h" |
18 #include "chrome/browser/search_engines/search_host_to_urls_map.h" | 18 #include "chrome/browser/search_engines/search_host_to_urls_map.h" |
19 #include "chrome/browser/search_engines/template_url_id.h" | 19 #include "chrome/browser/search_engines/template_url_id.h" |
20 #include "chrome/browser/sync/api/sync_change.h" | 20 #include "chrome/browser/sync/api/sync_change.h" |
21 #include "chrome/browser/sync/api/syncable_service.h" | 21 #include "chrome/browser/sync/api/syncable_service.h" |
22 #include "chrome/browser/webdata/web_data_service.h" | 22 #include "chrome/browser/webdata/web_data_service.h" |
23 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
24 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
25 | 25 |
| 26 class Extension; |
26 class GURL; | 27 class GURL; |
27 class Extension; | |
28 class PrefService; | 28 class PrefService; |
| 29 class PrefSetObserver; |
29 class Profile; | 30 class Profile; |
30 class PrefSetObserver; | |
31 class SearchHostToURLsMap; | 31 class SearchHostToURLsMap; |
32 class SearchTermsData; | 32 class SearchTermsData; |
33 class SyncData; | 33 class SyncData; |
34 class TemplateURLServiceObserver; | 34 class TemplateURLServiceObserver; |
35 class TemplateURLRef; | |
36 | 35 |
37 namespace history { | 36 namespace history { |
38 struct URLVisitedDetails; | 37 struct URLVisitedDetails; |
39 } | 38 } |
40 | 39 |
41 // TemplateURLService is the backend for keywords. It's used by | 40 // TemplateURLService is the backend for keywords. It's used by |
42 // KeywordAutocomplete. | 41 // KeywordAutocomplete. |
43 // | 42 // |
44 // TemplateURLService stores a vector of TemplateURLs. The TemplateURLs are | 43 // TemplateURLService stores a vector of TemplateURLs. The TemplateURLs are |
45 // persisted to the database maintained by WebDataService. *ALL* mutations | 44 // persisted to the database maintained by WebDataService. *ALL* mutations |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 410 |
412 // If necessary, generates a visit for the site http:// + t_url.keyword(). | 411 // If necessary, generates a visit for the site http:// + t_url.keyword(). |
413 void AddTabToSearchVisit(const TemplateURL& t_url); | 412 void AddTabToSearchVisit(const TemplateURL& t_url); |
414 | 413 |
415 // Adds each of the query terms in the specified url whose key and value are | 414 // Adds each of the query terms in the specified url whose key and value are |
416 // non-empty to query_terms. If a query key appears multiple times, the value | 415 // non-empty to query_terms. If a query key appears multiple times, the value |
417 // is set to an empty string. Returns true if there is at least one key that | 416 // is set to an empty string. Returns true if there is at least one key that |
418 // does not occur multiple times. | 417 // does not occur multiple times. |
419 static bool BuildQueryTerms( | 418 static bool BuildQueryTerms( |
420 const GURL& url, | 419 const GURL& url, |
421 std::map<std::string,std::string>* query_terms); | 420 std::map<std::string, std::string>* query_terms); |
422 | 421 |
423 // Invoked when the Google base URL has changed. Updates the mapping for all | 422 // Invoked when the Google base URL has changed. Updates the mapping for all |
424 // TemplateURLs that have a replacement term of {google:baseURL} or | 423 // TemplateURLs that have a replacement term of {google:baseURL} or |
425 // {google:baseSuggestURL}. | 424 // {google:baseSuggestURL}. |
426 void GoogleBaseURLChanged(); | 425 void GoogleBaseURLChanged(); |
427 | 426 |
428 // Update the default search. Called at initialization or when a managed | 427 // Update the default search. Called at initialization or when a managed |
429 // preference has changed. | 428 // preference has changed. |
430 void UpdateDefaultSearch(); | 429 void UpdateDefaultSearch(); |
431 | 430 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 // from Sync. This is to facilitate the fact that changes to the value of | 588 // from Sync. This is to facilitate the fact that changes to the value of |
590 // prefs::kSyncedDefaultSearchProviderGUID do not always come before the | 589 // prefs::kSyncedDefaultSearchProviderGUID do not always come before the |
591 // TemplateURL entry it refers to, and to handle the case when we want to use | 590 // TemplateURL entry it refers to, and to handle the case when we want to use |
592 // the Synced default when the default search provider becomes unmanaged. | 591 // the Synced default when the default search provider becomes unmanaged. |
593 bool pending_synced_default_search_; | 592 bool pending_synced_default_search_; |
594 | 593 |
595 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 594 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
596 }; | 595 }; |
597 | 596 |
598 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 597 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
OLD | NEW |