Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "ui/views/cocoa/views_scrollbar_bridge.h" | |
| 6 | |
| 7 #include "base/mac/mac_util.h" | |
| 8 #import "base/mac/sdk_forward_declarations.h" | |
| 9 | |
| 10 @interface ViewsScrollbarBridge () | |
| 11 | |
| 12 // Called when we receive a NSPreferredScrollerStyleDidChangeNotification. | |
| 13 - (void)onScrollerStyleChanged:(NSNotification*)notification; | |
| 14 | |
| 15 @end | |
| 16 | |
| 17 @implementation ViewsScrollbarBridge | |
| 18 | |
| 19 - (id)initWithDelegate:(ViewsScrollbarBridgeDelegate*)delegate { | |
| 20 if (self = [super init]) { | |
|
tapted
2016/02/22 22:34:57
needs extra parens around assignment used as condi
spqchan
2016/02/22 23:26:03
Done.
| |
| 21 delegate_ = delegate; | |
| 22 [[NSNotificationCenter defaultCenter] | |
| 23 addObserver:self | |
| 24 selector:@selector(onScrollerStyleChanged:) | |
| 25 name:NSPreferredScrollerStyleDidChangeNotification | |
| 26 object:nil]; | |
| 27 } | |
| 28 return self; | |
| 29 } | |
| 30 | |
| 31 - (void)dealloc { | |
| 32 [super dealloc]; | |
| 33 [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
|
tapted
2016/02/22 22:34:57
I'm not really a fan of this approach. I guess her
spqchan
2016/02/22 23:26:03
Added a clearDelegate method
| |
| 34 } | |
| 35 | |
| 36 - (void)onScrollerStyleChanged:(NSNotification*)notification { | |
| 37 if (delegate_) | |
| 38 delegate_->OnScrollerStyleChanged(); | |
| 39 } | |
| 40 | |
| 41 + (NSScrollerStyle)getPreferredScrollerStyle { | |
| 42 if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) { | |
| 43 DCHECK(base::mac::IsOSSnowLeopard()); | |
| 44 return NSScrollerStyleLegacy; | |
| 45 } | |
| 46 return [NSScroller preferredScrollerStyle]; | |
| 47 } | |
| 48 | |
| 49 @end | |
| OLD | NEW |