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

Unified Diff: content/browser/theme_helper_mac.mm

Issue 63203003: Have Blink be told of scrollbar changes rather than paying attention itself (Chromium side). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WebKit:: -> blink:: Created 7 years, 1 month 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 | « content/browser/theme_helper_mac.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/theme_helper_mac.mm
diff --git a/content/browser/theme_helper_mac.mm b/content/browser/theme_helper_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..3b952cc79b8e48d39e86bb6e6ce6b72d474d8001
--- /dev/null
+++ b/content/browser/theme_helper_mac.mm
@@ -0,0 +1,117 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/theme_helper_mac.h"
+
+#include <Foundation/Foundation.h>
+
+#include "content/common/view_messages.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_process_host.h"
+
+@interface ScrollbarPrefsObserver : NSObject
+
++ (void)registerAsObserver;
++ (void)appearancePrefsChanged:(NSNotification*)notification;
++ (void)behaviorPrefsChanged:(NSNotification*)notification;
++ (void)notifyPrefsChangedWithRedraw:(BOOL)redraw;
+
+@end
+
+@implementation ScrollbarPrefsObserver
+
++ (void)registerAsObserver {
+ [[NSDistributedNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(appearancePrefsChanged:)
+ name:@"AppleAquaScrollBarVariantChanged"
+ object:nil
+suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
+
+ [[NSDistributedNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(behaviorPrefsChanged:)
+ name:@"AppleNoRedisplayAppearancePreferenceChanged"
+ object:nil
+suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];
+}
+
++ (void)appearancePrefsChanged:(NSNotification*)notification {
+ [self notifyPrefsChangedWithRedraw:YES];
+}
+
++ (void)behaviorPrefsChanged:(NSNotification*)notification {
+ [self notifyPrefsChangedWithRedraw:NO];
+}
+
++ (void)notifyPrefsChangedWithRedraw:(BOOL)redraw {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ [defaults synchronize];
+
+ content::ThemeHelperMac::SendThemeChangeToAllRenderers(
+ [defaults floatForKey:@"NSScrollerButtonDelay"],
+ [defaults floatForKey:@"NSScrollerButtonPeriod"],
+ [defaults boolForKey:@"AppleScrollerPagingBehavior"],
+ redraw);
+}
+
+@end
+
+namespace content {
+
+ThemeHelperMac::ThemeHelperMac() {
+ [ScrollbarPrefsObserver registerAsObserver];
+ registrar_.Add(this,
+ NOTIFICATION_RENDERER_PROCESS_CREATED,
+ NotificationService::AllSources());
+}
+
+ThemeHelperMac::~ThemeHelperMac() {
+}
+
+// static
+ThemeHelperMac* ThemeHelperMac::GetInstance() {
+ return Singleton<ThemeHelperMac,
+ LeakySingletonTraits<ThemeHelperMac> >::get();
+}
+
+
+void ThemeHelperMac::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK_EQ(NOTIFICATION_RENDERER_PROCESS_CREATED, type);
+
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ [defaults synchronize];
+
+ RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr();
+ rph->Send(new ViewMsg_UpdateScrollbarTheme(
+ [defaults floatForKey:@"NSScrollerButtonDelay"],
+ [defaults floatForKey:@"NSScrollerButtonPeriod"],
+ [defaults boolForKey:@"AppleScrollerPagingBehavior"],
+ false));
+}
+
+// static
+void ThemeHelperMac::SendThemeChangeToAllRenderers(
+ float initial_button_delay,
+ float autoscroll_button_delay,
+ bool jump_on_track_click,
+ bool redraw) {
+ for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
+ !it.IsAtEnd();
+ it.Advance()) {
+ it.GetCurrentValue()->Send(new ViewMsg_UpdateScrollbarTheme(
+ initial_button_delay,
+ autoscroll_button_delay,
+ jump_on_track_click,
+ redraw));
+ }
+}
+
+} // namespace content
« no previous file with comments | « content/browser/theme_helper_mac.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698