OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/browser_frame_view.h" | 5 #import "chrome/browser/cocoa/browser_frame_view.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 #import <Carbon/Carbon.h> | 8 #import <Carbon/Carbon.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/scoped_nsautorelease_pool.h" | 11 #include "base/mac/scoped_nsautorelease_pool.h" |
12 #import "chrome/browser/cocoa/framed_browser_window.h" | 12 #import "chrome/browser/cocoa/framed_browser_window.h" |
13 #import "chrome/browser/cocoa/themed_window.h" | 13 #import "chrome/browser/cocoa/themed_window.h" |
14 #import "chrome/browser/themes/browser_theme_provider.h" | 14 #import "chrome/browser/themes/browser_theme_provider.h" |
15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
16 | 16 |
17 static const CGFloat kBrowserFrameViewPaintHeight = 60.0; | 17 static const CGFloat kBrowserFrameViewPaintHeight = 60.0; |
18 static const NSPoint kBrowserFrameViewPatternPhaseOffset = { -5, 3 }; | 18 static const NSPoint kBrowserFrameViewPatternPhaseOffset = { -5, 3 }; |
19 | 19 |
20 static BOOL gCanDrawTitle = NO; | 20 static BOOL gCanDrawTitle = NO; |
21 static BOOL gCanGetCornerRadius = NO; | 21 static BOOL gCanGetCornerRadius = NO; |
(...skipping 17 matching lines...) Expand all Loading... |
39 @end | 39 @end |
40 | 40 |
41 @implementation BrowserFrameView | 41 @implementation BrowserFrameView |
42 | 42 |
43 + (void)load { | 43 + (void)load { |
44 // This is where we swizzle drawRect, and add in two methods that we | 44 // This is where we swizzle drawRect, and add in two methods that we |
45 // need. If any of these fail it shouldn't affect the functionality of the | 45 // need. If any of these fail it shouldn't affect the functionality of the |
46 // others. If they all fail, we will lose window frame theming and | 46 // others. If they all fail, we will lose window frame theming and |
47 // roll overs for our close widgets, but things should still function | 47 // roll overs for our close widgets, but things should still function |
48 // correctly. | 48 // correctly. |
49 base::ScopedNSAutoreleasePool pool; | 49 base::mac::ScopedNSAutoreleasePool pool; |
50 Class grayFrameClass = NSClassFromString(@"NSGrayFrame"); | 50 Class grayFrameClass = NSClassFromString(@"NSGrayFrame"); |
51 DCHECK(grayFrameClass); | 51 DCHECK(grayFrameClass); |
52 if (!grayFrameClass) return; | 52 if (!grayFrameClass) return; |
53 | 53 |
54 // Exchange draw rect. | 54 // Exchange draw rect. |
55 Method m0 = class_getInstanceMethod([self class], @selector(drawRect:)); | 55 Method m0 = class_getInstanceMethod([self class], @selector(drawRect:)); |
56 DCHECK(m0); | 56 DCHECK(m0); |
57 if (m0) { | 57 if (m0) { |
58 BOOL didAdd = class_addMethod(grayFrameClass, | 58 BOOL didAdd = class_addMethod(grayFrameClass, |
59 @selector(drawRectOriginal:), | 59 @selector(drawRectOriginal:), |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 390 |
391 // If this isn't the window class we expect, then pass it on to the | 391 // If this isn't the window class we expect, then pass it on to the |
392 // original implementation. | 392 // original implementation. |
393 if (![[self window] isKindOfClass:[FramedBrowserWindow class]]) | 393 if (![[self window] isKindOfClass:[FramedBrowserWindow class]]) |
394 return [self _shadowFlagsOriginal]; | 394 return [self _shadowFlagsOriginal]; |
395 | 395 |
396 return [self _shadowFlagsOriginal] | 128; | 396 return [self _shadowFlagsOriginal] | 128; |
397 } | 397 } |
398 | 398 |
399 @end | 399 @end |
OLD | NEW |