Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: chrome/browser/ui/cocoa/custom_frame_view.mm

Issue 1101923002: mac: Suppress a clang warning in CustomFrameView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch to UNAVAILABLE_ATTRIBUTE. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #include "base/mac/scoped_nsautorelease_pool.h" 14 #include "base/mac/scoped_nsautorelease_pool.h"
15 15
16 @interface NSView (Swizzles) 16 @interface NSView (Swizzles)
17 - (NSPoint)_fullScreenButtonOriginOriginal; 17 - (NSPoint)_fullScreenButtonOriginOriginal;
18 @end 18 @end
19 19
20 @interface NSWindow (FramedBrowserWindow) 20 @interface NSWindow (FramedBrowserWindow)
21 - (NSPoint)fullScreenButtonOriginAdjustment; 21 - (NSPoint)fullScreenButtonOriginAdjustment;
22 @end 22 @end
23 23
24 @interface CustomFrameView : NSView 24 @interface CustomFrameView : NSView
25 25
26 // Clang emits a warning if designated initializers don't call the super
27 // initializer, even if the method raises an exception.
28 // http://www.crbug.com/479019.
29 - (id)initWithFrame:(NSRect)frame UNAVAILABLE_ATTRIBUTE;
30 - (id)initWithCoder:(NSCoder*)coder UNAVAILABLE_ATTRIBUTE;
31
26 @end 32 @end
27 33
28 @implementation CustomFrameView 34 @implementation CustomFrameView
29 35
30 + (void)load { 36 + (void)load {
31 // Swizzling should only happen in the browser process. Interacting with 37 // Swizzling should only happen in the browser process. Interacting with
32 // AppKit will run +[borderViewClass initialize] in the renderer, which 38 // AppKit will run +[borderViewClass initialize] in the renderer, which
33 // may establish Mach IPC with com.apple.windowserver. 39 // may establish Mach IPC with com.apple.windowserver.
34 // Note that CommandLine has not been initialized yet, since this is running 40 // Note that CommandLine has not been initialized yet, since this is running
35 // as a module initializer. 41 // as a module initializer.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 @selector(_fullScreenButtonOrigin)); 76 @selector(_fullScreenButtonOrigin));
71 Method m2 = class_getInstanceMethod( 77 Method m2 = class_getInstanceMethod(
72 borderViewClass, @selector(_fullScreenButtonOriginOriginal)); 78 borderViewClass, @selector(_fullScreenButtonOriginOriginal));
73 if (m1 && m2) { 79 if (m1 && m2) {
74 method_exchangeImplementations(m1, m2); 80 method_exchangeImplementations(m1, m2);
75 } 81 }
76 } 82 }
77 } 83 }
78 } 84 }
79 85
80 // TODO(erikchen): Clang throws a warning if a designated initializer doesn't
81 // call the super initializer, even if the method raises an exception. These
82 // pragmas shouldn't be necessary.
83 // http://www.crbug.com/479019.
84 #pragma clang diagnostic push
85 #pragma clang diagnostic ignored "-Wobjc-designated-initializers"
86 - (id)initWithFrame:(NSRect)frame { 86 - (id)initWithFrame:(NSRect)frame {
87 // This class is not for instantiating. 87 // This class is not for instantiating.
88 [self doesNotRecognizeSelector:_cmd]; 88 [self doesNotRecognizeSelector:_cmd];
89 return nil; 89 return nil;
90 } 90 }
91 91
92 - (id)initWithCoder:(NSCoder*)coder { 92 - (id)initWithCoder:(NSCoder*)coder {
93 // This class is not for instantiating. 93 // This class is not for instantiating.
94 [self doesNotRecognizeSelector:_cmd]; 94 [self doesNotRecognizeSelector:_cmd];
95 return nil; 95 return nil;
96 } 96 }
97 #pragma clang diagnostic pop
98 97
99 // Override to move the fullscreen button to the left of the profile avatar. 98 // Override to move the fullscreen button to the left of the profile avatar.
100 - (NSPoint)_fullScreenButtonOrigin { 99 - (NSPoint)_fullScreenButtonOrigin {
101 NSWindow* window = [self window]; 100 NSWindow* window = [self window];
102 NSPoint offset = NSZeroPoint; 101 NSPoint offset = NSZeroPoint;
103 102
104 if ([window respondsToSelector:@selector(fullScreenButtonOriginAdjustment)]) 103 if ([window respondsToSelector:@selector(fullScreenButtonOriginAdjustment)])
105 offset = [window fullScreenButtonOriginAdjustment]; 104 offset = [window fullScreenButtonOriginAdjustment];
106 105
107 NSPoint origin = [self _fullScreenButtonOriginOriginal]; 106 NSPoint origin = [self _fullScreenButtonOriginOriginal];
108 origin.x += offset.x; 107 origin.x += offset.x;
109 origin.y += offset.y; 108 origin.y += offset.y;
110 return origin; 109 return origin;
111 } 110 }
112 111
113 @end 112 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698