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