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

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: Fix grammar & style. 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_resource_cache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..545930d78f0468f407befc523bb33a45da4be892 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 "chrome/browser/platform_util.h"
+#endif
+
using base::Time;
using content::BrowserThread;
@@ -195,13 +199,28 @@ NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) {
NTPResourceCache::~NTPResourceCache() {}
+bool NTPResourceCache::NewTabCacheNeedsRefresh() {
+#if defined(OS_MACOSX)
+ // Invalidate if the current value is different from the cached value.
+ bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled();
+ if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) {
+ is_swipe_tracking_from_scroll_events_enabled_ = is_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())
+ // Refresh the cached HTML if necessary.
+ // NOTE: NewTabCacheNeedsRefresh() must be called every time the new tab
+ // HTML is fetched, because it needs to initialize cached values.
+ if (NewTabCacheNeedsRefresh() || !new_tab_html_.get())
CreateNewTabHTML();
}
return is_incognito ? new_tab_incognito_html_.get() :
@@ -365,6 +384,12 @@ 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.
+ localized_strings.SetBoolean("isSwipeTrackingFromScrollEventsEnabled",
+ is_swipe_tracking_from_scroll_events_enabled_);
+
#if defined(OS_CHROMEOS)
localized_strings.SetString("expandMenu",
l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_MENU_EXPAND));
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_resource_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698