| 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 "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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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<extensions::ExtensionHost>( | 90 if (content::Details<extensions::ExtensionHost>( |
| 91 [controller_ extensionHost]) == 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_AGENT_ATTACHED: { |
| 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]; |
| 102 break; | 102 break; |
| 103 } | 103 } |
| 104 case content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING: { | 104 case content::NOTIFICATION_DEVTOOLS_AGENT_DETACHED: { |
| 105 RenderViewHost* rvh = [controller_ extensionHost]->render_view_host(); | 105 RenderViewHost* rvh = [controller_ extensionHost]->render_view_host(); |
| 106 if (content::Details<RenderViewHost>(rvh) == details) | 106 if (content::Details<RenderViewHost>(rvh) == details) |
| 107 // Allow the devtools to finish detaching before we close the popup | 107 // Allow the devtools to finish detaching before we close the popup |
| 108 [controller_ performSelector:@selector(close) | 108 [controller_ performSelector:@selector(close) |
| 109 withObject:nil | 109 withObject:nil |
| 110 afterDelay:0.0]; | 110 afterDelay:0.0]; |
| 111 break; | 111 break; |
| 112 } | 112 } |
| 113 default: { | 113 default: { |
| 114 NOTREACHED() << "Received unexpected notification"; | 114 NOTREACHED() << "Received unexpected notification"; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 name:NSViewFrameDidChangeNotification | 157 name:NSViewFrameDidChangeNotification |
| 158 object:extensionView_]; | 158 object:extensionView_]; |
| 159 | 159 |
| 160 [view addSubview:extensionView_]; | 160 [view addSubview:extensionView_]; |
| 161 | 161 |
| 162 notificationBridge_.reset(new DevtoolsNotificationBridge(self)); | 162 notificationBridge_.reset(new DevtoolsNotificationBridge(self)); |
| 163 registrar_.reset(new content::NotificationRegistrar); | 163 registrar_.reset(new content::NotificationRegistrar); |
| 164 // Listen for the the devtools window closing so we can close this window if | 164 // Listen for the the devtools window closing so we can close this window if |
| 165 // it is being inspected and the inspector is closed. | 165 // it is being inspected and the inspector is closed. |
| 166 registrar_->Add(notificationBridge_.get(), | 166 registrar_->Add(notificationBridge_.get(), |
| 167 content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, | 167 content::NOTIFICATION_DEVTOOLS_AGENT_DETACHED, |
| 168 content::Source<content::BrowserContext>( | 168 content::Source<content::BrowserContext>( |
| 169 host->profile())); | 169 host->profile())); |
| 170 if (beingInspected_) { | 170 if (beingInspected_) { |
| 171 // Listen for the extension to finish loading so the dev tools can be | 171 // Listen for the extension to finish loading so the dev tools can be |
| 172 // opened. | 172 // opened. |
| 173 registrar_->Add(notificationBridge_.get(), | 173 registrar_->Add(notificationBridge_.get(), |
| 174 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 174 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 175 content::Source<Profile>(host->profile())); | 175 content::Source<Profile>(host->profile())); |
| 176 } else { | 176 } else { |
| 177 // Listen for the dev tools opening on this popup, so we can stop it going | 177 // Listen for the dev tools opening on this popup, so we can stop it going |
| 178 // away when the dev tools get focus. | 178 // away when the dev tools get focus. |
| 179 registrar_->Add(notificationBridge_.get(), | 179 registrar_->Add(notificationBridge_.get(), |
| 180 content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING, | 180 content::NOTIFICATION_DEVTOOLS_AGENT_ATTACHED, |
| 181 content::Source<content::BrowserContext>( | 181 content::Source<content::BrowserContext>( |
| 182 host->profile())); | 182 host->profile())); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 return self; | 185 return self; |
| 186 } | 186 } |
| 187 | 187 |
| 188 - (void)dealloc { | 188 - (void)dealloc { |
| 189 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 189 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 190 [super dealloc]; | 190 [super dealloc]; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |