OLD | NEW |
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 int repeat_mode = theme_provider->GetDisplayProperty( | 158 int repeat_mode = theme_provider->GetDisplayProperty( |
159 ThemeProperties::NTP_BACKGROUND_TILING); | 159 ThemeProperties::NTP_BACKGROUND_TILING); |
160 return ThemeProperties::TilingToString(repeat_mode); | 160 return ThemeProperties::TilingToString(repeat_mode); |
161 } | 161 } |
162 | 162 |
163 } // namespace | 163 } // namespace |
164 | 164 |
165 NTPResourceCache::NTPResourceCache(Profile* profile) | 165 NTPResourceCache::NTPResourceCache(Profile* profile) |
166 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false), | 166 : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false), |
167 should_show_apps_page_(NewTabUI::ShouldShowApps()), | 167 should_show_apps_page_(NewTabUI::ShouldShowApps()), |
| 168 should_show_most_visited_page_(true), |
168 should_show_other_devices_menu_(true) { | 169 should_show_other_devices_menu_(true) { |
169 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 170 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
170 content::Source<ThemeService>( | 171 content::Source<ThemeService>( |
171 ThemeServiceFactory::GetForProfile(profile))); | 172 ThemeServiceFactory::GetForProfile(profile))); |
172 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, | 173 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, |
173 content::NotificationService::AllSources()); | 174 content::NotificationService::AllSources()); |
174 | 175 |
175 PromoResourceService* promo_service = | 176 PromoResourceService* promo_service = |
176 g_browser_process->promo_resource_service(); | 177 g_browser_process->promo_resource_service(); |
177 if (promo_service) { | 178 if (promo_service) { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 // (in GetLocalizedValues) and should have more legible names. | 407 // (in GetLocalizedValues) and should have more legible names. |
407 // Show the profile name in the title and most visited labels if the current | 408 // Show the profile name in the title and most visited labels if the current |
408 // profile is not the default. | 409 // profile is not the default. |
409 PrefService* prefs = profile_->GetPrefs(); | 410 PrefService* prefs = profile_->GetPrefs(); |
410 base::DictionaryValue load_time_data; | 411 base::DictionaryValue load_time_data; |
411 load_time_data.SetBoolean("bookmarkbarattached", | 412 load_time_data.SetBoolean("bookmarkbarattached", |
412 prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); | 413 prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
413 load_time_data.SetBoolean("hasattribution", | 414 load_time_data.SetBoolean("hasattribution", |
414 ThemeServiceFactory::GetForProfile(profile_)->HasCustomImage( | 415 ThemeServiceFactory::GetForProfile(profile_)->HasCustomImage( |
415 IDR_THEME_NTP_ATTRIBUTION)); | 416 IDR_THEME_NTP_ATTRIBUTION)); |
| 417 load_time_data.SetBoolean("showMostvisited", should_show_most_visited_page_); |
416 load_time_data.SetBoolean("showAppLauncherPromo", | 418 load_time_data.SetBoolean("showAppLauncherPromo", |
417 ShouldShowAppLauncherPromo()); | 419 ShouldShowAppLauncherPromo()); |
418 load_time_data.SetString("title", | 420 load_time_data.SetString("title", |
419 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 421 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
| 422 load_time_data.SetString("mostvisited", |
| 423 l10n_util::GetStringUTF16(IDS_NEW_TAB_MOST_VISITED)); |
| 424 load_time_data.SetString("restoreThumbnailsShort", |
| 425 l10n_util::GetStringUTF16(IDS_NEW_TAB_RESTORE_THUMBNAILS_SHORT_LINK)); |
420 load_time_data.SetString("webStoreTitle", | 426 load_time_data.SetString("webStoreTitle", |
421 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE)); | 427 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE)); |
422 load_time_data.SetString("webStoreTitleShort", | 428 load_time_data.SetString("webStoreTitleShort", |
423 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE_SHORT)); | 429 l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE_SHORT)); |
424 load_time_data.SetString("attributionintro", | 430 load_time_data.SetString("attributionintro", |
425 l10n_util::GetStringUTF16(IDS_NEW_TAB_ATTRIBUTION_INTRO)); | 431 l10n_util::GetStringUTF16(IDS_NEW_TAB_ATTRIBUTION_INTRO)); |
| 432 load_time_data.SetString("thumbnailremovednotification", |
| 433 l10n_util::GetStringUTF16(IDS_NEW_TAB_THUMBNAIL_REMOVED_NOTIFICATION)); |
| 434 load_time_data.SetString("undothumbnailremove", |
| 435 l10n_util::GetStringUTF16(IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE)); |
| 436 load_time_data.SetString("removethumbnailtooltip", |
| 437 l10n_util::GetStringUTF16(IDS_NEW_TAB_REMOVE_THUMBNAIL_TOOLTIP)); |
426 load_time_data.SetString("appuninstall", | 438 load_time_data.SetString("appuninstall", |
427 l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); | 439 l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); |
428 load_time_data.SetString("appoptions", | 440 load_time_data.SetString("appoptions", |
429 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_OPTIONS)); | 441 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_OPTIONS)); |
430 load_time_data.SetString("appdetails", | 442 load_time_data.SetString("appdetails", |
431 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_DETAILS)); | 443 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_DETAILS)); |
432 load_time_data.SetString("appinfodialog", | 444 load_time_data.SetString("appinfodialog", |
433 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_SHOW_INFO)); | 445 l10n_util::GetStringUTF16(IDS_APP_CONTEXT_MENU_SHOW_INFO)); |
434 load_time_data.SetString("appcreateshortcut", | 446 load_time_data.SetString("appcreateshortcut", |
435 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_CREATE_SHORTCUT)); | 447 l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_CREATE_SHORTCUT)); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 // Get our template. | 701 // Get our template. |
690 static const base::StringPiece new_tab_theme_css( | 702 static const base::StringPiece new_tab_theme_css( |
691 ResourceBundle::GetSharedInstance().GetRawDataResource( | 703 ResourceBundle::GetSharedInstance().GetRawDataResource( |
692 IDR_NEW_TAB_4_THEME_CSS)); | 704 IDR_NEW_TAB_4_THEME_CSS)); |
693 | 705 |
694 // Create the string from our template and the replacements. | 706 // Create the string from our template and the replacements. |
695 std::string css_string; | 707 std::string css_string; |
696 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 708 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
697 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 709 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
698 } | 710 } |
OLD | NEW |