| 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/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
| 12 #include "chrome/browser/extensions/extension_view_host.h" | 12 #include "chrome/browser/extensions/extension_view_host.h" |
| 13 #include "chrome/browser/extensions/extension_view_host_factory.h" | 13 #include "chrome/browser/extensions/extension_view_host_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
| 18 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 18 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 19 #import "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 19 #import "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
| 20 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 20 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 21 #include "components/web_modal/popup_manager.h" | 21 #include "components/web_modal/popup_manager.h" |
| 22 #include "content/public/browser/devtools_agent_host.h" | 22 #include "content/public/browser/devtools_agent_host.h" |
| 23 #include "content/public/browser/devtools_manager.h" | |
| 24 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 25 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 26 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 27 #include "ui/base/cocoa/window_size_constants.h" | 26 #include "ui/base/cocoa/window_size_constants.h" |
| 28 | 27 |
| 29 using content::BrowserContext; | 28 using content::BrowserContext; |
| 30 using content::RenderViewHost; | 29 using content::RenderViewHost; |
| 31 using content::WebContents; | 30 using content::WebContents; |
| 32 | 31 |
| 33 namespace { | 32 namespace { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 class DevtoolsNotificationBridge : public content::NotificationObserver { | 91 class DevtoolsNotificationBridge : public content::NotificationObserver { |
| 93 public: | 92 public: |
| 94 explicit DevtoolsNotificationBridge(ExtensionPopupController* controller) | 93 explicit DevtoolsNotificationBridge(ExtensionPopupController* controller) |
| 95 : controller_(controller), | 94 : controller_(controller), |
| 96 web_contents_([controller_ extensionViewHost]->host_contents()), | 95 web_contents_([controller_ extensionViewHost]->host_contents()), |
| 97 devtools_callback_(base::Bind( | 96 devtools_callback_(base::Bind( |
| 98 &DevtoolsNotificationBridge::OnDevToolsStateChanged, | 97 &DevtoolsNotificationBridge::OnDevToolsStateChanged, |
| 99 base::Unretained(this))) { | 98 base::Unretained(this))) { |
| 100 content::DevToolsManager::GetInstance()->AddAgentStateCallback( | 99 content::DevToolsAgentHost::AddAgentStateCallback(devtools_callback_); |
| 101 devtools_callback_); | |
| 102 } | 100 } |
| 103 | 101 |
| 104 virtual ~DevtoolsNotificationBridge() { | 102 virtual ~DevtoolsNotificationBridge() { |
| 105 content::DevToolsManager::GetInstance()->RemoveAgentStateCallback( | 103 content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_); |
| 106 devtools_callback_); | |
| 107 } | 104 } |
| 108 | 105 |
| 109 void OnDevToolsStateChanged(content::DevToolsAgentHost* agent_host, | 106 void OnDevToolsStateChanged(content::DevToolsAgentHost* agent_host, |
| 110 bool attached) { | 107 bool attached) { |
| 111 if (agent_host->GetWebContents() != web_contents_) | 108 if (agent_host->GetWebContents() != web_contents_) |
| 112 return; | 109 return; |
| 113 | 110 |
| 114 if (attached) { | 111 if (attached) { |
| 115 // Set the flag on the controller so the popup is not hidden when | 112 // Set the flag on the controller so the popup is not hidden when |
| 116 // the dev tools get focus. | 113 // the dev tools get focus. |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 return minSize; | 429 return minSize; |
| 433 } | 430 } |
| 434 | 431 |
| 435 // Private (TestingAPI) | 432 // Private (TestingAPI) |
| 436 + (NSSize)maxPopupSize { | 433 + (NSSize)maxPopupSize { |
| 437 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; | 434 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; |
| 438 return maxSize; | 435 return maxSize; |
| 439 } | 436 } |
| 440 | 437 |
| 441 @end | 438 @end |
| OLD | NEW |