| 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 #include "chrome/renderer/extensions/send_request_natives.h" | 5 #include "chrome/renderer/extensions/send_request_natives.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "content/public/renderer/v8_value_converter.h" | 8 #include "content/public/renderer/v8_value_converter.h" |
| 9 #include "chrome/renderer/extensions/request_sender.h" | 9 #include "chrome/renderer/extensions/request_sender.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 void SendRequestNatives::GetNextRequestId( | 31 void SendRequestNatives::GetNextRequestId( |
| 32 const v8::FunctionCallbackInfo<v8::Value>& args) { | 32 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 33 args.GetReturnValue().Set(static_cast<int32_t>( | 33 args.GetReturnValue().Set(static_cast<int32_t>( |
| 34 request_sender_->GetNextRequestId())); | 34 request_sender_->GetNextRequestId())); |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Starts an API request to the browser, with an optional callback. The | 37 // Starts an API request to the browser, with an optional callback. The |
| 38 // callback will be dispatched to EventBindings::HandleResponse. | 38 // callback will be dispatched to EventBindings::HandleResponse. |
| 39 void SendRequestNatives::StartRequest( | 39 void SendRequestNatives::StartRequest( |
| 40 const v8::FunctionCallbackInfo<v8::Value>& args) { | 40 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 41 CHECK_EQ(6, args.Length()); |
| 41 std::string name = *v8::String::Utf8Value(args[0]); | 42 std::string name = *v8::String::Utf8Value(args[0]); |
| 42 int request_id = args[2]->Int32Value(); | 43 int request_id = args[2]->Int32Value(); |
| 43 bool has_callback = args[3]->BooleanValue(); | 44 bool has_callback = args[3]->BooleanValue(); |
| 44 bool for_io_thread = args[4]->BooleanValue(); | 45 bool for_io_thread = args[4]->BooleanValue(); |
| 45 bool preserve_null_in_objects = args[5]->BooleanValue(); | 46 bool preserve_null_in_objects = args[5]->BooleanValue(); |
| 46 | 47 |
| 47 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 48 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 48 | 49 |
| 49 // See http://crbug.com/149880. The context menus APIs relies on this, but | 50 // See http://crbug.com/149880. The context menus APIs relies on this, but |
| 50 // we shouldn't really be doing it (e.g. for the sake of the storage API). | 51 // we shouldn't really be doing it (e.g. for the sake of the storage API). |
| (...skipping 16 matching lines...) Expand all Loading... |
| 67 | 68 |
| 68 void SendRequestNatives::GetGlobal( | 69 void SendRequestNatives::GetGlobal( |
| 69 const v8::FunctionCallbackInfo<v8::Value>& args) { | 70 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 70 CHECK_EQ(1, args.Length()); | 71 CHECK_EQ(1, args.Length()); |
| 71 CHECK(args[0]->IsObject()); | 72 CHECK(args[0]->IsObject()); |
| 72 args.GetReturnValue().Set( | 73 args.GetReturnValue().Set( |
| 73 v8::Handle<v8::Object>::Cast(args[0])->CreationContext()->Global()); | 74 v8::Handle<v8::Object>::Cast(args[0])->CreationContext()->Global()); |
| 74 } | 75 } |
| 75 | 76 |
| 76 } // namespace extensions | 77 } // namespace extensions |
| OLD | NEW |