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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // Override WebUI methods so we can hook up the paint timer to the render | 31 // Override WebUI methods so we can hook up the paint timer to the render |
32 // view host. | 32 // view host. |
33 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 33 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
34 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; | 34 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; |
35 | 35 |
36 static void RegisterUserPrefs(PrefService* prefs); | 36 static void RegisterUserPrefs(PrefService* prefs); |
37 static void MigrateUserPrefs(PrefService* prefs, int old_pref_version, | 37 static void MigrateUserPrefs(PrefService* prefs, int old_pref_version, |
38 int new_pref_version); | 38 int new_pref_version); |
39 | 39 |
40 // Whether we should disable the first run notification based on the command | |
41 // line switch. | |
42 static bool FirstRunDisabled(); | |
43 | |
44 // Adds "url", "title", and "direction" keys on incoming dictionary, setting | 40 // Adds "url", "title", and "direction" keys on incoming dictionary, setting |
45 // title as the url as a fallback on empty title. | 41 // title as the url as a fallback on empty title. |
46 static void SetURLTitleAndDirection(base::DictionaryValue* dictionary, | 42 static void SetURLTitleAndDirection(base::DictionaryValue* dictionary, |
47 const string16& title, | 43 const string16& title, |
48 const GURL& gurl); | 44 const GURL& gurl); |
49 | 45 |
50 // The current preference version. | 46 // The current preference version. |
51 static int current_pref_version() { return current_pref_version_; } | 47 static int current_pref_version() { return current_pref_version_; } |
52 | 48 |
53 class NewTabHTMLSource : public ChromeURLDataManager::DataSource { | 49 class NewTabHTMLSource : public ChromeURLDataManager::DataSource { |
54 public: | 50 public: |
55 explicit NewTabHTMLSource(Profile* profile); | 51 explicit NewTabHTMLSource(Profile* profile); |
56 | 52 |
57 // Called when the network layer has requested a resource underneath | 53 // Called when the network layer has requested a resource underneath |
58 // the path we registered. | 54 // the path we registered. |
59 virtual void StartDataRequest(const std::string& path, | 55 virtual void StartDataRequest(const std::string& path, |
60 bool is_incognito, | 56 bool is_incognito, |
61 int request_id) OVERRIDE; | 57 int request_id) OVERRIDE; |
62 | 58 |
63 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | 59 virtual std::string GetMimeType(const std::string&) const OVERRIDE; |
64 | 60 |
65 virtual bool ShouldReplaceExistingSource() const; | 61 virtual bool ShouldReplaceExistingSource() const; |
66 | 62 |
67 // Setters and getters for first_run. | |
68 static void set_first_run(bool first_run) { first_run_ = first_run; } | |
69 static bool first_run() { return first_run_; } | |
70 | |
71 private: | 63 private: |
72 virtual ~NewTabHTMLSource() {} | 64 virtual ~NewTabHTMLSource() {} |
73 | 65 |
74 // Whether this is the first run. | |
75 static bool first_run_; | |
76 | |
77 // Pointer back to the original profile. | 66 // Pointer back to the original profile. |
78 Profile* profile_; | 67 Profile* profile_; |
79 | 68 |
80 DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource); | 69 DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource); |
81 }; | 70 }; |
82 | 71 |
83 private: | 72 private: |
84 FRIEND_TEST_ALL_PREFIXES(NewTabUITest, UpdateUserPrefsVersion); | 73 FRIEND_TEST_ALL_PREFIXES(NewTabUITest, UpdateUserPrefsVersion); |
85 | 74 |
86 virtual void Observe(int type, | 75 virtual void Observe(int type, |
(...skipping 18 matching lines...) Expand all Loading... |
105 base::TimeTicks last_paint_; | 94 base::TimeTicks last_paint_; |
106 // Scoping so we can be sure our timeouts don't outlive us. | 95 // Scoping so we can be sure our timeouts don't outlive us. |
107 base::OneShotTimer<NewTabUI> timer_; | 96 base::OneShotTimer<NewTabUI> timer_; |
108 // The preference version. This used for migrating prefs of the NTP. | 97 // The preference version. This used for migrating prefs of the NTP. |
109 static const int current_pref_version_ = 3; | 98 static const int current_pref_version_ = 3; |
110 | 99 |
111 DISALLOW_COPY_AND_ASSIGN(NewTabUI); | 100 DISALLOW_COPY_AND_ASSIGN(NewTabUI); |
112 }; | 101 }; |
113 | 102 |
114 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ | 103 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ |
OLD | NEW |