OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Implements the Chrome Extensions Debugger API. | 5 // Implements the Chrome Extensions Debugger API. |
6 | 6 |
7 #include "chrome/browser/extensions/extension_debugger_api.h" | 7 #include "chrome/browser/extensions/extension_debugger_api.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 std::string json_args; | 242 std::string json_args; |
243 base::JSONWriter::Write(&protocol_request, &json_args); | 243 base::JSONWriter::Write(&protocol_request, &json_args); |
244 DevToolsManager::GetInstance()->DispatchOnInspectorBackend(this, json_args); | 244 DevToolsManager::GetInstance()->DispatchOnInspectorBackend(this, json_args); |
245 } | 245 } |
246 | 246 |
247 void ExtensionDevToolsClientHost::SendDetachedEvent() { | 247 void ExtensionDevToolsClientHost::SendDetachedEvent() { |
248 Profile* profile = | 248 Profile* profile = |
249 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 249 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
250 if (profile != NULL && profile->GetExtensionEventRouter()) { | 250 if (profile != NULL && profile->GetExtensionEventRouter()) { |
251 ListValue args; | 251 ListValue* args = new ListValue(); |
252 args.Append(CreateDebuggeeId(tab_id_)); | 252 args->Append(CreateDebuggeeId(tab_id_)); |
253 | |
254 std::string json_args; | |
255 base::JSONWriter::Write(&args, &json_args); | |
256 | 253 |
257 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 254 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
258 extension_id_, keys::kOnDetach, json_args, profile, GURL()); | 255 extension_id_, keys::kOnDetach, args, profile, GURL()); |
259 } | 256 } |
260 } | 257 } |
261 | 258 |
262 void ExtensionDevToolsClientHost::Observe( | 259 void ExtensionDevToolsClientHost::Observe( |
263 int type, | 260 int type, |
264 const content::NotificationSource& source, | 261 const content::NotificationSource& source, |
265 const content::NotificationDetails& details) { | 262 const content::NotificationDetails& details) { |
266 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 263 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
267 std::string id = | 264 std::string id = |
268 content::Details<extensions::UnloadedExtensionInfo>(details)-> | 265 content::Details<extensions::UnloadedExtensionInfo>(details)-> |
(...skipping 22 matching lines...) Expand all Loading... |
291 if (!result->IsType(Value::TYPE_DICTIONARY)) | 288 if (!result->IsType(Value::TYPE_DICTIONARY)) |
292 return; | 289 return; |
293 DictionaryValue* dictionary = static_cast<DictionaryValue*>(result.get()); | 290 DictionaryValue* dictionary = static_cast<DictionaryValue*>(result.get()); |
294 | 291 |
295 int id; | 292 int id; |
296 if (!dictionary->GetInteger("id", &id)) { | 293 if (!dictionary->GetInteger("id", &id)) { |
297 std::string method_name; | 294 std::string method_name; |
298 if (!dictionary->GetString("method", &method_name)) | 295 if (!dictionary->GetString("method", &method_name)) |
299 return; | 296 return; |
300 | 297 |
301 ListValue args; | 298 ListValue* args = new ListValue(); |
302 args.Append(CreateDebuggeeId(tab_id_)); | 299 args->Append(CreateDebuggeeId(tab_id_)); |
303 args.Append(Value::CreateStringValue(method_name)); | 300 args->Append(Value::CreateStringValue(method_name)); |
304 Value* params_value; | 301 Value* params_value; |
305 if (dictionary->Get("params", ¶ms_value)) | 302 if (dictionary->Get("params", ¶ms_value)) |
306 args.Append(params_value->DeepCopy()); | 303 args->Append(params_value->DeepCopy()); |
307 | |
308 std::string json_args; | |
309 base::JSONWriter::Write(&args, &json_args); | |
310 | 304 |
311 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 305 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
312 extension_id_, keys::kOnEvent, json_args, profile, GURL()); | 306 extension_id_, keys::kOnEvent, args, profile, GURL()); |
313 } else { | 307 } else { |
314 SendCommandDebuggerFunction* function = pending_requests_[id]; | 308 SendCommandDebuggerFunction* function = pending_requests_[id]; |
315 if (!function) | 309 if (!function) |
316 return; | 310 return; |
317 | 311 |
318 function->SendResponseBody(dictionary); | 312 function->SendResponseBody(dictionary); |
319 pending_requests_.erase(id); | 313 pending_requests_.erase(id); |
320 } | 314 } |
321 } | 315 } |
322 | 316 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 return; | 477 return; |
484 } | 478 } |
485 | 479 |
486 Value* result_body; | 480 Value* result_body; |
487 if (dictionary->Get("result", &result_body)) | 481 if (dictionary->Get("result", &result_body)) |
488 result_.reset(result_body->DeepCopy()); | 482 result_.reset(result_body->DeepCopy()); |
489 else | 483 else |
490 result_.reset(new DictionaryValue()); | 484 result_.reset(new DictionaryValue()); |
491 SendResponse(true); | 485 SendResponse(true); |
492 } | 486 } |
OLD | NEW |