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

Unified Diff: extensions/browser/app_window/app_window_registry.cc

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
« no previous file with comments | « extensions/browser/app_window/app_window_registry.h ('k') | extensions/browser/process_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/app_window/app_window_registry.cc
diff --git a/extensions/browser/app_window/app_window_registry.cc b/extensions/browser/app_window/app_window_registry.cc
index 6fc0dedccfabd7cb140f09bdbd72a3a79e94435e..b9c9f1d10cfbf17835ae98572ba808812caf2037 100644
--- a/extensions/browser/app_window/app_window_registry.cc
+++ b/extensions/browser/app_window/app_window_registry.cc
@@ -45,14 +45,12 @@ AppWindowRegistry::Observer::~Observer() {
}
AppWindowRegistry::AppWindowRegistry(content::BrowserContext* context)
- : context_(context),
- devtools_callback_(base::Bind(&AppWindowRegistry::OnDevToolsStateChanged,
- base::Unretained(this))) {
- content::DevToolsAgentHost::AddAgentStateCallback(devtools_callback_);
+ : context_(context) {
+ content::DevToolsAgentHost::AddObserver(this);
}
AppWindowRegistry::~AppWindowRegistry() {
- content::DevToolsAgentHost::RemoveAgentStateCallback(devtools_callback_);
+ content::DevToolsAgentHost::RemoveObserver(this);
}
// static
@@ -180,21 +178,17 @@ bool AppWindowRegistry::HadDevToolsAttached(
return key.empty() ? false : inspected_windows_.count(key) != 0;
}
-void AppWindowRegistry::OnDevToolsStateChanged(
- content::DevToolsAgentHost* agent_host,
- bool attached) {
- content::WebContents* web_contents = agent_host->GetWebContents();
- // Ignore unrelated notifications.
- if (!web_contents || web_contents->GetBrowserContext() != context_)
- return;
-
- std::string key = GetWindowKeyForWebContents(web_contents);
- if (key.empty())
- return;
-
- if (attached)
+void AppWindowRegistry::DevToolsAgentHostAttached(
+ content::DevToolsAgentHost* agent_host) {
+ std::string key = GetWindowKeyForAgentHost(agent_host);
+ if (!key.empty())
inspected_windows_.insert(key);
- else
+}
+
+void AppWindowRegistry::DevToolsAgentHostDetached(
+ content::DevToolsAgentHost* agent_host) {
+ std::string key = GetWindowKeyForAgentHost(agent_host);
+ if (!key.empty())
inspected_windows_.erase(key);
}
@@ -214,6 +208,14 @@ void AppWindowRegistry::BringToFront(AppWindow* app_window) {
app_windows_.push_front(app_window);
}
+std::string AppWindowRegistry::GetWindowKeyForAgentHost(
+ content::DevToolsAgentHost* agent_host) const {
+ content::WebContents* web_contents = agent_host->GetWebContents();
+ if (!web_contents || web_contents->GetBrowserContext() != context_)
+ return std::string();
+ return GetWindowKeyForWebContents(web_contents);
+}
+
std::string AppWindowRegistry::GetWindowKeyForWebContents(
content::WebContents* web_contents) const {
AppWindow* app_window = GetAppWindowForWebContents(web_contents);
« no previous file with comments | « extensions/browser/app_window/app_window_registry.h ('k') | extensions/browser/process_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698