Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/dom_ui/new_tab_ui.h

Issue 337011: NTP: Allow hiding tips and bookmark sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_DOM_UI_NEW_TAB_UI_H_ 5 #ifndef CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H_
6 #define CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H_ 6 #define CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/dom_ui/dom_ui.h" 10 #include "chrome/browser/dom_ui/dom_ui.h"
11 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" 11 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
12 #include "chrome/common/notification_registrar.h" 12 #include "chrome/common/notification_registrar.h"
13 #include "testing/gtest/include/gtest/gtest_prod.h"
13 14
14 class GURL; 15 class GURL;
15 class MessageLoop; 16 class MessageLoop;
16 class PrefService; 17 class PrefService;
17 class Profile; 18 class Profile;
18 19
19 // The TabContents used for the New Tab page. 20 // The TabContents used for the New Tab page.
20 class NewTabUI : public DOMUI, 21 class NewTabUI : public DOMUI,
21 public NotificationObserver { 22 public NotificationObserver {
22 public: 23 public:
23 explicit NewTabUI(TabContents* manager); 24 explicit NewTabUI(TabContents* manager);
24 ~NewTabUI(); 25 ~NewTabUI();
25 26
26 // Override DOMUI methods so we can hook up the paint timer to the render 27 // Override DOMUI methods so we can hook up the paint timer to the render
27 // view host. 28 // view host.
28 virtual void RenderViewCreated(RenderViewHost* render_view_host); 29 virtual void RenderViewCreated(RenderViewHost* render_view_host);
29 virtual void RenderViewReused(RenderViewHost* render_view_host); 30 virtual void RenderViewReused(RenderViewHost* render_view_host);
30 31
31 static void RegisterUserPrefs(PrefService* prefs); 32 static void RegisterUserPrefs(PrefService* prefs);
33 static void MigrateUserPrefs(PrefService* prefs, int old_pref_version,
34 int new_pref_version);
32 35
33 // Whether we should disable the web resources backend service 36 // Whether we should disable the web resources backend service
34 static bool WebResourcesEnabled(); 37 static bool WebResourcesEnabled();
35 38
36 // Whether we should disable the first run notification based on the command 39 // Whether we should disable the first run notification based on the command
37 // line switch. 40 // line switch.
38 static bool FirstRunDisabled(); 41 static bool FirstRunDisabled();
39 42
40 // Adds "url", "title", and "direction" keys on incoming dictionary, setting 43 // Adds "url", "title", and "direction" keys on incoming dictionary, setting
41 // title as the url as a fallback on empty title. 44 // title as the url as a fallback on empty title.
42 static void SetURLTitleAndDirection(DictionaryValue* dictionary, 45 static void SetURLTitleAndDirection(DictionaryValue* dictionary,
43 const string16& title, 46 const string16& title,
44 const GURL& gurl); 47 const GURL& gurl);
45 48
49 // The current preference version.
50 static const int current_pref_version() { return current_pref_version_; }
51
46 class NewTabHTMLSource : public ChromeURLDataManager::DataSource { 52 class NewTabHTMLSource : public ChromeURLDataManager::DataSource {
47 public: 53 public:
48 explicit NewTabHTMLSource(Profile* profile); 54 explicit NewTabHTMLSource(Profile* profile);
49 55
50 // Called when the network layer has requested a resource underneath 56 // Called when the network layer has requested a resource underneath
51 // the path we registered. 57 // the path we registered.
52 virtual void StartDataRequest(const std::string& path, int request_id); 58 virtual void StartDataRequest(const std::string& path, int request_id);
53 59
54 virtual std::string GetMimeType(const std::string&) const { 60 virtual std::string GetMimeType(const std::string&) const {
55 return "text/html"; 61 return "text/html";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Whether this is the first run. 101 // Whether this is the first run.
96 static bool first_run_; 102 static bool first_run_;
97 103
98 // The user's profile. 104 // The user's profile.
99 Profile* profile_; 105 Profile* profile_;
100 106
101 DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource); 107 DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource);
102 }; 108 };
103 109
104 private: 110 private:
111 FRIEND_TEST(NewTabUITest, UpdateUserPrefsVersion);
112
105 void Observe(NotificationType type, 113 void Observe(NotificationType type,
106 const NotificationSource& source, 114 const NotificationSource& source,
107 const NotificationDetails& details); 115 const NotificationDetails& details);
108 116
109 // Reset the CSS caches. 117 // Reset the CSS caches.
110 void InitializeCSSCaches(); 118 void InitializeCSSCaches();
111 119
120 // Updates the user prefs version and calls |MigrateUserPrefs| if needed.
121 // Returns true if the version was updated.
122 static bool UpdateUserPrefsVersion(PrefService* prefs);
123
112 NotificationRegistrar registrar_; 124 NotificationRegistrar registrar_;
113 125
114 // The message id that should be displayed in this NewTabUIContents 126 // The message id that should be displayed in this NewTabUIContents
115 // instance's motd area. 127 // instance's motd area.
116 int motd_message_id_; 128 int motd_message_id_;
117 129
118 // Whether the user is in incognito mode or not, used to determine 130 // Whether the user is in incognito mode or not, used to determine
119 // what HTML to load. 131 // what HTML to load.
120 bool incognito_; 132 bool incognito_;
121 133
134 // The preference version. This used for migrating prefs of the NTP.
135 static const int current_pref_version_ = 1;
136
122 DISALLOW_COPY_AND_ASSIGN(NewTabUI); 137 DISALLOW_COPY_AND_ASSIGN(NewTabUI);
123 }; 138 };
124 139
125 #endif // CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H_ 140 #endif // CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H_
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698