 Chromium Code Reviews
 Chromium Code Reviews Issue 157763002:
  [Mac] In +[CustomFrameView load], do not perform any work if the process has a --type flag.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 157763002:
  [Mac] In +[CustomFrameView load], do not perform any work if the process has a --type flag.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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 for (int i = 1; i < argc; ++i) { | |
| 56 const char* arg = argv[i]; | |
| 57 if (strcmp(arg, "--type=") >= 0) | |
| 
Mark Mentovai
2014/02/07 19:06:26
Gotta use strNcmp.
 
Robert Sesek
2014/02/07 19:46:36
I don't even know what this code does. What stupid
 | |
| 58 return; | |
| 59 } | |
| 60 | |
| 46 base::mac::ScopedNSAutoreleasePool pool; | 61 base::mac::ScopedNSAutoreleasePool pool; | 
| 47 | 62 | 
| 48 // On 10.8+ the background for textured windows are no longer drawn by | 63 // On 10.8+ the background for textured windows are no longer drawn by | 
| 49 // NSGrayFrame, and NSThemeFrame is used instead <http://crbug.com/114745>. | 64 // NSGrayFrame, and NSThemeFrame is used instead <http://crbug.com/114745>. | 
| 50 Class borderViewClass = NSClassFromString( | 65 Class borderViewClass = NSClassFromString( | 
| 51 base::mac::IsOSMountainLionOrLater() ? @"NSThemeFrame" : @"NSGrayFrame"); | 66 base::mac::IsOSMountainLionOrLater() ? @"NSThemeFrame" : @"NSGrayFrame"); | 
| 52 DCHECK(borderViewClass); | 67 DCHECK(borderViewClass); | 
| 53 if (!borderViewClass) return; | 68 if (!borderViewClass) return; | 
| 54 | 69 | 
| 55 // Exchange draw rect. | 70 // Exchange draw rect. | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 if ([window respondsToSelector:@selector(fullScreenButtonOriginAdjustment)]) | 144 if ([window respondsToSelector:@selector(fullScreenButtonOriginAdjustment)]) | 
| 130 offset = [window fullScreenButtonOriginAdjustment]; | 145 offset = [window fullScreenButtonOriginAdjustment]; | 
| 131 | 146 | 
| 132 NSPoint origin = [self _fullScreenButtonOriginOriginal]; | 147 NSPoint origin = [self _fullScreenButtonOriginOriginal]; | 
| 133 origin.x += offset.x; | 148 origin.x += offset.x; | 
| 134 origin.y += offset.y; | 149 origin.y += offset.y; | 
| 135 return origin; | 150 return origin; | 
| 136 } | 151 } | 
| 137 | 152 | 
| 138 @end | 153 @end | 
| OLD | NEW |