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

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

Issue 11953021: Don't show the apps page on the NTP if the app launcher is installed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make shouldShowApps a pref Created 7 years, 11 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 "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 5 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 bool NTPResourceCache::NewTabCacheNeedsRefresh() { 186 bool NTPResourceCache::NewTabCacheNeedsRefresh() {
187 #if defined(OS_MACOSX) 187 #if defined(OS_MACOSX)
188 // Invalidate if the current value is different from the cached value. 188 // Invalidate if the current value is different from the cached value.
189 bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled(); 189 bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled();
190 if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) { 190 if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) {
191 is_swipe_tracking_from_scroll_events_enabled_ = is_enabled; 191 is_swipe_tracking_from_scroll_events_enabled_ = is_enabled;
192 return true; 192 return true;
193 } 193 }
194 #endif 194 #endif
195 bool should_show_apps_page = profile_->GetPrefs()->GetBoolean(
196 prefs::kNtpShouldShowAppsPage);
197 if (should_show_apps_page != should_show_apps_page_) {
198 should_show_apps_page_ = should_show_apps_page;
199 return true;
200 }
195 return false; 201 return false;
196 } 202 }
197 203
198 base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(bool is_incognito) { 204 base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(bool is_incognito) {
199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
200 if (is_incognito) { 206 if (is_incognito) {
201 if (!new_tab_incognito_html_.get()) 207 if (!new_tab_incognito_html_.get())
202 CreateNewTabIncognitoHTML(); 208 CreateNewTabIncognitoHTML();
203 } else { 209 } else {
204 // Refresh the cached HTML if necessary. 210 // Refresh the cached HTML if necessary.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 311
306 void NTPResourceCache::CreateNewTabHTML() { 312 void NTPResourceCache::CreateNewTabHTML() {
307 // TODO(estade): these strings should be defined in their relevant handlers 313 // TODO(estade): these strings should be defined in their relevant handlers
308 // (in GetLocalizedValues) and should have more legible names. 314 // (in GetLocalizedValues) and should have more legible names.
309 // Show the profile name in the title and most visited labels if the current 315 // Show the profile name in the title and most visited labels if the current
310 // profile is not the default. 316 // profile is not the default.
311 PrefService* prefs = profile_->GetPrefs(); 317 PrefService* prefs = profile_->GetPrefs();
312 DictionaryValue load_time_data; 318 DictionaryValue load_time_data;
313 load_time_data.SetBoolean("bookmarkbarattached", 319 load_time_data.SetBoolean("bookmarkbarattached",
314 prefs->GetBoolean(prefs::kShowBookmarkBar)); 320 prefs->GetBoolean(prefs::kShowBookmarkBar));
321 load_time_data.SetBoolean("showApps",
322 prefs->GetBoolean(prefs::kNtpShouldShowAppsPage));
315 load_time_data.SetBoolean("hasattribution", 323 load_time_data.SetBoolean("hasattribution",
316 ThemeServiceFactory::GetForProfile(profile_)->HasCustomImage( 324 ThemeServiceFactory::GetForProfile(profile_)->HasCustomImage(
317 IDR_THEME_NTP_ATTRIBUTION)); 325 IDR_THEME_NTP_ATTRIBUTION));
318 load_time_data.SetString("title", 326 load_time_data.SetString("title",
319 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); 327 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
320 load_time_data.SetString("mostvisited", 328 load_time_data.SetString("mostvisited",
321 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED)); 329 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED));
322 load_time_data.SetString("suggestions", 330 load_time_data.SetString("suggestions",
323 l10n_util::GetStringUTF16(IDS_NEW_TAB_SUGGESTIONS)); 331 l10n_util::GetStringUTF16(IDS_NEW_TAB_SUGGESTIONS));
324 load_time_data.SetString("restoreThumbnailsShort", 332 load_time_data.SetString("restoreThumbnailsShort",
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 load_time_data.SetString("otherSessionsLearnMoreUrl", 380 load_time_data.SetString("otherSessionsLearnMoreUrl",
373 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LEARN_MORE_URL)); 381 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_LEARN_MORE_URL));
374 load_time_data.SetString("learnMore", 382 load_time_data.SetString("learnMore",
375 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); 383 l10n_util::GetStringUTF16(IDS_LEARN_MORE));
376 load_time_data.SetString("webStoreLink", 384 load_time_data.SetString("webStoreLink",
377 GetUrlWithLang(GURL(extension_urls::GetWebstoreLaunchURL()))); 385 GetUrlWithLang(GURL(extension_urls::GetWebstoreLaunchURL())));
378 load_time_data.SetString("appInstallHintText", 386 load_time_data.SetString("appInstallHintText",
379 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL)); 387 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL));
380 load_time_data.SetBoolean("isDiscoveryInNTPEnabled", 388 load_time_data.SetBoolean("isDiscoveryInNTPEnabled",
381 NewTabUI::IsDiscoveryInNTPEnabled()); 389 NewTabUI::IsDiscoveryInNTPEnabled());
382 load_time_data.SetBoolean("showApps", NewTabUI::ShouldShowApps());
383 load_time_data.SetString("collapseSessionMenuItemText", 390 load_time_data.SetString("collapseSessionMenuItemText",
384 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION)); 391 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION));
385 load_time_data.SetString("expandSessionMenuItemText", 392 load_time_data.SetString("expandSessionMenuItemText",
386 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION)); 393 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION));
387 load_time_data.SetString("restoreSessionMenuItemText", 394 load_time_data.SetString("restoreSessionMenuItemText",
388 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL)); 395 l10n_util::GetStringUTF16(IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL));
389 load_time_data.SetString("learn_more", 396 load_time_data.SetString("learn_more",
390 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); 397 l10n_util::GetStringUTF16(IDS_LEARN_MORE));
391 load_time_data.SetString("tile_grid_screenreader_accessible_description", 398 load_time_data.SetString("tile_grid_screenreader_accessible_description",
392 l10n_util::GetStringUTF16(IDS_NEW_TAB_TILE_GRID_ACCESSIBLE_DESCRIPTION)); 399 l10n_util::GetStringUTF16(IDS_NEW_TAB_TILE_GRID_ACCESSIBLE_DESCRIPTION));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 static const base::StringPiece new_tab_theme_css( 586 static const base::StringPiece new_tab_theme_css(
580 ResourceBundle::GetSharedInstance().GetRawDataResource( 587 ResourceBundle::GetSharedInstance().GetRawDataResource(
581 chrome::search::IsInstantExtendedAPIEnabled(profile_) ? 588 chrome::search::IsInstantExtendedAPIEnabled(profile_) ?
582 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS)); 589 IDR_NEW_TAB_SEARCH_THEME_CSS : IDR_NEW_TAB_4_THEME_CSS));
583 590
584 // Create the string from our template and the replacements. 591 // Create the string from our template and the replacements.
585 std::string css_string; 592 std::string css_string;
586 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); 593 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL);
587 new_tab_css_ = base::RefCountedString::TakeString(&css_string); 594 new_tab_css_ = base::RefCountedString::TakeString(&css_string);
588 } 595 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698