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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_ui.cc

Issue 8760003: [ntp4] Remove bookmarks page implementation and resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: update page_list_view.js Created 9 years 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
OLDNEW
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 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/defaults.h" 18 #include "chrome/browser/defaults.h"
19 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/sessions/session_types.h" 21 #include "chrome/browser/sessions/session_types.h"
22 #include "chrome/browser/sync/profile_sync_service.h" 22 #include "chrome/browser/sync/profile_sync_service.h"
23 #include "chrome/browser/themes/theme_service.h" 23 #include "chrome/browser/themes/theme_service.h"
24 #include "chrome/browser/themes/theme_service_factory.h" 24 #include "chrome/browser/themes/theme_service_factory.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/webui/metrics_handler.h" 26 #include "chrome/browser/ui/webui/metrics_handler.h"
27 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 27 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
28 #include "chrome/browser/ui/webui/ntp/bookmarks_handler.h"
29 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" 28 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h"
30 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" 29 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h"
31 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" 30 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h"
32 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" 31 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
33 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" 32 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h"
34 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" 33 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
35 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 34 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
36 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" 35 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
37 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" 36 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h"
38 #include "chrome/browser/ui/webui/theme_source.h" 37 #include "chrome/browser/ui/webui/theme_source.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 AddMessageHandler((new MetricsHandler())->Attach(this)); 89 AddMessageHandler((new MetricsHandler())->Attach(this));
91 if (GetProfile()->IsSyncAccessible()) 90 if (GetProfile()->IsSyncAccessible())
92 AddMessageHandler((new NewTabPageSyncHandler())->Attach(this)); 91 AddMessageHandler((new NewTabPageSyncHandler())->Attach(this));
93 ExtensionService* service = GetProfile()->GetExtensionService(); 92 ExtensionService* service = GetProfile()->GetExtensionService();
94 // We might not have an ExtensionService (on ChromeOS when not logged in 93 // We might not have an ExtensionService (on ChromeOS when not logged in
95 // for example). 94 // for example).
96 if (service) 95 if (service)
97 AddMessageHandler((new AppLauncherHandler(service))->Attach(this)); 96 AddMessageHandler((new AppLauncherHandler(service))->Attach(this));
98 97
99 AddMessageHandler((new NewTabPageHandler())->Attach(this)); 98 AddMessageHandler((new NewTabPageHandler())->Attach(this));
100 AddMessageHandler((new BookmarksHandler())->Attach(this));
101 AddMessageHandler((new FaviconWebUIHandler())->Attach(this)); 99 AddMessageHandler((new FaviconWebUIHandler())->Attach(this));
102 } 100 }
103 101
104 if (NTPLoginHandler::ShouldShow(GetProfile())) 102 if (NTPLoginHandler::ShouldShow(GetProfile()))
105 AddMessageHandler((new NTPLoginHandler())->Attach(this)); 103 AddMessageHandler((new NTPLoginHandler())->Attach(this));
106 104
107 // Initializing the CSS and HTML can require some CPU, so do it after 105 // Initializing the CSS and HTML can require some CPU, so do it after
108 // we've hooked up the most visited handler. This allows the DB query 106 // we've hooked up the most visited handler. This allows the DB query
109 // for the new tab thumbs to happen earlier. 107 // for the new tab thumbs to happen earlier.
110 InitializeCSSCaches(); 108 InitializeCSSCaches();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 159
162 void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) { 160 void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) {
163 StartTimingPaint(render_view_host); 161 StartTimingPaint(render_view_host);
164 } 162 }
165 163
166 bool NewTabUI::CanShowBookmarkBar() const { 164 bool NewTabUI::CanShowBookmarkBar() const {
167 PrefService* prefs = GetProfile()->GetPrefs(); 165 PrefService* prefs = GetProfile()->GetPrefs();
168 bool disabled_by_policy = 166 bool disabled_by_policy =
169 prefs->IsManagedPreference(prefs::kShowBookmarkBar) && 167 prefs->IsManagedPreference(prefs::kShowBookmarkBar) &&
170 !prefs->GetBoolean(prefs::kShowBookmarkBar); 168 !prefs->GetBoolean(prefs::kShowBookmarkBar);
171 return browser_defaults::bookmarks_enabled && 169 return browser_defaults::bookmarks_enabled && !disabled_by_policy;
172 !disabled_by_policy &&
173 !NTP4BookmarkFeaturesEnabled();
174 } 170 }
175 171
176 void NewTabUI::Observe(int type, 172 void NewTabUI::Observe(int type,
177 const content::NotificationSource& source, 173 const content::NotificationSource& source,
178 const content::NotificationDetails& details) { 174 const content::NotificationDetails& details) {
179 switch (type) { 175 switch (type) {
180 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { 176 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: {
181 InitializeCSSCaches(); 177 InitializeCSSCaches();
182 ListValue args; 178 ListValue args;
183 args.Append(Value::CreateStringValue( 179 args.Append(Value::CreateStringValue(
(...skipping 16 matching lines...) Expand all
200 Profile* profile = GetProfile(); 196 Profile* profile = GetProfile();
201 ThemeSource* theme = new ThemeSource(profile); 197 ThemeSource* theme = new ThemeSource(profile);
202 profile->GetChromeURLDataManager()->AddDataSource(theme); 198 profile->GetChromeURLDataManager()->AddDataSource(theme);
203 } 199 }
204 200
205 // static 201 // static
206 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { 202 void NewTabUI::RegisterUserPrefs(PrefService* prefs) {
207 NewTabPageHandler::RegisterUserPrefs(prefs); 203 NewTabPageHandler::RegisterUserPrefs(prefs);
208 AppLauncherHandler::RegisterUserPrefs(prefs); 204 AppLauncherHandler::RegisterUserPrefs(prefs);
209 MostVisitedHandler::RegisterUserPrefs(prefs); 205 MostVisitedHandler::RegisterUserPrefs(prefs);
210 BookmarksHandler::RegisterUserPrefs(prefs);
211 } 206 }
212 207
213 // static 208 // static
214 void NewTabUI::SetURLTitleAndDirection(DictionaryValue* dictionary, 209 void NewTabUI::SetURLTitleAndDirection(DictionaryValue* dictionary,
215 const string16& title, 210 const string16& title,
216 const GURL& gurl) { 211 const GURL& gurl) {
217 dictionary->SetString("url", gurl.spec()); 212 dictionary->SetString("url", gurl.spec());
218 213
219 bool using_url_as_the_title = false; 214 bool using_url_as_the_title = false;
220 string16 title_to_set(title); 215 string16 title_to_set(title);
(...skipping 18 matching lines...) Expand all
239 base::i18n::IsRTL() && 234 base::i18n::IsRTL() &&
240 base::i18n::StringContainsStrongRTLChars(title)) { 235 base::i18n::StringContainsStrongRTLChars(title)) {
241 direction = kRTLHtmlTextDirection; 236 direction = kRTLHtmlTextDirection;
242 } else { 237 } else {
243 direction = kLTRHtmlTextDirection; 238 direction = kLTRHtmlTextDirection;
244 } 239 }
245 dictionary->SetString("title", title_to_set); 240 dictionary->SetString("title", title_to_set);
246 dictionary->SetString("direction", direction); 241 dictionary->SetString("direction", direction);
247 } 242 }
248 243
249 // static
250 bool NewTabUI::NTP4BookmarkFeaturesEnabled() {
251 CommandLine* cl = CommandLine::ForCurrentProcess();
252 return cl->HasSwitch(switches::kEnableNTPBookmarkFeatures);
253 }
254
255 /////////////////////////////////////////////////////////////////////////////// 244 ///////////////////////////////////////////////////////////////////////////////
256 // NewTabHTMLSource 245 // NewTabHTMLSource
257 246
258 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile) 247 NewTabUI::NewTabHTMLSource::NewTabHTMLSource(Profile* profile)
259 : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()), 248 : DataSource(chrome::kChromeUINewTabHost, MessageLoop::current()),
260 profile_(profile) { 249 profile_(profile) {
261 } 250 }
262 251
263 void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path, 252 void NewTabUI::NewTabHTMLSource::StartDataRequest(const std::string& path,
264 bool is_incognito, 253 bool is_incognito,
(...skipping 14 matching lines...) Expand all
279 SendResponse(request_id, html_bytes); 268 SendResponse(request_id, html_bytes);
280 } 269 }
281 270
282 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { 271 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const {
283 return "text/html"; 272 return "text/html";
284 } 273 }
285 274
286 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { 275 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const {
287 return false; 276 return false;
288 } 277 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.h ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698