| 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 // Starts an API request to the browser, with an optional callback. The | 466 // Starts an API request to the browser, with an optional callback. The |
| 467 // callback will be dispatched to EventBindings::HandleResponse. | 467 // callback will be dispatched to EventBindings::HandleResponse. |
| 468 static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) { | 468 static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) { |
| 469 std::string str_args = *v8::String::Utf8Value(args[1]); | 469 std::string str_args = *v8::String::Utf8Value(args[1]); |
| 470 base::JSONReader reader; | 470 base::JSONReader reader; |
| 471 scoped_ptr<Value> value_args; | 471 scoped_ptr<Value> value_args; |
| 472 value_args.reset(reader.JsonToValue(str_args, false, false)); | 472 value_args.reset(reader.JsonToValue(str_args, false, false)); |
| 473 | 473 |
| 474 // Since we do the serialization in the v8 extension, we should always get | 474 // Since we do the serialization in the v8 extension, we should always get |
| 475 // valid JSON. | 475 // valid JSON. |
| 476 if (!value_args.get() || !value_args->IsType(Value::TYPE_LIST)) { | 476 if (!value_args.get() || !value_args->IsList()) { |
| 477 NOTREACHED() << "Invalid JSON passed to StartRequest."; | 477 NOTREACHED() << "Invalid JSON passed to StartRequest."; |
| 478 return v8::Undefined(); | 478 return v8::Undefined(); |
| 479 } | 479 } |
| 480 | 480 |
| 481 return StartRequestCommon(args, static_cast<ListValue*>(value_args.get())); | 481 return StartRequestCommon(args, static_cast<ListValue*>(value_args.get())); |
| 482 } | 482 } |
| 483 | 483 |
| 484 static bool ConvertImageDataToBitmapValue( | 484 static bool ConvertImageDataToBitmapValue( |
| 485 const v8::Arguments& args, Value** bitmap_value) { | 485 const v8::Arguments& args, Value** bitmap_value) { |
| 486 v8::Local<v8::Object> extension_args = args[1]->ToObject(); | 486 v8::Local<v8::Object> extension_args = args[1]->ToObject(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 603 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
| 604 std::string error = *v8::String::AsciiValue(retval); | 604 std::string error = *v8::String::AsciiValue(retval); |
| 605 DCHECK(false) << error; | 605 DCHECK(false) << error; |
| 606 } | 606 } |
| 607 #endif | 607 #endif |
| 608 | 608 |
| 609 request->second->context.Dispose(); | 609 request->second->context.Dispose(); |
| 610 request->second->context.Clear(); | 610 request->second->context.Clear(); |
| 611 pending_requests.erase(request); | 611 pending_requests.erase(request); |
| 612 } | 612 } |
| OLD | NEW |