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> |
| 8 #include <crt_externs.h> |
7 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
8 #import <Carbon/Carbon.h> | 10 #include <string.h> |
9 | 11 |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
12 #include "base/mac/scoped_nsautorelease_pool.h" | 14 #include "base/mac/scoped_nsautorelease_pool.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 BOOL gCanDrawTitle = NO; | 17 BOOL gCanDrawTitle = NO; |
16 BOOL gCanGetCornerRadius = NO; | 18 BOOL gCanGetCornerRadius = NO; |
17 } // namespace | 19 } // namespace |
18 | 20 |
(...skipping 17 matching lines...) Expand all Loading... |
36 @end | 38 @end |
37 | 39 |
38 @implementation CustomFrameView | 40 @implementation CustomFrameView |
39 | 41 |
40 // This is where we swizzle drawRect, and add in two methods that we | 42 // This is where we swizzle drawRect, and add in two methods that we |
41 // need. If any of these fail it shouldn't affect the functionality of the | 43 // need. If any of these fail it shouldn't affect the functionality of the |
42 // others. If they all fail, we will lose window frame theming and | 44 // others. If they all fail, we will lose window frame theming and |
43 // roll overs for our close widgets, but things should still function | 45 // roll overs for our close widgets, but things should still function |
44 // correctly. | 46 // correctly. |
45 + (void)load { | 47 + (void)load { |
| 48 // Swizzling should only happen in the browser process. Interacting with |
| 49 // AppKit will run +[borderViewClass initialize] in the renderer, which |
| 50 // may establish Mach IPC with com.apple.windowserver. |
| 51 // Note that CommandLine has not been initialized yet, since this is running |
| 52 // as a module initializer. |
| 53 const char* const* const argv = *_NSGetArgv(); |
| 54 const int argc = *_NSGetArgc(); |
| 55 const char kType[] = "--type="; |
| 56 for (int i = 1; i < argc; ++i) { |
| 57 const char* arg = argv[i]; |
| 58 if (strncmp(arg, kType, strlen(kType)) == 0) |
| 59 return; |
| 60 } |
| 61 |
46 base::mac::ScopedNSAutoreleasePool pool; | 62 base::mac::ScopedNSAutoreleasePool pool; |
47 | 63 |
48 // On 10.8+ the background for textured windows are no longer drawn by | 64 // On 10.8+ the background for textured windows are no longer drawn by |
49 // NSGrayFrame, and NSThemeFrame is used instead <http://crbug.com/114745>. | 65 // NSGrayFrame, and NSThemeFrame is used instead <http://crbug.com/114745>. |
50 Class borderViewClass = NSClassFromString( | 66 Class borderViewClass = NSClassFromString( |
51 base::mac::IsOSMountainLionOrLater() ? @"NSThemeFrame" : @"NSGrayFrame"); | 67 base::mac::IsOSMountainLionOrLater() ? @"NSThemeFrame" : @"NSGrayFrame"); |
52 DCHECK(borderViewClass); | 68 DCHECK(borderViewClass); |
53 if (!borderViewClass) return; | 69 if (!borderViewClass) return; |
54 | 70 |
55 // Exchange draw rect. | 71 // Exchange draw rect. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 if ([window respondsToSelector:@selector(fullScreenButtonOriginAdjustment)]) | 145 if ([window respondsToSelector:@selector(fullScreenButtonOriginAdjustment)]) |
130 offset = [window fullScreenButtonOriginAdjustment]; | 146 offset = [window fullScreenButtonOriginAdjustment]; |
131 | 147 |
132 NSPoint origin = [self _fullScreenButtonOriginOriginal]; | 148 NSPoint origin = [self _fullScreenButtonOriginOriginal]; |
133 origin.x += offset.x; | 149 origin.x += offset.x; |
134 origin.y += offset.y; | 150 origin.y += offset.y; |
135 return origin; | 151 return origin; |
136 } | 152 } |
137 | 153 |
138 @end | 154 @end |
OLD | NEW |