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()); |