blob: 1d2b6526c4c5e5bf0bbd3581cecd2a45d405415d [file] [log] [blame]
[email protected]a3536432013-03-26 08:14:311// 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
treib3be61a92017-04-25 13:03:388#include <memory>
9
[email protected]a3536432013-03-26 08:14:3110#include "base/compiler_specific.h"
avib896c712015-12-26 02:10:4311#include "base/macros.h"
treib3be61a92017-04-25 13:03:3812#include "base/memory/weak_ptr.h"
[email protected]a3536432013-03-26 08:14:3113#include "content/public/browser/url_data_source.h"
14
[email protected]5df96ab2013-07-17 23:14:4815class Profile;
16
[email protected]a3536432013-03-26 08:14:3117// Serves HTML and resources for the local new tab page i.e.
18// chrome-search://local-ntp/local-ntp.html
19class LocalNtpSource : public content::URLDataSource {
20 public:
[email protected]5df96ab2013-07-17 23:14:4821 explicit LocalNtpSource(Profile* profile);
[email protected]a3536432013-03-26 08:14:3122
23 private:
treib3be61a92017-04-25 13:03:3824 class GoogleSearchProviderTracker;
25
Daniel Chenga542fca2014-10-21 09:51:2926 ~LocalNtpSource() override;
[email protected]a3536432013-03-26 08:14:3127
28 // Overridden from content::URLDataSource:
Daniel Chenga542fca2014-10-21 09:51:2929 std::string GetSource() const override;
30 void StartDataRequest(
[email protected]a3536432013-03-26 08:14:3131 const std::string& path,
jamedcd8b012016-09-20 02:03:5832 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
mostynbfb66cb4f2014-10-07 09:15:4233 const content::URLDataSource::GotDataCallback& callback) override;
Daniel Chenga542fca2014-10-21 09:51:2934 std::string GetMimeType(const std::string& path) const override;
toyoshim501ba312016-11-30 08:25:5535 bool AllowCaching() const override;
Daniel Chenga542fca2014-10-21 09:51:2936 bool ShouldServiceRequest(const net::URLRequest* request) const override;
treib3be61a92017-04-25 13:03:3837 std::string GetContentSecurityPolicyScriptSrc() const override;
wychend6eb7792016-06-04 00:52:5338 std::string GetContentSecurityPolicyChildSrc() const override;
[email protected]a3536432013-03-26 08:14:3139
treib3be61a92017-04-25 13:03:3840 void DefaultSearchProviderIsGoogleChanged(bool is_google);
41
42 void SetDefaultSearchProviderIsGoogleOnIOThread(bool is_google);
43
[email protected]5df96ab2013-07-17 23:14:4844 Profile* profile_;
45
treib3be61a92017-04-25 13:03:3846 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]a3536432013-03-26 08:14:3153 DISALLOW_COPY_AND_ASSIGN(LocalNtpSource);
54};
55
56#endif // CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_