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

Side by Side Diff: content/browser/theme_helper_mac.mm

Issue 1642553004: Make a test not depend on system settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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" 11 #include "base/mac/sdk_forward_declarations.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
17 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 19
20 using content::RenderProcessHost; 20 using content::RenderProcessHost;
21 using content::ThemeHelperMac; 21 using content::ThemeHelperMac;
22 22
23 namespace { 23 namespace {
24 24
25 content::ScopedPreferredScrollerStyleOveride*
26 g_preferred_scroller_style_override = nullptr;
27
25 bool GetScrollAnimationEnabled() { 28 bool GetScrollAnimationEnabled() {
26 bool enabled = false; 29 bool enabled = false;
27 id value = nil; 30 id value = nil;
28 if (base::mac::IsOSMountainLionOrLater()) { 31 if (base::mac::IsOSMountainLionOrLater()) {
29 value = [[NSUserDefaults standardUserDefaults] 32 value = [[NSUserDefaults standardUserDefaults]
30 objectForKey:@"NSScrollAnimationEnabled"]; 33 objectForKey:@"NSScrollAnimationEnabled"];
31 } else { 34 } else {
32 value = [[NSUserDefaults standardUserDefaults] 35 value = [[NSUserDefaults standardUserDefaults]
33 objectForKey:@"AppleScrollAnimationEnabled"]; 36 objectForKey:@"AppleScrollAnimationEnabled"];
34 } 37 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 !it.IsAtEnd(); 181 !it.IsAtEnd();
179 it.Advance()) { 182 it.Advance()) {
180 it.GetCurrentValue()->Send(new ViewMsg_UpdateScrollbarTheme(params)); 183 it.GetCurrentValue()->Send(new ViewMsg_UpdateScrollbarTheme(params));
181 } 184 }
182 } 185 }
183 186
184 @end 187 @end
185 188
186 namespace content { 189 namespace content {
187 190
191 ScopedPreferredScrollerStyleOveride::ScopedPreferredScrollerStyleOveride(
192 blink::ScrollerStyle value) : value_(value) {
193 DCHECK(!g_preferred_scroller_style_override);
194 g_preferred_scroller_style_override = this;
195 [ScrollbarPrefsObserver notifyPrefsChangedWithRedraw:NO];
196 }
197
198 ScopedPreferredScrollerStyleOveride::~ScopedPreferredScrollerStyleOveride() {
199 g_preferred_scroller_style_override = nullptr;
200 [ScrollbarPrefsObserver notifyPrefsChangedWithRedraw:NO];
201 }
202
188 // static 203 // static
189 ThemeHelperMac* ThemeHelperMac::GetInstance() { 204 ThemeHelperMac* ThemeHelperMac::GetInstance() {
190 return base::Singleton<ThemeHelperMac, 205 return base::Singleton<ThemeHelperMac,
191 base::LeakySingletonTraits<ThemeHelperMac>>::get(); 206 base::LeakySingletonTraits<ThemeHelperMac>>::get();
192 } 207 }
193 208
194 // static 209 // static
195 blink::ScrollerStyle ThemeHelperMac::GetPreferredScrollerStyle() { 210 blink::ScrollerStyle ThemeHelperMac::GetPreferredScrollerStyle() {
211 if (g_preferred_scroller_style_override)
212 return g_preferred_scroller_style_override->value();
196 if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) 213 if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)])
197 return blink::ScrollerStyleLegacy; 214 return blink::ScrollerStyleLegacy;
198 return static_cast<blink::ScrollerStyle>([NSScroller preferredScrollerStyle]); 215 return static_cast<blink::ScrollerStyle>([NSScroller preferredScrollerStyle]);
199 } 216 }
200 217
201 ThemeHelperMac::ThemeHelperMac() { 218 ThemeHelperMac::ThemeHelperMac() {
202 [ScrollbarPrefsObserver registerAsObserver]; 219 [ScrollbarPrefsObserver registerAsObserver];
203 registrar_.Add(this, 220 registrar_.Add(this,
204 NOTIFICATION_RENDERER_PROCESS_CREATED, 221 NOTIFICATION_RENDERER_PROCESS_CREATED,
205 NotificationService::AllSources()); 222 NotificationService::AllSources());
(...skipping 12 matching lines...) Expand all
218 ViewMsg_UpdateScrollbarTheme_Params params; 235 ViewMsg_UpdateScrollbarTheme_Params params;
219 FillScrollbarThemeParams(&params); 236 FillScrollbarThemeParams(&params);
220 params.redraw = false; 237 params.redraw = false;
221 238
222 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); 239 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr();
223 rph->Send(new ViewMsg_UpdateScrollbarTheme(params)); 240 rph->Send(new ViewMsg_UpdateScrollbarTheme(params));
224 rph->Send(CreateSystemColorsChangedMessage()); 241 rph->Send(CreateSystemColorsChangedMessage());
225 } 242 }
226 243
227 } // namespace content 244 } // namespace content
OLDNEW
« content/browser/theme_helper_mac.h ('K') | « content/browser/theme_helper_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698