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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm

Issue 10824030: Move ExtensionHost into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 years, 4 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
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/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 "chrome/browser/debugger/devtools_window.h" 9 #include "chrome/browser/debugger/devtools_window.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
(...skipping 22 matching lines...) Expand all
33 // Given a value and a rage, clamp the value into the range. 33 // Given a value and a rage, clamp the value into the range.
34 CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) { 34 CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) {
35 return std::max(min, std::min(max, value)); 35 return std::max(min, std::min(max, value));
36 } 36 }
37 37
38 } // namespace 38 } // namespace
39 39
40 @interface ExtensionPopupController (Private) 40 @interface ExtensionPopupController (Private)
41 // Callers should be using the public static method for initialization. 41 // Callers should be using the public static method for initialization.
42 // NOTE: This takes ownership of |host|. 42 // NOTE: This takes ownership of |host|.
43 - (id)initWithHost:(ExtensionHost*)host 43 - (id)initWithHost:(extensions::ExtensionHost*)host
44 parentWindow:(NSWindow*)parentWindow 44 parentWindow:(NSWindow*)parentWindow
45 anchoredAt:(NSPoint)anchoredAt 45 anchoredAt:(NSPoint)anchoredAt
46 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation 46 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation
47 devMode:(BOOL)devMode; 47 devMode:(BOOL)devMode;
48 48
49 // Called when the extension's hosted NSView has been resized. 49 // Called when the extension's hosted NSView has been resized.
50 - (void)extensionViewFrameChanged; 50 - (void)extensionViewFrameChanged;
51 51
52 // Called when the extension's size changes. 52 // Called when the extension's size changes.
53 - (void)onSizeChanged:(NSSize)newSize; 53 - (void)onSizeChanged:(NSSize)newSize;
(...skipping 26 matching lines...) Expand all
80 class DevtoolsNotificationBridge : public content::NotificationObserver { 80 class DevtoolsNotificationBridge : public content::NotificationObserver {
81 public: 81 public:
82 explicit DevtoolsNotificationBridge(ExtensionPopupController* controller) 82 explicit DevtoolsNotificationBridge(ExtensionPopupController* controller)
83 : controller_(controller) {} 83 : controller_(controller) {}
84 84
85 void Observe(int type, 85 void Observe(int type,
86 const content::NotificationSource& source, 86 const content::NotificationSource& source,
87 const content::NotificationDetails& details) { 87 const content::NotificationDetails& details) {
88 switch (type) { 88 switch (type) {
89 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { 89 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: {
90 if (content::Details<ExtensionHost>([controller_ extensionHost]) == 90 if (content::Details<extensions::ExtensionHost>(
91 details) { 91 [controller_ extensionHost]) == details) {
92 [controller_ showDevTools]; 92 [controller_ showDevTools];
93 } 93 }
94 break; 94 break;
95 } 95 }
96 case content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING: { 96 case content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING: {
97 RenderViewHost* rvh = [controller_ extensionHost]->render_view_host(); 97 RenderViewHost* rvh = [controller_ extensionHost]->render_view_host();
98 if (content::Details<RenderViewHost>(rvh) == details) 98 if (content::Details<RenderViewHost>(rvh) == details)
99 // Set the flag on the controller so the popup is not hidden when 99 // Set the flag on the controller so the popup is not hidden when
100 // the dev tools get focus. 100 // the dev tools get focus.
101 [controller_ setBeingInspected:YES]; 101 [controller_ setBeingInspected:YES];
(...skipping 14 matching lines...) Expand all
116 } 116 }
117 }; 117 };
118 } 118 }
119 119
120 private: 120 private:
121 ExtensionPopupController* controller_; 121 ExtensionPopupController* controller_;
122 }; 122 };
123 123
124 @implementation ExtensionPopupController 124 @implementation ExtensionPopupController
125 125
126 - (id)initWithHost:(ExtensionHost*)host 126 - (id)initWithHost:(extensions::ExtensionHost*)host
127 parentWindow:(NSWindow*)parentWindow 127 parentWindow:(NSWindow*)parentWindow
128 anchoredAt:(NSPoint)anchoredAt 128 anchoredAt:(NSPoint)anchoredAt
129 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation 129 arrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation
130 devMode:(BOOL)devMode { 130 devMode:(BOOL)devMode {
131 scoped_nsobject<InfoBubbleWindow> window( 131 scoped_nsobject<InfoBubbleWindow> window(
132 [[InfoBubbleWindow alloc] 132 [[InfoBubbleWindow alloc]
133 initWithContentRect:ui::kWindowSizeDeterminedLater 133 initWithContentRect:ui::kWindowSizeDeterminedLater
134 styleMask:NSBorderlessWindowMask 134 styleMask:NSBorderlessWindowMask
135 backing:NSBackingStoreBuffered 135 backing:NSBackingStoreBuffered
136 defer:YES]); 136 defer:YES]);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 - (void)windowDidResignKey:(NSNotification*)notification { 204 - (void)windowDidResignKey:(NSNotification*)notification {
205 if (!beingInspected_) 205 if (!beingInspected_)
206 [super windowDidResignKey:notification]; 206 [super windowDidResignKey:notification];
207 } 207 }
208 208
209 - (BOOL)isClosing { 209 - (BOOL)isClosing {
210 return [static_cast<InfoBubbleWindow*>([self window]) isClosing]; 210 return [static_cast<InfoBubbleWindow*>([self window]) isClosing];
211 } 211 }
212 212
213 - (ExtensionHost*)extensionHost { 213 - (extensions::ExtensionHost*)extensionHost {
214 return host_.get(); 214 return host_.get();
215 } 215 }
216 216
217 - (void)setBeingInspected:(BOOL)beingInspected { 217 - (void)setBeingInspected:(BOOL)beingInspected {
218 beingInspected_ = beingInspected; 218 beingInspected_ = beingInspected;
219 } 219 }
220 220
221 + (ExtensionPopupController*)showURL:(GURL)url 221 + (ExtensionPopupController*)showURL:(GURL)url
222 inBrowser:(Browser*)browser 222 inBrowser:(Browser*)browser
223 anchoredAt:(NSPoint)anchoredAt 223 anchoredAt:(NSPoint)anchoredAt
224 arrowLocation:(info_bubble::BubbleArrowLocation) 224 arrowLocation:(info_bubble::BubbleArrowLocation)
225 arrowLocation 225 arrowLocation
226 devMode:(BOOL)devMode { 226 devMode:(BOOL)devMode {
227 DCHECK([NSThread isMainThread]); 227 DCHECK([NSThread isMainThread]);
228 DCHECK(browser); 228 DCHECK(browser);
229 if (!browser) 229 if (!browser)
230 return nil; 230 return nil;
231 231
232 ExtensionProcessManager* manager = 232 ExtensionProcessManager* manager =
233 browser->profile()->GetExtensionProcessManager(); 233 browser->profile()->GetExtensionProcessManager();
234 DCHECK(manager); 234 DCHECK(manager);
235 if (!manager) 235 if (!manager)
236 return nil; 236 return nil;
237 237
238 ExtensionHost* host = manager->CreatePopupHost(url, browser); 238 extensions::ExtensionHost* host = manager->CreatePopupHost(url, browser);
239 DCHECK(host); 239 DCHECK(host);
240 if (!host) 240 if (!host)
241 return nil; 241 return nil;
242 242
243 // Make absolutely sure that no popups are leaked. 243 // Make absolutely sure that no popups are leaked.
244 if (gPopup) { 244 if (gPopup) {
245 if ([[gPopup window] isVisible]) 245 if ([[gPopup window] isVisible])
246 [gPopup close]; 246 [gPopup close];
247 247
248 [gPopup autorelease]; 248 [gPopup autorelease];
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return minSize; 370 return minSize;
371 } 371 }
372 372
373 // Private (TestingAPI) 373 // Private (TestingAPI)
374 + (NSSize)maxPopupSize { 374 + (NSSize)maxPopupSize {
375 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; 375 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight};
376 return maxSize; 376 return maxSize;
377 } 377 }
378 378
379 @end 379 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698