OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/theme_helper_mac.h" | 5 #include "content/browser/theme_helper_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
| 9 #include "base/command_line.h" |
9 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
12 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
13 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
| 15 #include "content/public/common/content_switches.h" |
14 | 16 |
15 // Declare notification names from the 10.7 SDK. | 17 // Declare notification names from the 10.7 SDK. |
16 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 18 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
17 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 19 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
18 NSString* NSPreferredScrollerStyleDidChangeNotification = | 20 NSString* NSPreferredScrollerStyleDidChangeNotification = |
19 @"NSPreferredScrollerStyleDidChangeNotification"; | 21 @"NSPreferredScrollerStyleDidChangeNotification"; |
20 | 22 |
21 @interface NSScroller (LionSDK) | 23 @interface NSScroller (LionSDK) |
22 + (NSInteger)preferredScrollerStyle; | 24 + (NSInteger)preferredScrollerStyle; |
23 @end | 25 @end |
(...skipping 18 matching lines...) Expand all Loading... |
42 object:nil | 44 object:nil |
43 suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; | 45 suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; |
44 | 46 |
45 [[NSDistributedNotificationCenter defaultCenter] | 47 [[NSDistributedNotificationCenter defaultCenter] |
46 addObserver:self | 48 addObserver:self |
47 selector:@selector(behaviorPrefsChanged:) | 49 selector:@selector(behaviorPrefsChanged:) |
48 name:@"AppleNoRedisplayAppearancePreferenceChanged" | 50 name:@"AppleNoRedisplayAppearancePreferenceChanged" |
49 object:nil | 51 object:nil |
50 suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce]; | 52 suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce]; |
51 | 53 |
52 if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) { | 54 // In single-process mode, renderers will catch these notifications |
| 55 // themselves and listening for them here may trigger the DCHECK in Observe(). |
| 56 if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)] && |
| 57 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { |
53 [[NSNotificationCenter defaultCenter] | 58 [[NSNotificationCenter defaultCenter] |
54 addObserver:self | 59 addObserver:self |
55 selector:@selector(behaviorPrefsChanged:) | 60 selector:@selector(behaviorPrefsChanged:) |
56 name:NSPreferredScrollerStyleDidChangeNotification | 61 name:NSPreferredScrollerStyleDidChangeNotification |
57 object:nil]; | 62 object:nil]; |
58 } | 63 } |
59 } | 64 } |
60 | 65 |
61 + (void)appearancePrefsChanged:(NSNotification*)notification { | 66 + (void)appearancePrefsChanged:(NSNotification*)notification { |
62 [self notifyPrefsChangedWithRedraw:YES]; | 67 [self notifyPrefsChangedWithRedraw:YES]; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 142 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
138 rph->Send(new ViewMsg_UpdateScrollbarTheme( | 143 rph->Send(new ViewMsg_UpdateScrollbarTheme( |
139 [defaults floatForKey:@"NSScrollerButtonDelay"], | 144 [defaults floatForKey:@"NSScrollerButtonDelay"], |
140 [defaults floatForKey:@"NSScrollerButtonPeriod"], | 145 [defaults floatForKey:@"NSScrollerButtonPeriod"], |
141 [defaults boolForKey:@"AppleScrollerPagingBehavior"], | 146 [defaults boolForKey:@"AppleScrollerPagingBehavior"], |
142 GetPreferredScrollerStyle(), | 147 GetPreferredScrollerStyle(), |
143 false)); | 148 false)); |
144 } | 149 } |
145 | 150 |
146 } // namespace content | 151 } // namespace content |
OLD | NEW |