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 "apps/app_launcher.h" | 10 #include "apps/app_launcher.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 base::Closure callback = base::Bind(&NTPResourceCache::OnPreferenceChanged, | 176 base::Closure callback = base::Bind(&NTPResourceCache::OnPreferenceChanged, |
177 base::Unretained(this)); | 177 base::Unretained(this)); |
178 | 178 |
179 // Watch for pref changes that cause us to need to invalidate the HTML cache. | 179 // Watch for pref changes that cause us to need to invalidate the HTML cache. |
180 pref_change_registrar_.Init(profile_->GetPrefs()); | 180 pref_change_registrar_.Init(profile_->GetPrefs()); |
181 pref_change_registrar_.Add(prefs::kSyncAcknowledgedSyncTypes, callback); | 181 pref_change_registrar_.Add(prefs::kSyncAcknowledgedSyncTypes, callback); |
182 pref_change_registrar_.Add(prefs::kShowBookmarkBar, callback); | 182 pref_change_registrar_.Add(prefs::kShowBookmarkBar, callback); |
183 pref_change_registrar_.Add(prefs::kNtpShownPage, callback); | 183 pref_change_registrar_.Add(prefs::kNtpShownPage, callback); |
184 pref_change_registrar_.Add(prefs::kSyncPromoShowNTPBubble, callback); | 184 pref_change_registrar_.Add(prefs::kSyncPromoShowNTPBubble, callback); |
| 185 pref_change_registrar_.Add(prefs::kHideWebStoreIcon, callback); |
185 } | 186 } |
186 | 187 |
187 NTPResourceCache::~NTPResourceCache() {} | 188 NTPResourceCache::~NTPResourceCache() {} |
188 | 189 |
189 bool NTPResourceCache::NewTabCacheNeedsRefresh() { | 190 bool NTPResourceCache::NewTabCacheNeedsRefresh() { |
190 #if defined(OS_MACOSX) | 191 #if defined(OS_MACOSX) |
191 // Invalidate if the current value is different from the cached value. | 192 // Invalidate if the current value is different from the cached value. |
192 bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled(); | 193 bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled(); |
193 if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) { | 194 if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) { |
194 is_swipe_tracking_from_scroll_events_enabled_ = is_enabled; | 195 is_swipe_tracking_from_scroll_events_enabled_ = is_enabled; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 load_time_data.SetString("page_switcher_change_title", | 401 load_time_data.SetString("page_switcher_change_title", |
401 l10n_util::GetStringUTF16(IDS_NEW_TAB_PAGE_SWITCHER_CHANGE_TITLE)); | 402 l10n_util::GetStringUTF16(IDS_NEW_TAB_PAGE_SWITCHER_CHANGE_TITLE)); |
402 load_time_data.SetString("page_switcher_same_title", | 403 load_time_data.SetString("page_switcher_same_title", |
403 l10n_util::GetStringUTF16(IDS_NEW_TAB_PAGE_SWITCHER_SAME_TITLE)); | 404 l10n_util::GetStringUTF16(IDS_NEW_TAB_PAGE_SWITCHER_SAME_TITLE)); |
404 // On Mac OS X 10.7+, horizontal scrolling can be treated as a back or | 405 // On Mac OS X 10.7+, horizontal scrolling can be treated as a back or |
405 // forward gesture. Pass through a flag that indicates whether or not that | 406 // forward gesture. Pass through a flag that indicates whether or not that |
406 // feature is enabled. | 407 // feature is enabled. |
407 load_time_data.SetBoolean("isSwipeTrackingFromScrollEventsEnabled", | 408 load_time_data.SetBoolean("isSwipeTrackingFromScrollEventsEnabled", |
408 is_swipe_tracking_from_scroll_events_enabled_); | 409 is_swipe_tracking_from_scroll_events_enabled_); |
409 load_time_data.SetBoolean("showApps", should_show_apps_page_); | 410 load_time_data.SetBoolean("showApps", should_show_apps_page_); |
| 411 load_time_data.SetBoolean("showWebStoreIcon", |
| 412 !prefs->GetBoolean(prefs::kHideWebStoreIcon)); |
410 | 413 |
411 #if defined(OS_CHROMEOS) | 414 #if defined(OS_CHROMEOS) |
412 load_time_data.SetString("expandMenu", | 415 load_time_data.SetString("expandMenu", |
413 l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); | 416 l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); |
414 #endif | 417 #endif |
415 | 418 |
416 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); | 419 NewTabPageHandler::GetLocalizedValues(profile_, &load_time_data); |
417 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); | 420 NTPLoginHandler::GetLocalizedValues(profile_, &load_time_data); |
418 | 421 |
419 webui::SetFontAndTextDirection(&load_time_data); | 422 webui::SetFontAndTextDirection(&load_time_data); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 // Get our template. | 589 // Get our template. |
587 static const base::StringPiece new_tab_theme_css( | 590 static const base::StringPiece new_tab_theme_css( |
588 ResourceBundle::GetSharedInstance().GetRawDataResource( | 591 ResourceBundle::GetSharedInstance().GetRawDataResource( |
589 IDR_NEW_TAB_4_THEME_CSS)); | 592 IDR_NEW_TAB_4_THEME_CSS)); |
590 | 593 |
591 // Create the string from our template and the replacements. | 594 // Create the string from our template and the replacements. |
592 std::string css_string; | 595 std::string css_string; |
593 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); | 596 css_string = ReplaceStringPlaceholders(new_tab_theme_css, subst, NULL); |
594 new_tab_css_ = base::RefCountedString::TakeString(&css_string); | 597 new_tab_css_ = base::RefCountedString::TakeString(&css_string); |
595 } | 598 } |
OLD | NEW |