OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 explicit NewTabUI(TabContents* manager); | 29 explicit NewTabUI(TabContents* manager); |
30 virtual ~NewTabUI(); | 30 virtual ~NewTabUI(); |
31 | 31 |
32 // Override WebUI methods so we can hook up the paint timer to the render | 32 // Override WebUI methods so we can hook up the paint timer to the render |
33 // view host. | 33 // view host. |
34 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 34 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
35 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; | 35 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; |
36 | 36 |
37 static void RegisterUserPrefs(PrefService* prefs); | 37 static void RegisterUserPrefs(PrefService* prefs); |
38 static void MigrateUserPrefs(PrefService* prefs, int old_pref_version, | |
39 int new_pref_version); | |
40 | 38 |
41 // Adds "url", "title", and "direction" keys on incoming dictionary, setting | 39 // Adds "url", "title", and "direction" keys on incoming dictionary, setting |
42 // title as the url as a fallback on empty title. | 40 // title as the url as a fallback on empty title. |
43 static void SetURLTitleAndDirection(base::DictionaryValue* dictionary, | 41 static void SetURLTitleAndDirection(base::DictionaryValue* dictionary, |
44 const string16& title, | 42 const string16& title, |
45 const GURL& gurl); | 43 const GURL& gurl); |
46 | 44 |
47 // The current preference version. | 45 // The current preference version. |
48 static int current_pref_version() { return current_pref_version_; } | 46 static int current_pref_version() { return current_pref_version_; } |
49 | 47 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 virtual void Observe(int type, | 80 virtual void Observe(int type, |
83 const content::NotificationSource& source, | 81 const content::NotificationSource& source, |
84 const content::NotificationDetails& details); | 82 const content::NotificationDetails& details); |
85 | 83 |
86 // Reset the CSS caches. | 84 // Reset the CSS caches. |
87 void InitializeCSSCaches(); | 85 void InitializeCSSCaches(); |
88 | 86 |
89 void StartTimingPaint(RenderViewHost* render_view_host); | 87 void StartTimingPaint(RenderViewHost* render_view_host); |
90 void PaintTimeout(); | 88 void PaintTimeout(); |
91 | 89 |
92 // Updates the user prefs version and calls |MigrateUserPrefs| if needed. | |
93 // Returns true if the version was updated. | |
94 static bool UpdateUserPrefsVersion(PrefService* prefs); | |
95 | |
96 // Overridden from ChromeWebUI. Determines if the bookmarks bar can be shown | 90 // Overridden from ChromeWebUI. Determines if the bookmarks bar can be shown |
97 // detached from the location bar. | 91 // detached from the location bar. |
98 virtual bool CanShowBookmarkBar() const OVERRIDE; | 92 virtual bool CanShowBookmarkBar() const OVERRIDE; |
99 | 93 |
100 content::NotificationRegistrar registrar_; | 94 content::NotificationRegistrar registrar_; |
101 | 95 |
102 // Tracks updates of the kShowBookmarkBar preference. | 96 // Tracks updates of the kShowBookmarkBar preference. |
103 PrefChangeRegistrar pref_change_registrar_; | 97 PrefChangeRegistrar pref_change_registrar_; |
104 // The time when we started benchmarking. | 98 // The time when we started benchmarking. |
105 base::TimeTicks start_; | 99 base::TimeTicks start_; |
106 // The last time we got a paint notification. | 100 // The last time we got a paint notification. |
107 base::TimeTicks last_paint_; | 101 base::TimeTicks last_paint_; |
108 // Scoping so we can be sure our timeouts don't outlive us. | 102 // Scoping so we can be sure our timeouts don't outlive us. |
109 base::OneShotTimer<NewTabUI> timer_; | 103 base::OneShotTimer<NewTabUI> timer_; |
110 // The preference version. This used for migrating prefs of the NTP. | 104 // The preference version. This used for migrating prefs of the NTP. |
111 static const int current_pref_version_ = 3; | 105 static const int current_pref_version_ = 3; |
112 | 106 |
113 DISALLOW_COPY_AND_ASSIGN(NewTabUI); | 107 DISALLOW_COPY_AND_ASSIGN(NewTabUI); |
114 }; | 108 }; |
115 | 109 |
116 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ | 110 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ |
OLD | NEW |