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

Unified Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc

Issue 10092017: Mac: Prevent NTP mousewheel events from being suppressed on Lion. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
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..6dd63fd14c281c24076dbbbedee5aba74e00cab0 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() {
+#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;
+ LOG(WARNING) << "Invalidating!";
+ 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());
+#else
+ localized_strings.SetBoolean("isSwipeTrackingFromScrollEventsEnabled",
+ false);
+#endif
+
#if defined(OS_CHROMEOS)
localized_strings.SetString("expandMenu",
l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND));

Powered by Google App Engine
This is Rietveld 408576698