| 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 "base/command_line.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 11 #include "base/mac/sdk_forward_declarations.h" | |
| 12 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 13 #include "content/browser/renderer_host/render_process_host_impl.h" | 12 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 14 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
| 15 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
| 18 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 20 | 19 |
| 21 using content::RenderProcessHost; | 20 using content::RenderProcessHost; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 object:nil | 117 object:nil |
| 119 suspensionBehavior: | 118 suspensionBehavior: |
| 120 NSNotificationSuspensionBehaviorDeliverImmediately]; | 119 NSNotificationSuspensionBehaviorDeliverImmediately]; |
| 121 | 120 |
| 122 // In single-process mode, renderers will catch these notifications | 121 // In single-process mode, renderers will catch these notifications |
| 123 // themselves and listening for them here may trigger the DCHECK in Observe(). | 122 // themselves and listening for them here may trigger the DCHECK in Observe(). |
| 124 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 123 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 125 switches::kSingleProcess)) { | 124 switches::kSingleProcess)) { |
| 126 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 125 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 127 | 126 |
| 128 if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) { | 127 [center addObserver:self |
| 129 [center addObserver:self | 128 selector:@selector(behaviorPrefsChanged:) |
| 130 selector:@selector(behaviorPrefsChanged:) | 129 name:NSPreferredScrollerStyleDidChangeNotification |
| 131 name:NSPreferredScrollerStyleDidChangeNotification | 130 object:nil]; |
| 132 object:nil]; | |
| 133 } | |
| 134 | 131 |
| 135 [center addObserver:self | 132 [center addObserver:self |
| 136 selector:@selector(systemColorsChanged:) | 133 selector:@selector(systemColorsChanged:) |
| 137 name:NSSystemColorsDidChangeNotification | 134 name:NSSystemColorsDidChangeNotification |
| 138 object:nil]; | 135 object:nil]; |
| 139 } | 136 } |
| 140 } | 137 } |
| 141 | 138 |
| 142 + (void)appearancePrefsChanged:(NSNotification*)notification { | 139 + (void)appearancePrefsChanged:(NSNotification*)notification { |
| 143 [self notifyPrefsChangedWithRedraw:YES]; | 140 [self notifyPrefsChangedWithRedraw:YES]; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 namespace content { | 172 namespace content { |
| 176 | 173 |
| 177 // static | 174 // static |
| 178 ThemeHelperMac* ThemeHelperMac::GetInstance() { | 175 ThemeHelperMac* ThemeHelperMac::GetInstance() { |
| 179 return base::Singleton<ThemeHelperMac, | 176 return base::Singleton<ThemeHelperMac, |
| 180 base::LeakySingletonTraits<ThemeHelperMac>>::get(); | 177 base::LeakySingletonTraits<ThemeHelperMac>>::get(); |
| 181 } | 178 } |
| 182 | 179 |
| 183 // static | 180 // static |
| 184 blink::ScrollerStyle ThemeHelperMac::GetPreferredScrollerStyle() { | 181 blink::ScrollerStyle ThemeHelperMac::GetPreferredScrollerStyle() { |
| 185 if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) | |
| 186 return blink::ScrollerStyleLegacy; | |
| 187 return static_cast<blink::ScrollerStyle>([NSScroller preferredScrollerStyle]); | 182 return static_cast<blink::ScrollerStyle>([NSScroller preferredScrollerStyle]); |
| 188 } | 183 } |
| 189 | 184 |
| 190 ThemeHelperMac::ThemeHelperMac() { | 185 ThemeHelperMac::ThemeHelperMac() { |
| 191 [ScrollbarPrefsObserver registerAsObserver]; | 186 [ScrollbarPrefsObserver registerAsObserver]; |
| 192 registrar_.Add(this, | 187 registrar_.Add(this, |
| 193 NOTIFICATION_RENDERER_PROCESS_CREATED, | 188 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 194 NotificationService::AllSources()); | 189 NotificationService::AllSources()); |
| 195 } | 190 } |
| 196 | 191 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 209 params.redraw = false; | 204 params.redraw = false; |
| 210 | 205 |
| 211 RenderProcessHostImpl* rphi = | 206 RenderProcessHostImpl* rphi = |
| 212 Source<content::RenderProcessHostImpl>(source).ptr(); | 207 Source<content::RenderProcessHostImpl>(source).ptr(); |
| 213 rphi->RecomputeAndUpdateWebKitPreferences(); | 208 rphi->RecomputeAndUpdateWebKitPreferences(); |
| 214 rphi->Send(new ViewMsg_UpdateScrollbarTheme(params)); | 209 rphi->Send(new ViewMsg_UpdateScrollbarTheme(params)); |
| 215 rphi->Send(CreateSystemColorsChangedMessage()); | 210 rphi->Send(CreateSystemColorsChangedMessage()); |
| 216 } | 211 } |
| 217 | 212 |
| 218 } // namespace content | 213 } // namespace content |
| OLD | NEW |