OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SEARCH_GOOGLE_SEARCH_PROVIDER_SERVICE_H_ | |
6 #define CHROME_BROWSER_SEARCH_GOOGLE_SEARCH_PROVIDER_SERVICE_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/observer_list.h" | |
10 #include "base/scoped_observer.h" | |
11 #include "chrome/browser/search/google_search_provider_service_observer.h" | |
12 #include "components/keyed_service/core/keyed_service.h" | |
13 #include "components/search_engines/template_url_service_observer.h" | |
14 | |
15 class TemplateURLService; | |
16 | |
17 // Tracks whether the default search provider is Google. | |
sfiera
2017/04/11 09:45:17
Comments? Tests? It's not clear from the header wh
Marc Treib
2017/04/11 12:37:59
Two things:
1) It abstracts away the kinda yucky T
sfiera
2017/04/11 14:07:35
On its own, I'm not sure that motivates this class
Marc Treib
2017/04/12 11:53:45
You're right, this isn't really worth a new servic
| |
18 class GoogleSearchProviderService : public KeyedService, | |
19 public TemplateURLServiceObserver { | |
20 public: | |
21 explicit GoogleSearchProviderService( | |
22 TemplateURLService* template_url_service); | |
23 ~GoogleSearchProviderService() override; | |
24 | |
25 // KeyedService implementation. | |
26 void Shutdown() override; | |
27 | |
28 bool DefaultSearchProviderIsGoogle() const; | |
29 | |
30 void AddObserver(GoogleSearchProviderServiceObserver* observer); | |
31 void RemoveObserver(GoogleSearchProviderServiceObserver* observer); | |
32 | |
33 private: | |
34 // TemplateURLServiceObserver implementation. | |
35 void OnTemplateURLServiceChanged() override; | |
36 | |
37 TemplateURLService* template_url_service_; | |
38 ScopedObserver<TemplateURLService, GoogleSearchProviderService> | |
39 template_url_service_observer_; | |
40 | |
41 bool is_google_; | |
42 | |
43 base::ObserverList<GoogleSearchProviderServiceObserver, true> observers_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(GoogleSearchProviderService); | |
46 }; | |
47 | |
48 #endif // CHROME_BROWSER_SEARCH_GOOGLE_SEARCH_PROVIDER_SERVICE_H_ | |
OLD | NEW |