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 77ba8cd473a0b31d26af9d4826ea225b98d2e7af..bb900fc0518bbd0a7b4bf6a2c6647fe51df65d98 100644 |
--- a/chrome/browser/extensions/api/debugger/debugger_api.cc |
+++ b/chrome/browser/extensions/api/debugger/debugger_api.cc |
@@ -11,6 +11,7 @@ |
#include "base/json/json_reader.h" |
#include "base/json/json_writer.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/memory/singleton.h" |
#include "base/string_number_conversions.h" |
#include "base/utf_string_conversions.h" |
@@ -25,6 +26,7 @@ |
#include "chrome/browser/ui/tab_contents/tab_contents.h" |
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
#include "chrome/common/chrome_notification_types.h" |
+#include "chrome/common/extensions/api/debugger.h" |
#include "chrome/common/extensions/extension.h" |
#include "chrome/common/extensions/extension_error_utils.h" |
#include "content/public/browser/devtools_agent_host_registry.h" |
@@ -46,6 +48,9 @@ using content::DevToolsManager; |
using content::WebContents; |
namespace keys = debugger_api_constants; |
+namespace Attach = extensions::api::debugger::Attach; |
+namespace Detach = extensions::api::debugger::Detach; |
+namespace SendCommand = extensions::api::debugger::SendCommand; |
class ExtensionDevToolsInfoBarDelegate : public ConfirmInfoBarDelegate { |
public: |
@@ -81,7 +86,7 @@ class ExtensionDevToolsClientHost : public DevToolsClientHost, |
void Close(); |
void SendMessageToBackend(SendCommandDebuggerFunction* function, |
const std::string& method, |
- Value* params); |
+ SendCommand::Params::CommandParams* params); |
// DevToolsClientHost interface |
virtual void InspectedContentsClosing() OVERRIDE; |
@@ -229,14 +234,14 @@ void ExtensionDevToolsClientHost::Close() { |
void ExtensionDevToolsClientHost::SendMessageToBackend( |
SendCommandDebuggerFunction* function, |
const std::string& method, |
- Value* params) { |
+ SendCommand::Params::CommandParams* params) { |
DictionaryValue protocol_request; |
int request_id = ++last_request_id_; |
pending_requests_[request_id] = function; |
protocol_request.SetInteger("id", request_id); |
protocol_request.SetString("method", method); |
if (params) |
not at google - send to devlin
2012/07/19 23:53:47
params can't be NULL, it's validated to not be, so
mitchellwrosen
2012/07/20 19:05:17
Params is optional, so this pointer can be NULL
Matt Tytel
2012/07/20 19:09:57
Maybe rename params to command_params here and oth
not at google - send to devlin
2012/07/23 13:56:23
Yep, I misread that. Thanks.
|
- protocol_request.Set("params", params->DeepCopy()); |
+ protocol_request.Set("params", params->additional_properties.DeepCopy()); |
std::string json_args; |
base::JSONWriter::Write(&protocol_request, &json_args); |
@@ -354,12 +359,6 @@ DebuggerFunction::DebuggerFunction() |
} |
bool DebuggerFunction::InitTabContents() { |
- Value* debuggee; |
- EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &debuggee)); |
- |
- DictionaryValue* dict = static_cast<DictionaryValue*>(debuggee); |
- EXTENSION_FUNCTION_VALIDATE(dict->GetInteger(keys::kTabIdKey, &tab_id_)); |
- |
// Find the TabContents that contains this tab id. |
contents_ = NULL; |
TabContents* tab_contents = NULL; |
@@ -407,16 +406,18 @@ AttachDebuggerFunction::AttachDebuggerFunction() {} |
AttachDebuggerFunction::~AttachDebuggerFunction() {} |
bool AttachDebuggerFunction::RunImpl() { |
+ scoped_ptr<Attach::Params> params(Attach::Params::Create(*args_)); |
+ EXTENSION_FUNCTION_VALIDATE(params.get()); |
+ |
+ tab_id_ = params->target.tab_id; |
if (!InitTabContents()) |
return false; |
- std::string version; |
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &version)); |
- |
- if (!webkit_glue::IsInspectorProtocolVersionSupported(version)) { |
+ if (!webkit_glue::IsInspectorProtocolVersionSupported( |
+ params->required_version)) { |
error_ = ExtensionErrorUtils::FormatErrorMessage( |
keys::kProtocolVersionNotSupportedError, |
- version); |
+ params->required_version); |
return false; |
} |
@@ -445,6 +446,10 @@ DetachDebuggerFunction::DetachDebuggerFunction() {} |
DetachDebuggerFunction::~DetachDebuggerFunction() {} |
bool DetachDebuggerFunction::RunImpl() { |
+ scoped_ptr<Detach::Params> params(Detach::Params::Create(*args_)); |
+ EXTENSION_FUNCTION_VALIDATE(params.get()); |
+ |
+ tab_id_ = params->target.tab_id; |
if (!InitClientHost()) |
return false; |
@@ -458,18 +463,15 @@ SendCommandDebuggerFunction::SendCommandDebuggerFunction() {} |
SendCommandDebuggerFunction::~SendCommandDebuggerFunction() {} |
bool SendCommandDebuggerFunction::RunImpl() { |
+ scoped_ptr<SendCommand::Params> params(SendCommand::Params::Create(*args_)); |
+ EXTENSION_FUNCTION_VALIDATE(params.get()); |
+ tab_id_ = params->target.tab_id; |
if (!InitClientHost()) |
return false; |
- std::string method; |
- EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &method)); |
- |
- Value *params; |
- if (!args_->Get(2, ¶ms)) |
- params = NULL; |
- |
- client_host_->SendMessageToBackend(this, method, params); |
+ client_host_->SendMessageToBackend(this, params->method, |
+ params->command_params.get()); |
return true; |
} |