OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LOCAL_NTP_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ |
6 #define CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ | 6 #define CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/scoped_observer.h" |
| 11 #include "chrome/browser/search/google_search_provider_service_observer.h" |
10 #include "content/public/browser/url_data_source.h" | 12 #include "content/public/browser/url_data_source.h" |
11 | 13 |
| 14 class GoogleSearchProviderService; |
12 class Profile; | 15 class Profile; |
13 | 16 |
14 // Serves HTML and resources for the local new tab page i.e. | 17 // Serves HTML and resources for the local new tab page i.e. |
15 // chrome-search://local-ntp/local-ntp.html | 18 // chrome-search://local-ntp/local-ntp.html |
16 class LocalNtpSource : public content::URLDataSource { | 19 class LocalNtpSource : public content::URLDataSource, |
| 20 public GoogleSearchProviderServiceObserver { |
17 public: | 21 public: |
18 explicit LocalNtpSource(Profile* profile); | 22 explicit LocalNtpSource(Profile* profile); |
19 | 23 |
20 private: | 24 private: |
21 ~LocalNtpSource() override; | 25 ~LocalNtpSource() override; |
22 | 26 |
23 // Overridden from content::URLDataSource: | 27 // Overridden from content::URLDataSource: |
24 std::string GetSource() const override; | 28 std::string GetSource() const override; |
25 void StartDataRequest( | 29 void StartDataRequest( |
26 const std::string& path, | 30 const std::string& path, |
27 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | 31 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
28 const content::URLDataSource::GotDataCallback& callback) override; | 32 const content::URLDataSource::GotDataCallback& callback) override; |
29 std::string GetMimeType(const std::string& path) const override; | 33 std::string GetMimeType(const std::string& path) const override; |
30 bool AllowCaching() const override; | 34 bool AllowCaching() const override; |
31 bool ShouldServiceRequest(const net::URLRequest* request) const override; | 35 bool ShouldServiceRequest(const net::URLRequest* request) const override; |
| 36 std::string GetContentSecurityPolicyScriptSrc() const override; |
32 std::string GetContentSecurityPolicyChildSrc() const override; | 37 std::string GetContentSecurityPolicyChildSrc() const override; |
33 | 38 |
| 39 // Overridden from GoogleSearchProviderServiceObserver: |
| 40 void OnDefaultSearchProviderIsGoogleChanged(bool is_google) override; |
| 41 void OnGoogleSearchProviderServiceShuttingDown() override; |
| 42 |
34 Profile* profile_; | 43 Profile* profile_; |
35 | 44 |
| 45 ScopedObserver<GoogleSearchProviderService, LocalNtpSource> |
| 46 default_search_provider_observer_; |
| 47 bool default_search_provider_is_google_; |
| 48 |
36 DISALLOW_COPY_AND_ASSIGN(LocalNtpSource); | 49 DISALLOW_COPY_AND_ASSIGN(LocalNtpSource); |
37 }; | 50 }; |
38 | 51 |
39 #endif // CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ | 52 #endif // CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ |
OLD | NEW |