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

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

Issue 145463002: Extensions: Send the tab id to platform apps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 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
(...skipping 25 matching lines...) Expand all
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 std::string name = *v8::String::Utf8Value(args[0]); 41 std::string name = *v8::String::Utf8Value(args[0]);
42 int request_id = args[2]->Int32Value(); 42 int request_id = args[2]->Int32Value();
43 bool has_callback = args[3]->BooleanValue(); 43 bool has_callback = args[3]->BooleanValue();
44 bool for_io_thread = args[4]->BooleanValue(); 44 bool for_io_thread = args[4]->BooleanValue();
45 bool preserve_null_in_objects = args[5]->BooleanValue(); 45 bool preserve_null_in_objects = args[5]->BooleanValue();
46 int sender_tab_id = args[6]->Int32Value();
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).
51 converter->SetFunctionAllowed(true); 52 converter->SetFunctionAllowed(true);
52 53
53 if (!preserve_null_in_objects) 54 if (!preserve_null_in_objects)
54 converter->SetStripNullFromObjects(true); 55 converter->SetStripNullFromObjects(true);
55 56
56 scoped_ptr<base::Value> value_args( 57 scoped_ptr<base::Value> value_args(
57 converter->FromV8Value(args[1], context()->v8_context())); 58 converter->FromV8Value(args[1], context()->v8_context()));
58 if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) { 59 if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) {
59 NOTREACHED() << "Unable to convert args passed to StartRequest"; 60 NOTREACHED() << "Unable to convert args passed to StartRequest";
60 return; 61 return;
61 } 62 }
62 63
63 request_sender_->StartRequest( 64 request_sender_->StartRequest(
64 context(), name, request_id, has_callback, for_io_thread, 65 context(), name, request_id, has_callback, for_io_thread, sender_tab_id,
65 static_cast<base::ListValue*>(value_args.get())); 66 static_cast<base::ListValue*>(value_args.get()));
66 } 67 }
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698