Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: chrome/renderer/extensions/send_request_natives.cc

Issue 12378077: Attempting to fix problems in 11571014. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 using content::V8ValueConverter; 11 using content::V8ValueConverter;
12 12
13 namespace extensions { 13 namespace extensions {
14 14
15 SendRequestNatives::SendRequestNatives(Dispatcher* dispatcher, 15 SendRequestNatives::SendRequestNatives(Dispatcher* dispatcher,
16 RequestSender* request_sender, 16 RequestSender* request_sender,
17 ChromeV8Context* context) 17 ChromeV8Context* context)
18 : ChromeV8Extension(dispatcher, context->v8_context()), 18 : ChromeV8Extension(dispatcher, context->v8_context()),
19 request_sender_(request_sender), 19 request_sender_(request_sender),
20 context_(context) { 20 context_(context) {
21 RouteFunction("GetNextRequestId", 21 RouteFunction("GetNextRequestId",
22 base::Bind(&SendRequestNatives::GetNextRequestId, 22 base::Bind(&SendRequestNatives::GetNextRequestId,
23 base::Unretained(this))); 23 base::Unretained(this)));
24 RouteFunction("StartRequest", 24 RouteFunction("StartRequest",
25 base::Bind(&SendRequestNatives::StartRequest, 25 base::Bind(&SendRequestNatives::StartRequest,
26 base::Unretained(this))); 26 base::Unretained(this)));
27 RouteFunction("GetGlobal",
28 base::Bind(&SendRequestNatives::GetGlobal,
29 base::Unretained(this)));
27 } 30 }
28 31
29 v8::Handle<v8::Value> SendRequestNatives::GetNextRequestId( 32 v8::Handle<v8::Value> SendRequestNatives::GetNextRequestId(
30 const v8::Arguments& args) { 33 const v8::Arguments& args) {
31 static int next_request_id = 0; 34 static int next_request_id = 0;
32 return v8::Integer::New(next_request_id++); 35 return v8::Integer::New(next_request_id++);
33 } 36 }
34 37
35 // Starts an API request to the browser, with an optional callback. The 38 // Starts an API request to the browser, with an optional callback. The
36 // callback will be dispatched to EventBindings::HandleResponse. 39 // callback will be dispatched to EventBindings::HandleResponse.
(...skipping 19 matching lines...) Expand all
56 NOTREACHED() << "Unable to convert args passed to StartRequest"; 59 NOTREACHED() << "Unable to convert args passed to StartRequest";
57 return v8::Undefined(); 60 return v8::Undefined();
58 } 61 }
59 62
60 request_sender_->StartRequest( 63 request_sender_->StartRequest(
61 context_, name, request_id, has_callback, for_io_thread, 64 context_, name, request_id, has_callback, for_io_thread,
62 static_cast<ListValue*>(value_args.get())); 65 static_cast<ListValue*>(value_args.get()));
63 return v8::Undefined(); 66 return v8::Undefined();
64 } 67 }
65 68
69 v8::Handle<v8::Value> SendRequestNatives::GetGlobal(const v8::Arguments& args) {
70 CHECK_EQ(1, args.Length());
71 CHECK(args[0]->IsObject());
72 return v8::Handle<v8::Object>::Cast(args[0])->CreationContext()->Global();
73 }
74
66 } // namespace extensions 75 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/send_request_natives.h ('k') | chrome/renderer/resources/extensions/bluetooth_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698