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

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

Issue 444813002: Remove BrowserPlugin's -internal-attach method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/extensions/guest_view_internal_custom_bindings.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "chrome/common/extensions/chrome_extension_messages.h"
11 #include "content/public/renderer/render_frame.h"
12 #include "content/public/renderer/render_view.h"
13 #include "content/public/renderer/v8_value_converter.h"
14 #include "extensions/common/extension.h"
15 #include "extensions/renderer/script_context.h"
16 #include "v8/include/v8.h"
17
18 using content::V8ValueConverter;
19
20 namespace extensions {
21
22 GuestViewInternalCustomBindings::GuestViewInternalCustomBindings(
23 ScriptContext* context)
24 : ObjectBackedNativeHandler(context) {
25 RouteFunction("AttachGuest",
26 base::Bind(&GuestViewInternalCustomBindings::AttachGuest,
27 base::Unretained(this)));
28 }
29
30 void GuestViewInternalCustomBindings::AttachGuest(
31 const v8::FunctionCallbackInfo<v8::Value>& args) {
32 content::RenderFrame* render_frame = context()->GetRenderFrame();
not at google - send to devlin 2014/08/13 23:40:16 Nit: do this after argument validation.
Fady Samuel 2014/08/14 19:41:18 Done.
33 if (!render_frame)
34 return;
35
36 if (args.Length() < 3 || !args[0]->IsInt32() || !args[1]->IsInt32() ||
not at google - send to devlin 2014/08/13 23:40:16 !=3. Be explicit.
Fady Samuel 2014/08/14 19:41:18 Done.
37 !args[2]->IsObject()) {
not at google - send to devlin 2014/08/13 23:40:16 Add NOTREACHED() here as well. Or even CHECK. Best
Fady Samuel 2014/08/14 19:41:18 Done.
38 return;
39 }
40
41 int element_instance_id = args[0]->Int32Value();
42 int guest_instance_id = args[1]->Int32Value();
43 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
44 scoped_ptr<base::Value> params_value(
45 converter->FromV8Value(args[2], context()->v8_context()));
46 if (base::Value::TYPE_DICTIONARY != params_value->GetType()) {
not at google - send to devlin 2014/08/13 23:40:16 If it's not a dictionary then V8ValueConverter is
Fady Samuel 2014/08/14 19:41:18 Done.
47 return;
48 }
49
50 // Step 1, send the attach params to chrome/.
51 scoped_ptr<base::DictionaryValue> params_dictionary(
52 static_cast<base::DictionaryValue*>(params_value.release()));
not at google - send to devlin 2014/08/13 23:40:16 Nit: use params_value.PassAs()?
Fady Samuel 2014/08/14 19:41:17 Can't. PassAs can only be used for upcasting and n
53 render_frame->Send(new ChromeExtensionHostMsg_GuestViewSetAttachParams(
54 render_frame->GetRenderView()->GetRoutingID(),
55 element_instance_id,
56 guest_instance_id,
57 *params_dictionary));
58
59 // Step 2, attach plugin through content/.
60 render_frame->AttachToBrowserPlugin(element_instance_id, guest_instance_id);
61
62 v8::Isolate* isolate = args.GetIsolate();
63 args.GetReturnValue().Set(v8::Boolean::New(isolate, true));
not at google - send to devlin 2014/08/13 23:40:16 Nit: inline |isolate|. You could also use context(
Fady Samuel 2014/08/14 19:41:18 Done.
64 }
65
66 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698