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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 content::Source<ThemeService>( | 165 content::Source<ThemeService>( |
166 ThemeServiceFactory::GetForProfile(profile))); | 166 ThemeServiceFactory::GetForProfile(profile))); |
167 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, | 167 registrar_.Add(this, chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, |
168 content::NotificationService::AllSources()); | 168 content::NotificationService::AllSources()); |
169 | 169 |
170 base::Closure callback = base::Bind(&NTPResourceCache::OnPreferenceChanged, | 170 base::Closure callback = base::Bind(&NTPResourceCache::OnPreferenceChanged, |
171 base::Unretained(this)); | 171 base::Unretained(this)); |
172 | 172 |
173 // Watch for pref changes that cause us to need to invalidate the HTML cache. | 173 // Watch for pref changes that cause us to need to invalidate the HTML cache. |
174 profile_pref_change_registrar_.Init(profile_->GetPrefs()); | 174 profile_pref_change_registrar_.Init(profile_->GetPrefs()); |
175 profile_pref_change_registrar_.Add(prefs::kShowBookmarkBar, callback); | 175 profile_pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar, |
| 176 callback); |
176 profile_pref_change_registrar_.Add(prefs::kNtpShownPage, callback); | 177 profile_pref_change_registrar_.Add(prefs::kNtpShownPage, callback); |
177 profile_pref_change_registrar_.Add(prefs::kSignInPromoShowNTPBubble, | 178 profile_pref_change_registrar_.Add(prefs::kSignInPromoShowNTPBubble, |
178 callback); | 179 callback); |
179 profile_pref_change_registrar_.Add(prefs::kHideWebStoreIcon, callback); | 180 profile_pref_change_registrar_.Add(prefs::kHideWebStoreIcon, callback); |
180 | 181 |
181 // Some tests don't have a local state. | 182 // Some tests don't have a local state. |
182 #if defined(ENABLE_APP_LIST) | 183 #if defined(ENABLE_APP_LIST) |
183 if (g_browser_process->local_state()) { | 184 if (g_browser_process->local_state()) { |
184 local_state_pref_change_registrar_.Init(g_browser_process->local_state()); | 185 local_state_pref_change_registrar_.Init(g_browser_process->local_state()); |
185 local_state_pref_change_registrar_.Add(prefs::kShowAppLauncherPromo, | 186 local_state_pref_change_registrar_.Add(prefs::kShowAppLauncherPromo, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 localized_strings.SetString("incognitoTabHeading", | 307 localized_strings.SetString("incognitoTabHeading", |
307 l10n_util::GetStringUTF16(new_tab_heading_ids)); | 308 l10n_util::GetStringUTF16(new_tab_heading_ids)); |
308 localized_strings.SetString("incognitoTabWarning", | 309 localized_strings.SetString("incognitoTabWarning", |
309 l10n_util::GetStringUTF16(new_tab_warning_ids)); | 310 l10n_util::GetStringUTF16(new_tab_warning_ids)); |
310 } | 311 } |
311 | 312 |
312 localized_strings.SetString("learnMore", | 313 localized_strings.SetString("learnMore", |
313 l10n_util::GetStringUTF16(new_tab_link_ids)); | 314 l10n_util::GetStringUTF16(new_tab_link_ids)); |
314 localized_strings.SetString("learnMoreLink", new_tab_link); | 315 localized_strings.SetString("learnMoreLink", new_tab_link); |
315 | 316 |
316 bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( | 317 bool bookmark_bar_attached = |
317 prefs::kShowBookmarkBar); | 318 profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar); |
318 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); | 319 localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached); |
319 | 320 |
320 webui::SetFontAndTextDirection(&localized_strings); | 321 webui::SetFontAndTextDirection(&localized_strings); |
321 | 322 |
322 static const base::StringPiece incognito_tab_html( | 323 static const base::StringPiece incognito_tab_html( |
323 ResourceBundle::GetSharedInstance().GetRawDataResource( | 324 ResourceBundle::GetSharedInstance().GetRawDataResource( |
324 new_tab_html_idr)); | 325 new_tab_html_idr)); |
325 | 326 |
326 std::string full_html = webui::GetI18nTemplateHtml( | 327 std::string full_html = webui::GetI18nTemplateHtml( |
327 incognito_tab_html, &localized_strings); | 328 incognito_tab_html, &localized_strings); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } | 384 } |
384 | 385 |
385 void NTPResourceCache::CreateNewTabHTML() { | 386 void NTPResourceCache::CreateNewTabHTML() { |
386 // TODO(estade): these strings should be defined in their relevant handlers | 387 // TODO(estade): these strings should be defined in their relevant handlers |
387 // (in GetLocalizedValues) and should have more legible names. | 388 // (in GetLocalizedValues) and should have more legible names. |
388 // Show the profile name in the title and most visited labels if the current | 389 // Show the profile name in the title and most visited labels if the current |
389 // profile is not the default. | 390 // profile is not the default. |
390 PrefService* prefs = profile_->GetPrefs(); | 391 PrefService* prefs = profile_->GetPrefs(); |
391 base::DictionaryValue load_time_data; | 392 base::DictionaryValue load_time_data; |
392 load_time_data.SetBoolean("bookmarkbarattached", | 393 load_time_data.SetBoolean("bookmarkbarattached", |
393 prefs->GetBoolean(prefs::kShowBookmarkBar)); | 394 prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); |
394 load_time_data.SetBoolean("hasattribution", | 395 load_time_data.SetBoolean("hasattribution", |
395 ThemeServiceFactory::GetForProfile(profile_)->HasCustomImage( | 396 ThemeServiceFactory::GetForProfile(profile_)->HasCustomImage( |
396 IDR_THEME_NTP_ATTRIBUTION)); | 397 IDR_THEME_NTP_ATTRIBUTION)); |
397 load_time_data.SetBoolean("showMostvisited", should_show_most_visited_page_); | 398 load_time_data.SetBoolean("showMostvisited", should_show_most_visited_page_); |
398 load_time_data.SetBoolean("showAppLauncherPromo", | 399 load_time_data.SetBoolean("showAppLauncherPromo", |
399 ShouldShowAppLauncherPromo()); | 400 ShouldShowAppLauncherPromo()); |
400 load_time_data.SetBoolean("showRecentlyClosed", | 401 load_time_data.SetBoolean("showRecentlyClosed", |
401 should_show_recently_closed_menu_); | 402 should_show_recently_closed_menu_); |
402 load_time_data.SetString("title", | 403 load_time_data.SetString("title", |
403 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 404 l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 // Get our template. | 714 // Get our template. |
714 static const base::StringPiece new_tab_theme_css( | 715 static const base::StringPiece new_tab_theme_css( |
715 ResourceBundle::GetSharedInstance().GetRawDataResource( | 716 ResourceBundle::GetSharedInstance().GetRawDataResource( |
716 IDR_NEW_TAB_4_THEME_CSS)); | 717 IDR_NEW_TAB_4_THEME_CSS)); |
717 | 718 |
718 // Create the string from our template and the replacements. | 719 // Create the string from our template and the replacements. |
719 std::string css_string; | 720 std::string css_string; |
720 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 721 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
721 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 722 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
722 } | 723 } |
OLD | NEW |