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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_process_manager.h" 10 #include "chrome/browser/extensions/extension_process_manager.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 13 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
14 #import "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" 14 #import "chrome/browser/ui/cocoa/extensions/extension_view_mac.h"
15 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 15 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
16 #include "chrome/common/chrome_notification_types.h"
16 #include "content/browser/debugger/devtools_window.h" 17 #include "content/browser/debugger/devtools_window.h"
17 #include "content/common/notification_details.h" 18 #include "content/common/notification_details.h"
18 #include "content/common/notification_registrar.h" 19 #include "content/common/notification_registrar.h"
19 #include "content/common/notification_source.h" 20 #include "content/common/notification_source.h"
20 21
21 namespace { 22 namespace {
22 // The duration for any animations that might be invoked by this controller. 23 // The duration for any animations that might be invoked by this controller.
23 const NSTimeInterval kAnimationDuration = 0.2; 24 const NSTimeInterval kAnimationDuration = 0.2;
24 25
25 // There should only be one extension popup showing at one time. Keep a 26 // There should only be one extension popup showing at one time. Keep a
26 // reference to it here. 27 // reference to it here.
27 static ExtensionPopupController* gPopup; 28 static ExtensionPopupController* gPopup;
28 29
29 // Given a value and a rage, clamp the value into the range. 30 // Given a value and a rage, clamp the value into the range.
30 CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) { 31 CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) {
31 return std::max(min, std::min(max, value)); 32 return std::max(min, std::min(max, value));
32 } 33 }
33 34
34 } // namespace 35 } // namespace
35 36
36 class DevtoolsNotificationBridge : public NotificationObserver { 37 class DevtoolsNotificationBridge : public NotificationObserver {
37 public: 38 public:
38 explicit DevtoolsNotificationBridge(ExtensionPopupController* controller) 39 explicit DevtoolsNotificationBridge(ExtensionPopupController* controller)
39 : controller_(controller) {} 40 : controller_(controller) {}
40 41
41 void Observe(NotificationType type, 42 void Observe(int type,
42 const NotificationSource& source, 43 const NotificationSource& source,
43 const NotificationDetails& details) { 44 const NotificationDetails& details) {
44 switch (type.value) { 45 switch (type) {
45 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: { 46 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: {
46 if (Details<ExtensionHost>([controller_ extensionHost]) == details) 47 if (Details<ExtensionHost>([controller_ extensionHost]) == details)
47 [controller_ showDevTools]; 48 [controller_ showDevTools];
48 break; 49 break;
49 } 50 }
50 case NotificationType::DEVTOOLS_WINDOW_CLOSING: { 51 case content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING: {
51 RenderViewHost* rvh = [controller_ extensionHost]->render_view_host(); 52 RenderViewHost* rvh = [controller_ extensionHost]->render_view_host();
52 if (Details<RenderViewHost>(rvh) == details) 53 if (Details<RenderViewHost>(rvh) == details)
53 // Allow the devtools to finish detaching before we close the popup 54 // Allow the devtools to finish detaching before we close the popup
54 [controller_ performSelector:@selector(close) 55 [controller_ performSelector:@selector(close)
55 withObject:nil 56 withObject:nil
56 afterDelay:0.0]; 57 afterDelay:0.0];
57 break; 58 break;
58 } 59 }
59 default: { 60 default: {
60 NOTREACHED() << "Received unexpected notification"; 61 NOTREACHED() << "Received unexpected notification";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return nil; 125 return nil;
125 126
126 [window setDelegate:self]; 127 [window setDelegate:self];
127 [window setContentView:view]; 128 [window setContentView:view];
128 self = [super initWithWindow:window]; 129 self = [super initWithWindow:window];
129 if (beingInspected_) { 130 if (beingInspected_) {
130 // Listen for the the devtools window closing. 131 // Listen for the the devtools window closing.
131 notificationBridge_.reset(new DevtoolsNotificationBridge(self)); 132 notificationBridge_.reset(new DevtoolsNotificationBridge(self));
132 registrar_.reset(new NotificationRegistrar); 133 registrar_.reset(new NotificationRegistrar);
133 registrar_->Add(notificationBridge_.get(), 134 registrar_->Add(notificationBridge_.get(),
134 NotificationType::DEVTOOLS_WINDOW_CLOSING, 135 chrome::DEVTOOLS_WINDOW_CLOSING,
135 Source<Profile>(host->profile())); 136 Source<Profile>(host->profile()));
136 registrar_->Add(notificationBridge_.get(), 137 registrar_->Add(notificationBridge_.get(),
137 NotificationType::EXTENSION_HOST_DID_STOP_LOADING, 138 chrome::EXTENSION_HOST_DID_STOP_LOADING,
138 Source<Profile>(host->profile())); 139 Source<Profile>(host->profile()));
139 } 140 }
140 return self; 141 return self;
141 } 142 }
142 143
143 - (void)showDevTools { 144 - (void)showDevTools {
144 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); 145 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host());
145 } 146 }
146 147
147 - (void)dealloc { 148 - (void)dealloc {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return minSize; 330 return minSize;
330 } 331 }
331 332
332 // Private (TestingAPI) 333 // Private (TestingAPI)
333 + (NSSize)maxPopupSize { 334 + (NSSize)maxPopupSize {
334 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; 335 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight};
335 return maxSize; 336 return maxSize;
336 } 337 }
337 338
338 @end 339 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698