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 #include "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 - (void)setDelegate:(ViewsScrollbarBridgeDelegate*)delegate { | |
| 20 DCHECK_NE(delegate, delegate_); | |
| 21 if (!delegate_) { | |
| 22 [[NSNotificationCenter defaultCenter] | |
| 23 removeObserver:self | |
| 24 name:NSPreferredScrollerStyleDidChangeNotification | |
| 25 object:nil]; | |
| 26 return; | |
| 27 } | |
| 28 [[NSNotificationCenter defaultCenter] | |
| 29 addObserver:self | |
| 30 selector:@selector(onScrollerStyleChanged:) | |
| 31 name:NSPreferredScrollerStyleDidChangeNotification | |
| 32 object:nil]; | |
| 33 } | |
| 34 | |
| 35 - (void)dealloc { | |
| 36 DCHECK(!delegate_); | |
| 37 [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
|
spqchan
2016/02/09 21:21:26
This might be unnecessary? Especially since we're
tapted
2016/02/09 23:51:48
Yeah - I think it's redundant with the DCHECK abov
spqchan
2016/02/10 00:35:16
Gotcha, removed it
| |
| 38 [super dealloc]; | |
| 39 } | |
| 40 | |
| 41 - (void)onScrollerStyleChanged:(NSNotification*)notification { | |
| 42 delegate_->OnScrollerStyleChanged(); | |
| 43 } | |
| 44 | |
| 45 - (NSScrollerStyle)getPreferredScrollerStyle { | |
| 46 if (![NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) { | |
| 47 DCHECK(base::mac::IsOSSnowLeopard()); | |
| 48 return NSScrollerStyleLegacy; | |
| 49 } | |
| 50 return [NSScroller preferredScrollerStyle]; | |
| 51 } | |
| 52 | |
| 53 @end | |
| OLD | NEW |