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

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: All tests pass 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_view.h"
12 #include "content/public/renderer/v8_value_converter.h"
13 #include "extensions/common/extension.h"
14 #include "extensions/renderer/script_context.h"
15 #include "v8/include/v8.h"
16
17 using content::V8ValueConverter;
18
19 namespace extensions {
20
21 GuestViewInternalCustomBindings::GuestViewInternalCustomBindings(
22 ScriptContext* context)
23 : ObjectBackedNativeHandler(context) {
24 RouteFunction("AttachGuest",
25 base::Bind(&GuestViewInternalCustomBindings::AttachGuest,
26 base::Unretained(this)));
27 }
28
29 void GuestViewInternalCustomBindings::AttachGuest(
30 const v8::FunctionCallbackInfo<v8::Value>& args) {
31 content::RenderView* render_view = context()->GetRenderView();
32 if (!render_view)
33 return;
34
35 if (args.Length() < 3 || !args[0]->IsInt32() || !args[1]->IsInt32() ||
36 !args[2]->IsObject()) {
37 return;
38 }
39
40 int element_instance_id = args[0]->Int32Value();
41 int guest_instance_id = args[1]->Int32Value();
42 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
43 scoped_ptr<base::Value> params_value(
44 converter->FromV8Value(args[2], context()->v8_context()));
45 if (base::Value::TYPE_DICTIONARY != params_value->GetType()) {
46 return;
47 }
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()));
53 render_view->Send(new ChromeExtensionHostMsg_GuestViewSetAttachParams(
54 render_view->GetRoutingID(),
55 element_instance_id,
56 guest_instance_id,
57 *params_dictionary));
58
59 // Step 2, attach plugin through content/.
60 render_view->AttachToBrowserPlugin(element_instance_id, guest_instance_id);
61
62 v8::Isolate* isolate = args.GetIsolate();
63 args.GetReturnValue().Set(v8::Boolean::New(isolate, true));
64 }
65
66 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698