OLD | NEW |
---|---|
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
102 virtual void Observe(int type, | 104 virtual void Observe(int type, |
103 const content::NotificationSource& source, | 105 const content::NotificationSource& source, |
104 const content::NotificationDetails& details) OVERRIDE; | 106 const content::NotificationDetails& details) OVERRIDE; |
105 | 107 |
Mattias Nissler (ping if slow)
2012/10/31 13:29:36
// PrefObserver:
Jói
2012/10/31 14:56:26
Done.
| |
108 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
109 const std::string& pref_name) OVERRIDE; | |
110 | |
106 // Reset the CSS caches. | 111 // Reset the CSS caches. |
107 void InitializeCSSCaches(); | 112 void InitializeCSSCaches(); |
108 | 113 |
109 void StartTimingPaint(content::RenderViewHost* render_view_host); | 114 void StartTimingPaint(content::RenderViewHost* render_view_host); |
110 void PaintTimeout(); | 115 void PaintTimeout(); |
111 | 116 |
112 Profile* GetProfile() const; | 117 Profile* GetProfile() const; |
113 | 118 |
114 content::NotificationRegistrar registrar_; | 119 content::NotificationRegistrar registrar_; |
115 | 120 |
116 // The time when we started benchmarking. | 121 // The time when we started benchmarking. |
117 base::TimeTicks start_; | 122 base::TimeTicks start_; |
118 // The last time we got a paint notification. | 123 // The last time we got a paint notification. |
119 base::TimeTicks last_paint_; | 124 base::TimeTicks last_paint_; |
120 // Scoping so we can be sure our timeouts don't outlive us. | 125 // Scoping so we can be sure our timeouts don't outlive us. |
121 base::OneShotTimer<NewTabUI> timer_; | 126 base::OneShotTimer<NewTabUI> timer_; |
122 // The preference version. This used for migrating prefs of the NTP. | 127 // The preference version. This used for migrating prefs of the NTP. |
123 static const int current_pref_version_ = 3; | 128 static const int current_pref_version_ = 3; |
124 | 129 |
125 // If the sync promo NTP bubble is being shown. | 130 // If the sync promo NTP bubble is being shown. |
126 bool showing_sync_bubble_; | 131 bool showing_sync_bubble_; |
127 | 132 |
128 PrefChangeRegistrar pref_change_registrar_; | 133 PrefChangeRegistrar pref_change_registrar_; |
129 | 134 |
130 DISALLOW_COPY_AND_ASSIGN(NewTabUI); | 135 DISALLOW_COPY_AND_ASSIGN(NewTabUI); |
131 }; | 136 }; |
132 | 137 |
133 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ | 138 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ |
OLD | NEW |