Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/search/local_ntp_source.h

Issue 2819553003: Hook up LocalNtpSource to OneGoogleBarService (Closed)
Patch Set: Tests! Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string>
10 #include <vector>
9 11
10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/optional.h"
15 #include "base/scoped_observer.h"
16 #include "chrome/browser/search/one_google_bar/one_google_bar_service_observer.h "
13 #include "content/public/browser/url_data_source.h" 17 #include "content/public/browser/url_data_source.h"
14 18
19 struct OneGoogleBarData;
20 class OneGoogleBarService;
15 class Profile; 21 class Profile;
16 22
17 // Serves HTML and resources for the local new tab page i.e. 23 // Serves HTML and resources for the local new tab page i.e.
18 // chrome-search://local-ntp/local-ntp.html 24 // chrome-search://local-ntp/local-ntp.html
19 class LocalNtpSource : public content::URLDataSource { 25 class LocalNtpSource : public content::URLDataSource,
26 public OneGoogleBarServiceObserver {
20 public: 27 public:
21 explicit LocalNtpSource(Profile* profile); 28 explicit LocalNtpSource(Profile* profile);
22 29
23 private: 30 private:
24 class GoogleSearchProviderTracker; 31 class GoogleSearchProviderTracker;
25 32
26 ~LocalNtpSource() override; 33 ~LocalNtpSource() override;
27 34
28 // Overridden from content::URLDataSource: 35 // Overridden from content::URLDataSource:
29 std::string GetSource() const override; 36 std::string GetSource() const override;
30 void StartDataRequest( 37 void StartDataRequest(
31 const std::string& path, 38 const std::string& path,
32 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, 39 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
33 const content::URLDataSource::GotDataCallback& callback) override; 40 const content::URLDataSource::GotDataCallback& callback) override;
34 std::string GetMimeType(const std::string& path) const override; 41 std::string GetMimeType(const std::string& path) const override;
35 bool AllowCaching() const override; 42 bool AllowCaching() const override;
36 bool ShouldServiceRequest(const net::URLRequest* request) const override; 43 bool ShouldServiceRequest(const net::URLRequest* request) const override;
37 std::string GetContentSecurityPolicyScriptSrc() const override; 44 std::string GetContentSecurityPolicyScriptSrc() const override;
38 std::string GetContentSecurityPolicyChildSrc() const override; 45 std::string GetContentSecurityPolicyChildSrc() const override;
39 46
47 // Overridden from OneGoogleBarServiceObserver:
48 void OnOneGoogleBarDataChanged() override;
49 void OnOneGoogleBarFetchFailed() override;
50 void OnOneGoogleBarServiceShuttingDown() override;
51
52 void ServeOneGoogleBar(const OneGoogleBarData& data);
53 void ServeNullOneGoogleBar();
54
40 void DefaultSearchProviderIsGoogleChanged(bool is_google); 55 void DefaultSearchProviderIsGoogleChanged(bool is_google);
41 56
42 void SetDefaultSearchProviderIsGoogleOnIOThread(bool is_google); 57 void SetDefaultSearchProviderIsGoogleOnIOThread(bool is_google);
43 58
44 Profile* profile_; 59 Profile* const profile_;
60
61 OneGoogleBarService* one_google_bar_service_;
62
63 ScopedObserver<OneGoogleBarService, OneGoogleBarServiceObserver>
64 one_google_bar_service_observer_;
65
66 std::vector<content::URLDataSource::GotDataCallback> one_google_callbacks_;
45 67
46 std::unique_ptr<GoogleSearchProviderTracker> google_tracker_; 68 std::unique_ptr<GoogleSearchProviderTracker> google_tracker_;
47 bool default_search_provider_is_google_; 69 bool default_search_provider_is_google_;
48 // A copy of |default_search_provider_is_google_| for use on the IO thread. 70 // A copy of |default_search_provider_is_google_| for use on the IO thread.
49 bool default_search_provider_is_google_io_thread_; 71 bool default_search_provider_is_google_io_thread_;
50 72
51 base::WeakPtrFactory<LocalNtpSource> weak_ptr_factory_; 73 base::WeakPtrFactory<LocalNtpSource> weak_ptr_factory_;
52 74
53 DISALLOW_COPY_AND_ASSIGN(LocalNtpSource); 75 DISALLOW_COPY_AND_ASSIGN(LocalNtpSource);
54 }; 76 };
55 77
56 #endif // CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_ 78 #endif // CHROME_BROWSER_SEARCH_LOCAL_NTP_SOURCE_H_
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/local_ntp.js ('k') | chrome/browser/search/local_ntp_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698