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

Unified Diff: chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm

Issue 2419943002: [DevTools] Migrate from AgentStateCallbacks to DevToolsAgentHostObserver. (Closed)
Patch Set: mac Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm
diff --git a/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm
index 08c83c2e6b98849925e5201a341c84758844cf36..3cc5352f0220c4aa9f061af83f05ce6d1124f0fe 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm
@@ -20,6 +20,7 @@
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/devtools_agent_host.h"
+#include "content/public/browser/devtools_agent_host_observer.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "extensions/browser/notification_types.h"
@@ -90,38 +91,39 @@ class ExtensionPopupContainer : public ExtensionViewMac::Container {
ExtensionPopupController* controller_; // Weak; owns this.
};
-class ExtensionPopupNotificationBridge : public content::NotificationObserver {
+class ExtensionPopupNotificationBridge :
+ public content::NotificationObserver,
+ public content::DevToolsAgentHostObserver {
public:
ExtensionPopupNotificationBridge(ExtensionPopupController* controller,
ExtensionViewHost* view_host)
: controller_(controller),
view_host_(view_host),
- web_contents_(view_host_->host_contents()),
- devtools_callback_(base::Bind(
- &ExtensionPopupNotificationBridge::OnDevToolsStateChanged,
- base::Unretained(this))) {
- content::DevToolsAgentHost::AddAgentStateCallback(devtools_callback_);
+ web_contents_(view_host_->host_contents()) {
+ content::DevToolsAgentHost::AddObserver(this);
}
~ExtensionPopupNotificationBridge() override {
- content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_);
+ content::DevToolsAgentHost::RemoveObserver(this);
}
- void OnDevToolsStateChanged(content::DevToolsAgentHost* agent_host,
- bool attached) {
+ void DevToolsAgentHostAttached(
+ content::DevToolsAgentHost* agent_host) override {
if (agent_host->GetWebContents() != web_contents_)
return;
+ // Set the flag on the controller so the popup is not hidden when
+ // the dev tools get focus.
+ [controller_ setBeingInspected:YES];
+ }
- if (attached) {
- // Set the flag on the controller so the popup is not hidden when
- // the dev tools get focus.
- [controller_ setBeingInspected:YES];
- } else {
- // Allow the devtools to finish detaching before we close the popup.
- [controller_ performSelector:@selector(close)
- withObject:nil
- afterDelay:0.0];
- }
+ void DevToolsAgentHostDetached(
+ content::DevToolsAgentHost* agent_host) override {
+ if (agent_host->GetWebContents() != web_contents_)
+ return;
+ // Allow the devtools to finish detaching before we close the popup.
+ [controller_ performSelector:@selector(close)
+ withObject:nil
+ afterDelay:0.0];
}
void Observe(int type,
@@ -153,7 +155,6 @@ class ExtensionPopupNotificationBridge : public content::NotificationObserver {
// know what it is for notifications, but our ExtensionViewHost may not be
// valid.
WebContents* web_contents_;
- base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
DISALLOW_COPY_AND_ASSIGN(ExtensionPopupNotificationBridge);
};
« no previous file with comments | « chrome/browser/devtools/chrome_devtools_manager_delegate.cc ('k') | chrome/browser/ui/views/extensions/extension_popup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698