| 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" | |
| 14 #include "base/time.h" | 13 #include "base/time.h" |
| 15 #include "base/timer.h" | 14 #include "base/timer.h" |
| 16 #include "chrome/browser/sessions/tab_restore_service.h" | 15 #include "chrome/browser/sessions/tab_restore_service.h" |
| 17 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 18 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/web_ui_controller.h" | 19 #include "content/public/browser/web_ui_controller.h" |
| 21 | 20 |
| 22 class GURL; | 21 class GURL; |
| 23 class PrefService; | 22 class PrefService; |
| 24 class Profile; | 23 class Profile; |
| 25 | 24 |
| 26 // The WebContents used for the New Tab page. | 25 // The WebContents used for the New Tab page. |
| 27 class NewTabUI : public content::WebUIController, | 26 class NewTabUI : public content::WebUIController, |
| 28 public content::NotificationObserver, | 27 public content::NotificationObserver { |
| 29 public PrefObserver { | |
| 30 public: | 28 public: |
| 31 explicit NewTabUI(content::WebUI* web_ui); | 29 explicit NewTabUI(content::WebUI* web_ui); |
| 32 virtual ~NewTabUI(); | 30 virtual ~NewTabUI(); |
| 33 | 31 |
| 34 static void RegisterUserPrefs(PrefService* prefs); | 32 static void RegisterUserPrefs(PrefService* prefs); |
| 35 | 33 |
| 36 // Returns whether or not to show apps pages. | 34 // Returns whether or not to show apps pages. |
| 37 static bool ShouldShowApps(); | 35 static bool ShouldShowApps(); |
| 38 | 36 |
| 39 // Returns whether or not "Discovery" in the NTP is Enabled. | 37 // Returns whether or not "Discovery" in the NTP is Enabled. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 }; | 97 }; |
| 100 | 98 |
| 101 private: | 99 private: |
| 102 FRIEND_TEST_ALL_PREFIXES(NewTabUITest, UpdateUserPrefsVersion); | 100 FRIEND_TEST_ALL_PREFIXES(NewTabUITest, UpdateUserPrefsVersion); |
| 103 | 101 |
| 104 // content::NotificationObserver implementation. | 102 // content::NotificationObserver implementation. |
| 105 virtual void Observe(int type, | 103 virtual void Observe(int type, |
| 106 const content::NotificationSource& source, | 104 const content::NotificationSource& source, |
| 107 const content::NotificationDetails& details) OVERRIDE; | 105 const content::NotificationDetails& details) OVERRIDE; |
| 108 | 106 |
| 109 // PrefObserver implementation. | 107 void OnShowBookmarkBarChanged(); |
| 110 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
| 111 const std::string& pref_name) OVERRIDE; | |
| 112 | 108 |
| 113 // Reset the CSS caches. | 109 // Reset the CSS caches. |
| 114 void InitializeCSSCaches(); | 110 void InitializeCSSCaches(); |
| 115 | 111 |
| 116 void StartTimingPaint(content::RenderViewHost* render_view_host); | 112 void StartTimingPaint(content::RenderViewHost* render_view_host); |
| 117 void PaintTimeout(); | 113 void PaintTimeout(); |
| 118 | 114 |
| 119 Profile* GetProfile() const; | 115 Profile* GetProfile() const; |
| 120 | 116 |
| 121 content::NotificationRegistrar registrar_; | 117 content::NotificationRegistrar registrar_; |
| 122 | 118 |
| 123 // The time when we started benchmarking. | 119 // The time when we started benchmarking. |
| 124 base::TimeTicks start_; | 120 base::TimeTicks start_; |
| 125 // The last time we got a paint notification. | 121 // The last time we got a paint notification. |
| 126 base::TimeTicks last_paint_; | 122 base::TimeTicks last_paint_; |
| 127 // Scoping so we can be sure our timeouts don't outlive us. | 123 // Scoping so we can be sure our timeouts don't outlive us. |
| 128 base::OneShotTimer<NewTabUI> timer_; | 124 base::OneShotTimer<NewTabUI> timer_; |
| 129 // The preference version. This used for migrating prefs of the NTP. | 125 // The preference version. This used for migrating prefs of the NTP. |
| 130 static const int current_pref_version_ = 3; | 126 static const int current_pref_version_ = 3; |
| 131 | 127 |
| 132 // If the sync promo NTP bubble is being shown. | 128 // If the sync promo NTP bubble is being shown. |
| 133 bool showing_sync_bubble_; | 129 bool showing_sync_bubble_; |
| 134 | 130 |
| 135 PrefChangeRegistrar pref_change_registrar_; | 131 PrefChangeRegistrar pref_change_registrar_; |
| 136 | 132 |
| 137 DISALLOW_COPY_AND_ASSIGN(NewTabUI); | 133 DISALLOW_COPY_AND_ASSIGN(NewTabUI); |
| 138 }; | 134 }; |
| 139 | 135 |
| 140 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ | 136 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ |
| OLD | NEW |