OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/custom_frame_view.h" | 5 #import "chrome/browser/ui/cocoa/custom_frame_view.h" |
6 | 6 |
7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
8 #include <crt_externs.h> | 8 #include <crt_externs.h> |
9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 @selector(drawRect:)); | 82 @selector(drawRect:)); |
83 Method m2 = class_getInstanceMethod(borderViewClass, | 83 Method m2 = class_getInstanceMethod(borderViewClass, |
84 @selector(drawRectOriginal:)); | 84 @selector(drawRectOriginal:)); |
85 DCHECK(m1 && m2); | 85 DCHECK(m1 && m2); |
86 if (m1 && m2) { | 86 if (m1 && m2) { |
87 method_exchangeImplementations(m1, m2); | 87 method_exchangeImplementations(m1, m2); |
88 } | 88 } |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 // Swizzle the method that sets the origin for the Lion fullscreen button. Do | 92 // In Yosemite, the fullscreen button replaces the zoom button. We no longer |
93 // nothing if it cannot be found. | 93 // need to swizzle out this AppKit private method. |
94 m0 = class_getInstanceMethod([self class], | 94 if (base::mac::IsOSMavericksOrEarlier()) { |
95 @selector(_fullScreenButtonOrigin)); | 95 // Swizzle the method that sets the origin for the Lion fullscreen button. |
96 if (m0) { | 96 // Do nothing if it cannot be found. |
97 BOOL didAdd = class_addMethod(borderViewClass, | 97 m0 = class_getInstanceMethod([self class], |
98 @selector(_fullScreenButtonOriginOriginal), | 98 @selector(_fullScreenButtonOrigin)); |
99 method_getImplementation(m0), | 99 if (m0) { |
100 method_getTypeEncoding(m0)); | 100 BOOL didAdd = class_addMethod(borderViewClass, |
101 if (didAdd) { | 101 @selector(_fullScreenButtonOriginOriginal), |
102 Method m1 = class_getInstanceMethod(borderViewClass, | 102 method_getImplementation(m0), |
103 @selector(_fullScreenButtonOrigin)); | 103 method_getTypeEncoding(m0)); |
104 Method m2 = class_getInstanceMethod(borderViewClass, | 104 if (didAdd) { |
105 @selector(_fullScreenButtonOriginOriginal)); | 105 Method m1 = class_getInstanceMethod(borderViewClass, |
106 if (m1 && m2) { | 106 @selector(_fullScreenButtonOrigin)); |
107 method_exchangeImplementations(m1, m2); | 107 Method m2 = class_getInstanceMethod( |
| 108 borderViewClass, @selector(_fullScreenButtonOriginOriginal)); |
| 109 if (m1 && m2) { |
| 110 method_exchangeImplementations(m1, m2); |
| 111 } |
108 } | 112 } |
109 } | 113 } |
110 } | 114 } |
111 } | 115 } |
112 | 116 |
113 + (BOOL)canDrawTitle { | 117 + (BOOL)canDrawTitle { |
114 return gCanDrawTitle; | 118 return gCanDrawTitle; |
115 } | 119 } |
116 | 120 |
117 + (BOOL)canGetCornerRadius { | 121 + (BOOL)canGetCornerRadius { |
(...skipping 27 matching lines...) Expand all Loading... |
145 if ([window respondsToSelector:@selector(fullScreenButtonOriginAdjustment)]) | 149 if ([window respondsToSelector:@selector(fullScreenButtonOriginAdjustment)]) |
146 offset = [window fullScreenButtonOriginAdjustment]; | 150 offset = [window fullScreenButtonOriginAdjustment]; |
147 | 151 |
148 NSPoint origin = [self _fullScreenButtonOriginOriginal]; | 152 NSPoint origin = [self _fullScreenButtonOriginOriginal]; |
149 origin.x += offset.x; | 153 origin.x += offset.x; |
150 origin.y += offset.y; | 154 origin.y += offset.y; |
151 return origin; | 155 return origin; |
152 } | 156 } |
153 | 157 |
154 @end | 158 @end |
OLD | NEW |