| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/renderer/extensions/extension_process_bindings.h" | 5 #include "chrome/renderer/extensions/extension_process_bindings.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // Starts an API request to the browser, with an optional callback. The | 460 // Starts an API request to the browser, with an optional callback. The |
| 461 // callback will be dispatched to EventBindings::HandleResponse. | 461 // callback will be dispatched to EventBindings::HandleResponse. |
| 462 static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) { | 462 static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) { |
| 463 std::string str_args = *v8::String::Utf8Value(args[1]); | 463 std::string str_args = *v8::String::Utf8Value(args[1]); |
| 464 base::JSONReader reader; | 464 base::JSONReader reader; |
| 465 scoped_ptr<Value> value_args; | 465 scoped_ptr<Value> value_args; |
| 466 value_args.reset(reader.JsonToValue(str_args, false, false)); | 466 value_args.reset(reader.JsonToValue(str_args, false, false)); |
| 467 | 467 |
| 468 // Since we do the serialization in the v8 extension, we should always get | 468 // Since we do the serialization in the v8 extension, we should always get |
| 469 // valid JSON. | 469 // valid JSON. |
| 470 if (!value_args.get() || !value_args->AsList()) { | 470 if (!value_args.get() || !value_args->IsType(Value::TYPE_LIST)) { |
| 471 NOTREACHED() << "Invalid JSON passed to StartRequest."; | 471 NOTREACHED() << "Invalid JSON passed to StartRequest."; |
| 472 return v8::Undefined(); | 472 return v8::Undefined(); |
| 473 } | 473 } |
| 474 | 474 |
| 475 return StartRequestCommon(args, value_args->AsList()); | 475 return StartRequestCommon(args, static_cast<ListValue*>(value_args.get())); |
| 476 } | 476 } |
| 477 | 477 |
| 478 static bool ConvertImageDataToBitmapValue( | 478 static bool ConvertImageDataToBitmapValue( |
| 479 const v8::Arguments& args, Value** bitmap_value) { | 479 const v8::Arguments& args, Value** bitmap_value) { |
| 480 v8::Local<v8::Object> extension_args = args[1]->ToObject(); | 480 v8::Local<v8::Object> extension_args = args[1]->ToObject(); |
| 481 v8::Local<v8::Object> details = | 481 v8::Local<v8::Object> details = |
| 482 extension_args->Get(v8::String::New("0"))->ToObject(); | 482 extension_args->Get(v8::String::New("0"))->ToObject(); |
| 483 v8::Local<v8::Object> image_data = | 483 v8::Local<v8::Object> image_data = |
| 484 details->Get(v8::String::New("imageData"))->ToObject(); | 484 details->Get(v8::String::New("imageData"))->ToObject(); |
| 485 v8::Local<v8::Object> data = | 485 v8::Local<v8::Object> data = |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 597 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
| 598 std::string error = *v8::String::AsciiValue(retval); | 598 std::string error = *v8::String::AsciiValue(retval); |
| 599 DCHECK(false) << error; | 599 DCHECK(false) << error; |
| 600 } | 600 } |
| 601 #endif | 601 #endif |
| 602 | 602 |
| 603 request->second->context.Dispose(); | 603 request->second->context.Dispose(); |
| 604 request->second->context.Clear(); | 604 request->second->context.Clear(); |
| 605 pending_requests.erase(request); | 605 pending_requests.erase(request); |
| 606 } | 606 } |
| OLD | NEW |