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

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

Issue 702433002: Refactor GuestViewContainer to split out WebView related logic and MimeHandlerView related logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "extensions/renderer/guest_view/guest_view_internal_custom_bindings.h" 5 #include "extensions/renderer/guest_view/guest_view_internal_custom_bindings.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
11 #include "content/public/renderer/v8_value_converter.h" 11 #include "content/public/renderer/v8_value_converter.h"
12 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
13 #include "extensions/common/extension_messages.h" 13 #include "extensions/common/extension_messages.h"
14 #include "extensions/renderer/guest_view/guest_view_container.h" 14 #include "extensions/renderer/guest_view/extensions_guest_view_container.h"
15 #include "extensions/renderer/script_context.h" 15 #include "extensions/renderer/script_context.h"
16 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
17 17
18 using content::V8ValueConverter; 18 using content::V8ValueConverter;
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 GuestViewInternalCustomBindings::GuestViewInternalCustomBindings( 22 GuestViewInternalCustomBindings::GuestViewInternalCustomBindings(
23 ScriptContext* context) 23 ScriptContext* context)
24 : ObjectBackedNativeHandler(context) { 24 : ObjectBackedNativeHandler(context) {
25 RouteFunction("AttachGuest", 25 RouteFunction("AttachGuest",
26 base::Bind(&GuestViewInternalCustomBindings::AttachGuest, 26 base::Bind(&GuestViewInternalCustomBindings::AttachGuest,
27 base::Unretained(this))); 27 base::Unretained(this)));
28 } 28 }
29 29
30 void GuestViewInternalCustomBindings::AttachGuest( 30 void GuestViewInternalCustomBindings::AttachGuest(
31 const v8::FunctionCallbackInfo<v8::Value>& args) { 31 const v8::FunctionCallbackInfo<v8::Value>& args) {
32 // Allow for an optional callback parameter. 32 // Allow for an optional callback parameter.
33 CHECK(args.Length() >= 3 && args.Length() <= 4); 33 CHECK(args.Length() >= 3 && args.Length() <= 4);
34 // Element Instance ID. 34 // Element Instance ID.
35 CHECK(args[0]->IsInt32()); 35 CHECK(args[0]->IsInt32());
36 // Guest Instance ID. 36 // Guest Instance ID.
37 CHECK(args[1]->IsInt32()); 37 CHECK(args[1]->IsInt32());
38 // Attach Parameters. 38 // Attach Parameters.
39 CHECK(args[2]->IsObject()); 39 CHECK(args[2]->IsObject());
40 // Optional Callback Function. 40 // Optional Callback Function.
41 CHECK(args.Length() < 4 || args[3]->IsFunction()); 41 CHECK(args.Length() < 4 || args[3]->IsFunction());
42 42
43 int element_instance_id = args[0]->Int32Value(); 43 int element_instance_id = args[0]->Int32Value();
44 // An element instance ID uniquely identifies a GuestViewContainer within 44 // An element instance ID uniquely identifies a ExtensionsGuestViewContainer
45 // a RenderView. 45 // within a RenderView.
46 GuestViewContainer* guest_view_container = 46 ExtensionsGuestViewContainer* web_view_container =
Fady Samuel 2014/11/04 11:47:50 change this back to guest_view_container.
raymes 2014/11/04 22:56:08 Done.
47 GuestViewContainer::FromID(context()->GetRenderView()->GetRoutingID(), 47 ExtensionsGuestViewContainer::FromID(
48 element_instance_id); 48 context()->GetRenderView()->GetRoutingID(), element_instance_id);
49 49
50 // TODO(fsamuel): Should we be reporting an error if the element instance ID 50 // TODO(fsamuel): Should we be reporting an error if the element instance ID
51 // is invalid? 51 // is invalid?
52 if (!guest_view_container) 52 if (!web_view_container)
Fady Samuel 2014/11/04 11:47:50 guest_view_container
raymes 2014/11/04 22:56:08 Done.
53 return; 53 return;
54 54
55 int guest_instance_id = args[1]->Int32Value(); 55 int guest_instance_id = args[1]->Int32Value();
56 56
57 scoped_ptr<base::DictionaryValue> params; 57 scoped_ptr<base::DictionaryValue> params;
58 { 58 {
59 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 59 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
60 scoped_ptr<base::Value> params_as_value( 60 scoped_ptr<base::Value> params_as_value(
61 converter->FromV8Value(args[2], context()->v8_context())); 61 converter->FromV8Value(args[2], context()->v8_context()));
62 CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY)); 62 CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY));
63 params.reset( 63 params.reset(
64 static_cast<base::DictionaryValue*>(params_as_value.release())); 64 static_cast<base::DictionaryValue*>(params_as_value.release()));
65 } 65 }
66 66
67 linked_ptr<GuestViewContainer::AttachRequest> request( 67 linked_ptr<ExtensionsGuestViewContainer::AttachRequest> request(
68 new GuestViewContainer::AttachRequest( 68 new ExtensionsGuestViewContainer::AttachRequest(
69 element_instance_id, 69 element_instance_id,
70 guest_instance_id, 70 guest_instance_id,
71 params.Pass(), 71 params.Pass(),
72 args.Length() == 4 ? args[3].As<v8::Function>() : 72 args.Length() == 4 ? args[3].As<v8::Function>() :
73 v8::Handle<v8::Function>(), 73 v8::Handle<v8::Function>(),
74 args.GetIsolate())); 74 args.GetIsolate()));
75 guest_view_container->AttachGuest(request); 75 web_view_container->AttachGuest(request);
Fady Samuel 2014/11/04 11:47:50 guest_view_container
raymes 2014/11/04 22:56:09 Done.
76 76
77 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); 77 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
78 } 78 }
79 79
80 } // namespace extensions 80 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698