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/extensions/extension_popup_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "chrome/browser/devtools/devtools_window.h" | 10 #include "chrome/browser/devtools/devtools_window.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) { | 41 CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) { |
42 return std::max(min, std::min(max, value)); | 42 return std::max(min, std::min(max, value)); |
43 } | 43 } |
44 | 44 |
45 } // namespace | 45 } // namespace |
46 | 46 |
47 @interface ExtensionPopupController (Private) | 47 @interface ExtensionPopupController (Private) |
48 // Callers should be using the public static method for initialization. | 48 // Callers should be using the public static method for initialization. |
49 - (id)initWithParentWindow:(NSWindow*)parentWindow | 49 - (id)initWithParentWindow:(NSWindow*)parentWindow |
50 anchoredAt:(NSPoint)anchoredAt | 50 anchoredAt:(NSPoint)anchoredAt |
51 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation | 51 arrowLocation:(views::BubbleBorder::Arrow)arrowLocation |
52 devMode:(BOOL)devMode; | 52 devMode:(BOOL)devMode; |
53 | 53 |
54 // Set the ExtensionViewHost, taking ownership. | 54 // Set the ExtensionViewHost, taking ownership. |
55 - (void)setExtensionViewHost:(scoped_ptr<ExtensionViewHost>)host; | 55 - (void)setExtensionViewHost:(scoped_ptr<ExtensionViewHost>)host; |
56 | 56 |
57 // Called when the extension's hosted NSView has been resized. | 57 // Called when the extension's hosted NSView has been resized. |
58 - (void)extensionViewFrameChanged; | 58 - (void)extensionViewFrameChanged; |
59 | 59 |
60 // Called when the extension's size changes. | 60 // Called when the extension's size changes. |
61 - (void)onSizeChanged:(NSSize)newSize; | 61 - (void)onSizeChanged:(NSSize)newSize; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 DISALLOW_COPY_AND_ASSIGN(ExtensionPopupNotificationBridge); | 156 DISALLOW_COPY_AND_ASSIGN(ExtensionPopupNotificationBridge); |
157 }; | 157 }; |
158 | 158 |
159 @implementation ExtensionPopupController | 159 @implementation ExtensionPopupController |
160 | 160 |
161 @synthesize extensionId = extensionId_; | 161 @synthesize extensionId = extensionId_; |
162 | 162 |
163 - (id)initWithParentWindow:(NSWindow*)parentWindow | 163 - (id)initWithParentWindow:(NSWindow*)parentWindow |
164 anchoredAt:(NSPoint)anchoredAt | 164 anchoredAt:(NSPoint)anchoredAt |
165 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation | 165 arrowLocation:(views::BubbleBorder::Arrow)arrowLocation |
166 devMode:(BOOL)devMode { | 166 devMode:(BOOL)devMode { |
167 base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc] | 167 base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc] |
168 initWithContentRect:ui::kWindowSizeDeterminedLater | 168 initWithContentRect:ui::kWindowSizeDeterminedLater |
169 styleMask:NSBorderlessWindowMask | 169 styleMask:NSBorderlessWindowMask |
170 backing:NSBackingStoreBuffered | 170 backing:NSBackingStoreBuffered |
171 defer:YES]); | 171 defer:YES]); |
172 if (!window.get()) | 172 if (!window.get()) |
173 return nil; | 173 return nil; |
174 | 174 |
175 anchoredAt = [parentWindow convertBaseToScreen:anchoredAt]; | 175 anchoredAt = [parentWindow convertBaseToScreen:anchoredAt]; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 return host_.get(); | 248 return host_.get(); |
249 } | 249 } |
250 | 250 |
251 - (void)setBeingInspected:(BOOL)beingInspected { | 251 - (void)setBeingInspected:(BOOL)beingInspected { |
252 beingInspected_ = beingInspected; | 252 beingInspected_ = beingInspected; |
253 } | 253 } |
254 | 254 |
255 + (ExtensionPopupController*)host:(scoped_ptr<ExtensionViewHost>)host | 255 + (ExtensionPopupController*)host:(scoped_ptr<ExtensionViewHost>)host |
256 inBrowser:(Browser*)browser | 256 inBrowser:(Browser*)browser |
257 anchoredAt:(NSPoint)anchoredAt | 257 anchoredAt:(NSPoint)anchoredAt |
258 arrowLocation:(info_bubble::BubbleArrowLocation) | 258 arrowLocation:(views::BubbleBorder::Arrow)arrowLocation |
259 arrowLocation | |
260 devMode:(BOOL)devMode { | 259 devMode:(BOOL)devMode { |
261 DCHECK([NSThread isMainThread]); | 260 DCHECK([NSThread isMainThread]); |
262 DCHECK(browser); | 261 DCHECK(browser); |
263 DCHECK(host); | 262 DCHECK(host); |
264 | 263 |
265 if (gPopup) | 264 if (gPopup) |
266 [gPopup close]; // Starts the animation to fade out the popup. | 265 [gPopup close]; // Starts the animation to fade out the popup. |
267 | 266 |
268 // Create the popup first. This establishes an initially hidden NSWindow so | 267 // Create the popup first. This establishes an initially hidden NSWindow so |
269 // that the renderer is able to gather correct screen metrics for the initial | 268 // that the renderer is able to gather correct screen metrics for the initial |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 return minSize; | 432 return minSize; |
434 } | 433 } |
435 | 434 |
436 // Private (TestingAPI) | 435 // Private (TestingAPI) |
437 + (NSSize)maxPopupSize { | 436 + (NSSize)maxPopupSize { |
438 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 437 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
439 return maxSize; | 438 return maxSize; |
440 } | 439 } |
441 | 440 |
442 @end | 441 @end |
OLD | NEW |