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

Unified Diff: chrome/browser/extensions/api/debugger/debugger_api.cc

Issue 2263843002: DevTools: merge devtools target with devtools host, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for review Created 4 years, 4 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/extensions/api/debugger/debugger_api.cc
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc
index 36e39db94f9c451beb14de78684fe0db2e672fd5..fb488acc5fe9fc4a29e1725ca65c33f6e205f385 100644
--- a/chrome/browser/extensions/api/debugger/debugger_api.cc
+++ b/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -673,33 +673,28 @@ const char kTargetTitleField[] = "title";
const char kTargetAttachedField[] = "attached";
const char kTargetUrlField[] = "url";
const char kTargetFaviconUrlField[] = "faviconUrl";
-const char kTargetTypePage[] = "page";
-const char kTargetTypeBackgroundPage[] = "background_page";
-const char kTargetTypeWorker[] = "worker";
-const char kTargetTypeOther[] = "other";
const char kTargetTabIdField[] = "tabId";
const char kTargetExtensionIdField[] = "extensionId";
base::Value* SerializeTarget(const DevToolsTargetImpl& target) {
base::DictionaryValue* dictionary = new base::DictionaryValue();
-
- dictionary->SetString(kTargetIdField, target.GetId());
- dictionary->SetString(kTargetTitleField, target.GetTitle());
- dictionary->SetBoolean(kTargetAttachedField, target.IsAttached());
- dictionary->SetString(kTargetUrlField, target.GetURL().spec());
-
- std::string type = target.GetType();
- if (type == kTargetTypePage) {
- dictionary->SetInteger(kTargetTabIdField, target.GetTabId());
- } else if (type == kTargetTypeBackgroundPage) {
- dictionary->SetString(kTargetExtensionIdField, target.GetExtensionId());
- } else if (type != kTargetTypeWorker) {
- // DevToolsTargetImpl may support more types than the debugger API.
- type = kTargetTypeOther;
+ scoped_refptr<DevToolsAgentHost> host = target.GetAgentHost();
+ dictionary->SetString(kTargetIdField, host->GetId());
+ dictionary->SetString(kTargetTitleField, host->GetTitle());
+ dictionary->SetBoolean(kTargetAttachedField, host->IsAttached());
+ dictionary->SetString(kTargetUrlField, host->GetURL().spec());
+
+ std::string type = host->GetType();
+ if (type == DevToolsAgentHost::kTypePage) {
+ int tab_id =
+ extensions::ExtensionTabUtil::GetTabId(host->GetWebContents());
+ dictionary->SetInteger(kTargetTabIdField, tab_id);
+ } else if (type == "background_page") {
+ dictionary->SetString(kTargetExtensionIdField, host->GetURL().host());
}
dictionary->SetString(kTargetTypeField, type);
- GURL favicon_url = target.GetFaviconURL();
+ GURL favicon_url = host->GetFaviconURL();
if (favicon_url.is_valid())
dictionary->SetString(kTargetFaviconUrlField, favicon_url.spec());

Powered by Google App Engine
This is Rietveld 408576698