| Index: content/browser/theme_helper_mac.mm
|
| diff --git a/content/browser/theme_helper_mac.mm b/content/browser/theme_helper_mac.mm
|
| index 3b952cc79b8e48d39e86bb6e6ce6b72d474d8001..21c476f0573777bbe78636c52a8d33cf94e5aa56 100644
|
| --- a/content/browser/theme_helper_mac.mm
|
| +++ b/content/browser/theme_helper_mac.mm
|
| @@ -4,7 +4,7 @@
|
|
|
| #include "content/browser/theme_helper_mac.h"
|
|
|
| -#include <Foundation/Foundation.h>
|
| +#import <Cocoa/Cocoa.h>
|
|
|
| #include "content/common/view_messages.h"
|
| #include "content/public/browser/browser_thread.h"
|
| @@ -12,6 +12,17 @@
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_process_host.h"
|
|
|
| +// Declare notification names from the 10.7 SDK.
|
| +#if !defined(MAC_OS_X_VERSION_10_7) || \
|
| + MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
| +NSString* NSPreferredScrollerStyleDidChangeNotification =
|
| + @"NSPreferredScrollerStyleDidChangeNotification";
|
| +
|
| +@interface NSScroller (LionSDK)
|
| ++ (NSInteger)preferredScrollerStyle;
|
| +@end
|
| +#endif
|
| +
|
| @interface ScrollbarPrefsObserver : NSObject
|
|
|
| + (void)registerAsObserver;
|
| @@ -37,6 +48,14 @@ suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
|
| name:@"AppleNoRedisplayAppearancePreferenceChanged"
|
| object:nil
|
| suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];
|
| +
|
| + if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) {
|
| + [[NSNotificationCenter defaultCenter]
|
| + addObserver:self
|
| + selector:@selector(behaviorPrefsChanged:)
|
| + name:NSPreferredScrollerStyleDidChangeNotification
|
| + object:nil];
|
| + }
|
| }
|
|
|
| + (void)appearancePrefsChanged:(NSNotification*)notification {
|
| @@ -56,6 +75,7 @@ suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];
|
| [defaults floatForKey:@"NSScrollerButtonDelay"],
|
| [defaults floatForKey:@"NSScrollerButtonPeriod"],
|
| [defaults boolForKey:@"AppleScrollerPagingBehavior"],
|
| + content::ThemeHelperMac::GetPreferredScrollerStyle(),
|
| redraw);
|
| }
|
|
|
| @@ -63,6 +83,38 @@ suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];
|
|
|
| namespace content {
|
|
|
| +// static
|
| +ThemeHelperMac* ThemeHelperMac::GetInstance() {
|
| + return Singleton<ThemeHelperMac,
|
| + LeakySingletonTraits<ThemeHelperMac> >::get();
|
| +}
|
| +
|
| +// static
|
| +blink::ScrollerStyle ThemeHelperMac::GetPreferredScrollerStyle() {
|
| + if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)])
|
| + return blink::ScrollerStyleLegacy;
|
| + return static_cast<blink::ScrollerStyle>([NSScroller preferredScrollerStyle]);
|
| +}
|
| +
|
| +// static
|
| +void ThemeHelperMac::SendThemeChangeToAllRenderers(
|
| + float initial_button_delay,
|
| + float autoscroll_button_delay,
|
| + bool jump_on_track_click,
|
| + blink::ScrollerStyle preferred_scroller_style,
|
| + 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,
|
| + preferred_scroller_style,
|
| + redraw));
|
| + }
|
| +}
|
| +
|
| ThemeHelperMac::ThemeHelperMac() {
|
| [ScrollbarPrefsObserver registerAsObserver];
|
| registrar_.Add(this,
|
| @@ -73,13 +125,6 @@ ThemeHelperMac::ThemeHelperMac() {
|
| ThemeHelperMac::~ThemeHelperMac() {
|
| }
|
|
|
| -// static
|
| -ThemeHelperMac* ThemeHelperMac::GetInstance() {
|
| - return Singleton<ThemeHelperMac,
|
| - LeakySingletonTraits<ThemeHelperMac> >::get();
|
| -}
|
| -
|
| -
|
| void ThemeHelperMac::Observe(int type,
|
| const NotificationSource& source,
|
| const NotificationDetails& details) {
|
| @@ -94,24 +139,8 @@ void ThemeHelperMac::Observe(int type,
|
| [defaults floatForKey:@"NSScrollerButtonDelay"],
|
| [defaults floatForKey:@"NSScrollerButtonPeriod"],
|
| [defaults boolForKey:@"AppleScrollerPagingBehavior"],
|
| + GetPreferredScrollerStyle(),
|
| 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
|
|
|