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 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/timer.h" | 13 #include "base/timer.h" |
14 #include "chrome/browser/prefs/pref_change_registrar.h" | |
15 #include "chrome/browser/sessions/tab_restore_service.h" | 14 #include "chrome/browser/sessions/tab_restore_service.h" |
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
17 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 16 #include "chrome/browser/ui/webui/chrome_web_ui.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 | 19 |
21 class GURL; | 20 class GURL; |
22 class PrefService; | 21 class PrefService; |
23 class Profile; | 22 class Profile; |
24 | 23 |
(...skipping 13 matching lines...) Expand all Loading... |
38 | 37 |
39 // Adds "url", "title", and "direction" keys on incoming dictionary, setting | 38 // Adds "url", "title", and "direction" keys on incoming dictionary, setting |
40 // title as the url as a fallback on empty title. | 39 // title as the url as a fallback on empty title. |
41 static void SetURLTitleAndDirection(base::DictionaryValue* dictionary, | 40 static void SetURLTitleAndDirection(base::DictionaryValue* dictionary, |
42 const string16& title, | 41 const string16& title, |
43 const GURL& gurl); | 42 const GURL& gurl); |
44 | 43 |
45 // The current preference version. | 44 // The current preference version. |
46 static int current_pref_version() { return current_pref_version_; } | 45 static int current_pref_version() { return current_pref_version_; } |
47 | 46 |
48 // Returns whether NTP4 is enabled. | |
49 static bool NTP4Enabled(); | |
50 | |
51 // Returns whether NTP4 bookmark features are enabled. | 47 // Returns whether NTP4 bookmark features are enabled. |
52 static bool NTP4BookmarkFeaturesEnabled(); | 48 static bool NTP4BookmarkFeaturesEnabled(); |
53 | 49 |
54 class NewTabHTMLSource : public ChromeURLDataManager::DataSource { | 50 class NewTabHTMLSource : public ChromeURLDataManager::DataSource { |
55 public: | 51 public: |
56 explicit NewTabHTMLSource(Profile* profile); | 52 explicit NewTabHTMLSource(Profile* profile); |
57 | 53 |
58 // Called when the network layer has requested a resource underneath | 54 // Called when the network layer has requested a resource underneath |
59 // the path we registered. | 55 // the path we registered. |
60 virtual void StartDataRequest(const std::string& path, | 56 virtual void StartDataRequest(const std::string& path, |
(...skipping 25 matching lines...) Expand all Loading... |
86 | 82 |
87 void StartTimingPaint(RenderViewHost* render_view_host); | 83 void StartTimingPaint(RenderViewHost* render_view_host); |
88 void PaintTimeout(); | 84 void PaintTimeout(); |
89 | 85 |
90 // Overridden from ChromeWebUI. Determines if the bookmarks bar can be shown | 86 // Overridden from ChromeWebUI. Determines if the bookmarks bar can be shown |
91 // detached from the location bar. | 87 // detached from the location bar. |
92 virtual bool CanShowBookmarkBar() const OVERRIDE; | 88 virtual bool CanShowBookmarkBar() const OVERRIDE; |
93 | 89 |
94 content::NotificationRegistrar registrar_; | 90 content::NotificationRegistrar registrar_; |
95 | 91 |
96 // Tracks updates of the kShowBookmarkBar preference. | |
97 PrefChangeRegistrar pref_change_registrar_; | |
98 // The time when we started benchmarking. | 92 // The time when we started benchmarking. |
99 base::TimeTicks start_; | 93 base::TimeTicks start_; |
100 // The last time we got a paint notification. | 94 // The last time we got a paint notification. |
101 base::TimeTicks last_paint_; | 95 base::TimeTicks last_paint_; |
102 // Scoping so we can be sure our timeouts don't outlive us. | 96 // Scoping so we can be sure our timeouts don't outlive us. |
103 base::OneShotTimer<NewTabUI> timer_; | 97 base::OneShotTimer<NewTabUI> timer_; |
104 // The preference version. This used for migrating prefs of the NTP. | 98 // The preference version. This used for migrating prefs of the NTP. |
105 static const int current_pref_version_ = 3; | 99 static const int current_pref_version_ = 3; |
106 | 100 |
107 DISALLOW_COPY_AND_ASSIGN(NewTabUI); | 101 DISALLOW_COPY_AND_ASSIGN(NewTabUI); |
108 }; | 102 }; |
109 | 103 |
110 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ | 104 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ |
OLD | NEW |