[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ | ||||
6 | #define CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ | ||||
7 | |||||
treib | 3be61a9 | 2017-04-25 13:03:38 | [diff] [blame^] | 8 | #include <memory> |
9 | |||||
[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 10 | #include "base/compiler_specific.h" |
avi | b896c71 | 2015-12-26 02:10:43 | [diff] [blame] | 11 | #include "base/macros.h" |
treib | 3be61a9 | 2017-04-25 13:03:38 | [diff] [blame^] | 12 | #include "base/memory/weak_ptr.h" |
[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 13 | #include "content/public/browser/url_data_source.h" |
14 | |||||
[email protected] | 5df96ab | 2013-07-17 23:14:48 | [diff] [blame] | 15 | class Profile; |
16 | |||||
[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 17 | // Serves HTML and resources for the local new tab page i.e. |
18 | // chrome-search://local-ntp/local-ntp.html | ||||
19 | class LocalNtpSource : public content::URLDataSource { | ||||
20 | public: | ||||
[email protected] | 5df96ab | 2013-07-17 23:14:48 | [diff] [blame] | 21 | explicit LocalNtpSource(Profile* profile); |
[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 22 | |
23 | private: | ||||
treib | 3be61a9 | 2017-04-25 13:03:38 | [diff] [blame^] | 24 | class GoogleSearchProviderTracker; |
25 | |||||
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 26 | ~LocalNtpSource() override; |
[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 27 | |
28 | // Overridden from content::URLDataSource: | ||||
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 29 | std::string GetSource() const override; |
30 | void StartDataRequest( | ||||
[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 31 | const std::string& path, |
jam | edcd8b01 | 2016-09-20 02:03:58 | [diff] [blame] | 32 | const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
mostynb | fb66cb4f | 2014-10-07 09:15:42 | [diff] [blame] | 33 | const content::URLDataSource::GotDataCallback& callback) override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 34 | std::string GetMimeType(const std::string& path) const override; |
toyoshim | 501ba31 | 2016-11-30 08:25:55 | [diff] [blame] | 35 | bool AllowCaching() const override; |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 36 | bool ShouldServiceRequest(const net::URLRequest* request) const override; |
treib | 3be61a9 | 2017-04-25 13:03:38 | [diff] [blame^] | 37 | std::string GetContentSecurityPolicyScriptSrc() const override; |
wychen | d6eb779 | 2016-06-04 00:52:53 | [diff] [blame] | 38 | std::string GetContentSecurityPolicyChildSrc() const override; |
[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 39 | |
treib | 3be61a9 | 2017-04-25 13:03:38 | [diff] [blame^] | 40 | void DefaultSearchProviderIsGoogleChanged(bool is_google); |
41 | |||||
42 | void SetDefaultSearchProviderIsGoogleOnIOThread(bool is_google); | ||||
43 | |||||
[email protected] | 5df96ab | 2013-07-17 23:14:48 | [diff] [blame] | 44 | Profile* profile_; |
45 | |||||
treib | 3be61a9 | 2017-04-25 13:03:38 | [diff] [blame^] | 46 | std::unique_ptr<GoogleSearchProviderTracker> google_tracker_; |
47 | bool default_search_provider_is_google_; | ||||
48 | // A copy of |default_search_provider_is_google_| for use on the IO thread. | ||||
49 | bool default_search_provider_is_google_io_thread_; | ||||
50 | |||||
51 | base::WeakPtrFactory<LocalNtpSource> weak_ptr_factory_; | ||||
52 | |||||
[email protected] | a353643 | 2013-03-26 08:14:31 | [diff] [blame] | 53 | DISALLOW_COPY_AND_ASSIGN(LocalNtpSource); |
54 | }; | ||||
55 | |||||
56 | #endif // CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ |