Chromium Code Reviews| Index: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
| diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
| index c5dadc2e31965856a8093cb71f8c33598049762d..ccfc1161b95b60688cf5cb3b1e09e3d6bec2b3ca 100644 |
| --- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
| +++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc |
| @@ -58,6 +58,10 @@ |
| #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
| #endif |
| +#if defined(OS_MACOSX) |
| +#include "base/mac/mac_util.h" |
| +#endif |
| + |
| using base::Time; |
| using content::BrowserThread; |
| @@ -176,7 +180,8 @@ bool InDateRange(double begin, double end) { |
| } // namespace |
| -NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) { |
| +NTPResourceCache::NTPResourceCache(Profile* profile) |
| + : profile_(profile), isSwipeTrackingFromScrollEventsEnabled_(false) { |
| registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| content::Source<ThemeService>( |
| ThemeServiceFactory::GetForProfile(profile))); |
| @@ -195,13 +200,26 @@ NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) { |
| NTPResourceCache::~NTPResourceCache() {} |
| +bool NTPResourceCache::InvalidateNewTabCache() { |
|
Evan Stade
2012/04/17 21:29:53
s/InvalidateNewTabCache/NewTabCacheNeedsRefresh/g
Patrick Dubroy
2012/04/18 14:43:06
Done.
|
| +#if defined(OS_MACOSX) |
| + // Invalidate if the current value is different from the cached value. |
| + bool swipe_tracking_enabled = |
| + base::mac::IsSwipeTrackingFromScrollEventsEnabled(); |
| + if (swipe_tracking_enabled != isSwipeTrackingFromScrollEventsEnabled_) { |
| + isSwipeTrackingFromScrollEventsEnabled_ = swipe_tracking_enabled; |
| + return true; |
| + } |
| +#endif |
| + return false; |
| +} |
| + |
| RefCountedMemory* NTPResourceCache::GetNewTabHTML(bool is_incognito) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| if (is_incognito) { |
| if (!new_tab_incognito_html_.get()) |
| CreateNewTabIncognitoHTML(); |
| } else { |
| - if (!new_tab_html_.get()) |
| + if (!new_tab_html_.get() || InvalidateNewTabCache()) |
| CreateNewTabHTML(); |
| } |
| return is_incognito ? new_tab_incognito_html_.get() : |
| @@ -365,6 +383,17 @@ void NTPResourceCache::CreateNewTabHTML() { |
| localized_strings.SetString("hideSessionMenuItemText", |
| l10n_util::GetStringUTF16(IDS_POLICY_HIDE)); |
| + // On Mac OS X 10.7+, horizontal scrolling can be treated as a back or |
| + // forward gesture. Pass through a flag that indicates whether or not that |
| + // feature is enabled. |
| +#if defined(OS_MACOSX) |
| + localized_strings.SetBoolean("isSwipeTrackingFromScrollEventsEnabled", |
| + base::mac::IsSwipeTrackingFromScrollEventsEnabled()); |
|
Evan Stade
2012/04/17 21:29:53
use the member var to avoid these ifdefs
Patrick Dubroy
2012/04/18 14:43:06
Done.
|
| +#else |
| + localized_strings.SetBoolean("isSwipeTrackingFromScrollEventsEnabled", |
| + false); |
| +#endif |
| + |
| #if defined(OS_CHROMEOS) |
| localized_strings.SetString("expandMenu", |
| l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND)); |