| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 54 | 54 |
| 55 // Called when the extension view is shown. | 55 // Called when the extension view is shown. |
| 56 - (void)onViewDidShow; | 56 - (void)onViewDidShow; |
| 57 @end | 57 @end |
| 58 | 58 |
| 59 class ExtensionPopupContainer : public ExtensionViewMac::Container { | 59 class ExtensionPopupContainer : public ExtensionViewContainer { |
| 60 public: | 60 public: |
| 61 explicit ExtensionPopupContainer(ExtensionPopupController* controller) | 61 explicit ExtensionPopupContainer(ExtensionPopupController* controller) |
| 62 : controller_(controller) { | 62 : controller_(controller) { |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void OnExtensionSizeChanged( | 65 virtual void OnExtensionSizeChanged(ExtensionView* view, |
| 66 ExtensionViewMac* view, | 66 const gfx::Size& new_size) OVERRIDE { |
| 67 const gfx::Size& new_size) OVERRIDE { | |
| 68 [controller_ onSizeChanged: | 67 [controller_ onSizeChanged: |
| 69 NSMakeSize(new_size.width(), new_size.height())]; | 68 NSMakeSize(new_size.width(), new_size.height())]; |
| 70 } | 69 } |
| 71 | 70 |
| 72 virtual void OnExtensionViewDidShow(ExtensionViewMac* view) OVERRIDE { | 71 virtual void OnExtensionViewDidShow(ExtensionView* view) OVERRIDE { |
| 73 [controller_ onViewDidShow]; | 72 [controller_ onViewDidShow]; |
| 74 } | 73 } |
| 75 | 74 |
| 76 private: | 75 private: |
| 77 ExtensionPopupController* controller_; // Weak; owns this. | 76 ExtensionPopupController* controller_; // Weak; owns this. |
| 78 }; | 77 }; |
| 79 | 78 |
| 80 class DevtoolsNotificationBridge : public content::NotificationObserver { | 79 class DevtoolsNotificationBridge : public content::NotificationObserver { |
| 81 public: | 80 public: |
| 82 explicit DevtoolsNotificationBridge(ExtensionPopupController* controller) | 81 explicit DevtoolsNotificationBridge(ExtensionPopupController* controller) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 parentWindow:parentWindow | 141 parentWindow:parentWindow |
| 143 anchoredAt:anchoredAt])) { | 142 anchoredAt:anchoredAt])) { |
| 144 host_.reset(host); | 143 host_.reset(host); |
| 145 beingInspected_ = devMode; | 144 beingInspected_ = devMode; |
| 146 | 145 |
| 147 InfoBubbleView* view = self.bubble; | 146 InfoBubbleView* view = self.bubble; |
| 148 [view setArrowLocation:arrowLocation]; | 147 [view setArrowLocation:arrowLocation]; |
| 149 | 148 |
| 150 extensionView_ = host->view()->native_view(); | 149 extensionView_ = host->view()->native_view(); |
| 151 container_.reset(new ExtensionPopupContainer(self)); | 150 container_.reset(new ExtensionPopupContainer(self)); |
| 152 host->view()->set_container(container_.get()); | 151 host->view()->SetContainer(container_.get()); |
| 153 | 152 |
| 154 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 153 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 155 [center addObserver:self | 154 [center addObserver:self |
| 156 selector:@selector(extensionViewFrameChanged) | 155 selector:@selector(extensionViewFrameChanged) |
| 157 name:NSViewFrameDidChangeNotification | 156 name:NSViewFrameDidChangeNotification |
| 158 object:extensionView_]; | 157 object:extensionView_]; |
| 159 | 158 |
| 160 [view addSubview:extensionView_]; | 159 [view addSubview:extensionView_]; |
| 161 | 160 |
| 162 notificationBridge_.reset(new DevtoolsNotificationBridge(self)); | 161 notificationBridge_.reset(new DevtoolsNotificationBridge(self)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 191 } | 190 } |
| 192 | 191 |
| 193 - (void)showDevTools { | 192 - (void)showDevTools { |
| 194 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); | 193 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); |
| 195 } | 194 } |
| 196 | 195 |
| 197 - (void)windowWillClose:(NSNotification *)notification { | 196 - (void)windowWillClose:(NSNotification *)notification { |
| 198 [super windowWillClose:notification]; | 197 [super windowWillClose:notification]; |
| 199 gPopup = nil; | 198 gPopup = nil; |
| 200 if (host_->view()) | 199 if (host_->view()) |
| 201 host_->view()->set_container(NULL); | 200 host_->view()->SetContainer(NULL); |
| 202 } | 201 } |
| 203 | 202 |
| 204 - (void)windowDidResignKey:(NSNotification*)notification { | 203 - (void)windowDidResignKey:(NSNotification*)notification { |
| 205 if (!beingInspected_) | 204 if (!beingInspected_) |
| 206 [super windowDidResignKey:notification]; | 205 [super windowDidResignKey:notification]; |
| 207 } | 206 } |
| 208 | 207 |
| 209 - (BOOL)isClosing { | 208 - (BOOL)isClosing { |
| 210 return [static_cast<InfoBubbleWindow*>([self window]) isClosing]; | 209 return [static_cast<InfoBubbleWindow*>([self window]) isClosing]; |
| 211 } | 210 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 return minSize; | 369 return minSize; |
| 371 } | 370 } |
| 372 | 371 |
| 373 // Private (TestingAPI) | 372 // Private (TestingAPI) |
| 374 + (NSSize)maxPopupSize { | 373 + (NSSize)maxPopupSize { |
| 375 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 374 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
| 376 return maxSize; | 375 return maxSize; |
| 377 } | 376 } |
| 378 | 377 |
| 379 @end | 378 @end |
| OLD | NEW |