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

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

Issue 10827075: Use isDiscoveryInNTPEnabled flag instead of isSuggestionsPageEnabled flag to control suggestions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 9 #include <set>
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // highly. Note this means we're including clicks on not only most visited 100 // highly. Note this means we're including clicks on not only most visited
101 // thumbnails, but also clicks on recently bookmarked. 101 // thumbnails, but also clicks on recently bookmarked.
102 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK); 102 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK);
103 103
104 if (!GetProfile()->IsOffTheRecord()) { 104 if (!GetProfile()->IsOffTheRecord()) {
105 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); 105 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
106 web_ui->AddMessageHandler(new MostVisitedHandler()); 106 web_ui->AddMessageHandler(new MostVisitedHandler());
107 web_ui->AddMessageHandler(new RecentlyClosedTabsHandler()); 107 web_ui->AddMessageHandler(new RecentlyClosedTabsHandler());
108 web_ui->AddMessageHandler(new MetricsHandler()); 108 web_ui->AddMessageHandler(new MetricsHandler());
109 #if !defined(OS_ANDROID) 109 #if !defined(OS_ANDROID)
110 if (NewTabUI::IsSuggestionsPageEnabled()) 110 if (NewTabUI::IsDiscoveryInNTPEnabled())
111 web_ui->AddMessageHandler(new SuggestionsHandler()); 111 web_ui->AddMessageHandler(new SuggestionsHandler());
112 // Android doesn't have a sync promo/username on NTP. 112 // Android doesn't have a sync promo/username on NTP.
113 if (GetProfile()->IsSyncAccessible()) 113 if (GetProfile()->IsSyncAccessible())
114 web_ui->AddMessageHandler(new NewTabPageSyncHandler()); 114 web_ui->AddMessageHandler(new NewTabPageSyncHandler());
115 115
116 // Or apps. 116 // Or apps.
117 if (ShouldShowApps()) { 117 if (ShouldShowApps()) {
118 ExtensionService* service = GetProfile()->GetExtensionService(); 118 ExtensionService* service = GetProfile()->GetExtensionService();
119 // We might not have an ExtensionService (on ChromeOS when not logged in 119 // We might not have an ExtensionService (on ChromeOS when not logged in
120 // for example). 120 // for example).
(...skipping 13 matching lines...) Expand all
134 #endif 134 #endif
135 135
136 // Initializing the CSS and HTML can require some CPU, so do it after 136 // Initializing the CSS and HTML can require some CPU, so do it after
137 // we've hooked up the most visited handler. This allows the DB query 137 // we've hooked up the most visited handler. This allows the DB query
138 // for the new tab thumbs to happen earlier. 138 // for the new tab thumbs to happen earlier.
139 InitializeCSSCaches(); 139 InitializeCSSCaches();
140 NewTabHTMLSource* html_source = 140 NewTabHTMLSource* html_source =
141 new NewTabHTMLSource(GetProfile()->GetOriginalProfile()); 141 new NewTabHTMLSource(GetProfile()->GetOriginalProfile());
142 // These two resources should be loaded only if suggestions NTP is enabled. 142 // These two resources should be loaded only if suggestions NTP is enabled.
143 html_source->AddResource("suggestions_page.css", "text/css", 143 html_source->AddResource("suggestions_page.css", "text/css",
144 NewTabUI::IsSuggestionsPageEnabled() ? IDR_SUGGESTIONS_PAGE_CSS : 0); 144 NewTabUI::IsDiscoveryInNTPEnabled() ? IDR_SUGGESTIONS_PAGE_CSS : 0);
145 if (NewTabUI::IsSuggestionsPageEnabled()) { 145 if (NewTabUI::IsDiscoveryInNTPEnabled()) {
146 html_source->AddResource("suggestions_page.js", "application/javascript", 146 html_source->AddResource("suggestions_page.js", "application/javascript",
147 IDR_SUGGESTIONS_PAGE_JS); 147 IDR_SUGGESTIONS_PAGE_JS);
148 } 148 }
149 // ChromeURLDataManager assumes the ownership of the html_source and in some 149 // ChromeURLDataManager assumes the ownership of the html_source and in some
150 // tests immediately deletes it, so html_source should not be accessed after 150 // tests immediately deletes it, so html_source should not be accessed after
151 // this call. 151 // this call.
152 Profile* profile = GetProfile(); 152 Profile* profile = GetProfile();
153 ChromeURLDataManager::AddDataSource(profile, html_source); 153 ChromeURLDataManager::AddDataSource(profile, html_source);
154 154
155 pref_change_registrar_.Init(GetProfile()->GetPrefs()); 155 pref_change_registrar_.Init(GetProfile()->GetPrefs());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ThemeSource* theme = new ThemeSource(profile); 262 ThemeSource* theme = new ThemeSource(profile);
263 ChromeURLDataManager::AddDataSource(profile, theme); 263 ChromeURLDataManager::AddDataSource(profile, theme);
264 #endif 264 #endif
265 } 265 }
266 266
267 // static 267 // static
268 void NewTabUI::RegisterUserPrefs(PrefService* prefs) { 268 void NewTabUI::RegisterUserPrefs(PrefService* prefs) {
269 NewTabPageHandler::RegisterUserPrefs(prefs); 269 NewTabPageHandler::RegisterUserPrefs(prefs);
270 #if !defined(OS_ANDROID) 270 #if !defined(OS_ANDROID)
271 AppLauncherHandler::RegisterUserPrefs(prefs); 271 AppLauncherHandler::RegisterUserPrefs(prefs);
272 if (NewTabUI::IsSuggestionsPageEnabled()) 272 if (NewTabUI::IsDiscoveryInNTPEnabled())
273 SuggestionsHandler::RegisterUserPrefs(prefs); 273 SuggestionsHandler::RegisterUserPrefs(prefs);
274 #endif 274 #endif
275 MostVisitedHandler::RegisterUserPrefs(prefs); 275 MostVisitedHandler::RegisterUserPrefs(prefs);
276 browser_sync::ForeignSessionHandler::RegisterUserPrefs(prefs); 276 browser_sync::ForeignSessionHandler::RegisterUserPrefs(prefs);
277 } 277 }
278 278
279 // static 279 // static
280 bool NewTabUI::ShouldShowApps() { 280 bool NewTabUI::ShouldShowApps() {
281 #if defined(USE_ASH) || defined(OS_ANDROID) 281 #if defined(USE_ASH) || defined(OS_ANDROID)
282 // Ash shows apps in app list thus should not show apps page in NTP4. 282 // Ash shows apps in app list thus should not show apps page in NTP4.
283 // Android does not have apps. 283 // Android does not have apps.
284 return false; 284 return false;
285 #else 285 #else
286 return true; 286 return true;
287 #endif 287 #endif
288 } 288 }
289 289
290 // static 290 // static
291 bool NewTabUI::IsSuggestionsPageEnabled() { 291 bool NewTabUI::IsDiscoveryInNTPEnabled() {
292 return CommandLine::ForCurrentProcess()->HasSwitch( 292 return CommandLine::ForCurrentProcess()->HasSwitch(
293 switches::kEnableSuggestionsTabPage); 293 switches::kEnableDiscoveryInNewTabPage);
294 } 294 }
295 295
296 // static 296 // static
297 void NewTabUI::SetURLTitleAndDirection(DictionaryValue* dictionary, 297 void NewTabUI::SetURLTitleAndDirection(DictionaryValue* dictionary,
298 const string16& title, 298 const string16& title,
299 const GURL& gurl) { 299 const GURL& gurl) {
300 dictionary->SetString("url", gurl.spec()); 300 dictionary->SetString("url", gurl.spec());
301 301
302 bool using_url_as_the_title = false; 302 bool using_url_as_the_title = false;
303 string16 title_to_set(title); 303 string16 title_to_set(title);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 394
395 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, 395 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource,
396 const char* mime_type, 396 const char* mime_type,
397 int resource_id) { 397 int resource_id) {
398 DCHECK(resource); 398 DCHECK(resource);
399 DCHECK(mime_type); 399 DCHECK(mime_type);
400 resource_map_[std::string(resource)] = 400 resource_map_[std::string(resource)] =
401 std::make_pair(std::string(mime_type), resource_id); 401 std::make_pair(std::string(mime_type), resource_id);
402 } 402 }
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