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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_ui.h

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_UI_WEBUI_NTP_NEW_TAB_UI_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/prefs/public/pref_change_registrar.h" 12 #include "base/prefs/public/pref_change_registrar.h"
13 #include "base/prefs/public/pref_observer.h"
13 #include "base/time.h" 14 #include "base/time.h"
14 #include "base/timer.h" 15 #include "base/timer.h"
15 #include "chrome/browser/sessions/tab_restore_service.h" 16 #include "chrome/browser/sessions/tab_restore_service.h"
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 17 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_ui_controller.h" 20 #include "content/public/browser/web_ui_controller.h"
20 21
21 class GURL; 22 class GURL;
22 class PrefService; 23 class PrefService;
23 class Profile; 24 class Profile;
24 25
25 // The WebContents used for the New Tab page. 26 // The WebContents used for the New Tab page.
26 class NewTabUI : public content::WebUIController, 27 class NewTabUI : public content::WebUIController,
27 public content::NotificationObserver { 28 public content::NotificationObserver,
29 public PrefObserver {
28 public: 30 public:
29 explicit NewTabUI(content::WebUI* web_ui); 31 explicit NewTabUI(content::WebUI* web_ui);
30 virtual ~NewTabUI(); 32 virtual ~NewTabUI();
31 33
32 static void RegisterUserPrefs(PrefService* prefs); 34 static void RegisterUserPrefs(PrefService* prefs);
33 35
34 // Returns whether or not to show apps pages. 36 // Returns whether or not to show apps pages.
35 static bool ShouldShowApps(); 37 static bool ShouldShowApps();
36 38
37 // Returns whether or not "Discovery" in the NTP is Enabled. 39 // Returns whether or not "Discovery" in the NTP is Enabled.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 94
93 // Maps resource files to mime types an resource ids. 95 // Maps resource files to mime types an resource ids.
94 std::map<std::string, std::pair<std::string, int> > resource_map_; 96 std::map<std::string, std::pair<std::string, int> > resource_map_;
95 97
96 DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource); 98 DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource);
97 }; 99 };
98 100
99 private: 101 private:
100 FRIEND_TEST_ALL_PREFIXES(NewTabUITest, UpdateUserPrefsVersion); 102 FRIEND_TEST_ALL_PREFIXES(NewTabUITest, UpdateUserPrefsVersion);
101 103
104 // content::NotificationObserver implementation.
102 virtual void Observe(int type, 105 virtual void Observe(int type,
103 const content::NotificationSource& source, 106 const content::NotificationSource& source,
104 const content::NotificationDetails& details) OVERRIDE; 107 const content::NotificationDetails& details) OVERRIDE;
105 108
109 // PrefObserver implementation.
110 virtual void OnPreferenceChanged(PrefServiceBase* service,
111 const std::string& pref_name) OVERRIDE;
112
106 // Reset the CSS caches. 113 // Reset the CSS caches.
107 void InitializeCSSCaches(); 114 void InitializeCSSCaches();
108 115
109 void StartTimingPaint(content::RenderViewHost* render_view_host); 116 void StartTimingPaint(content::RenderViewHost* render_view_host);
110 void PaintTimeout(); 117 void PaintTimeout();
111 118
112 Profile* GetProfile() const; 119 Profile* GetProfile() const;
113 120
114 content::NotificationRegistrar registrar_; 121 content::NotificationRegistrar registrar_;
115 122
116 // The time when we started benchmarking. 123 // The time when we started benchmarking.
117 base::TimeTicks start_; 124 base::TimeTicks start_;
118 // The last time we got a paint notification. 125 // The last time we got a paint notification.
119 base::TimeTicks last_paint_; 126 base::TimeTicks last_paint_;
120 // Scoping so we can be sure our timeouts don't outlive us. 127 // Scoping so we can be sure our timeouts don't outlive us.
121 base::OneShotTimer<NewTabUI> timer_; 128 base::OneShotTimer<NewTabUI> timer_;
122 // The preference version. This used for migrating prefs of the NTP. 129 // The preference version. This used for migrating prefs of the NTP.
123 static const int current_pref_version_ = 3; 130 static const int current_pref_version_ = 3;
124 131
125 // If the sync promo NTP bubble is being shown. 132 // If the sync promo NTP bubble is being shown.
126 bool showing_sync_bubble_; 133 bool showing_sync_bubble_;
127 134
128 PrefChangeRegistrar pref_change_registrar_; 135 PrefChangeRegistrar pref_change_registrar_;
129 136
130 DISALLOW_COPY_AND_ASSIGN(NewTabUI); 137 DISALLOW_COPY_AND_ASSIGN(NewTabUI);
131 }; 138 };
132 139
133 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ 140 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698