| OLD | NEW |
| 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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 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 ExtensionsGuestViewContainer | 44 // An element instance ID uniquely identifies a ExtensionsGuestViewContainer |
| 45 // within a RenderView. | 45 // within a RenderView. |
| 46 ExtensionsGuestViewContainer* guest_view_container = | 46 ExtensionsGuestViewContainer* guest_view_container = |
| 47 ExtensionsGuestViewContainer::FromID(element_instance_id); | 47 ExtensionsGuestViewContainer::FromID( |
| 48 context()->GetRenderView()->GetRoutingID(), element_instance_id); |
| 48 | 49 |
| 49 // 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 |
| 50 // is invalid? | 51 // is invalid? |
| 51 if (!guest_view_container) | 52 if (!guest_view_container) |
| 52 return; | 53 return; |
| 53 | 54 |
| 54 int guest_instance_id = args[1]->Int32Value(); | 55 int guest_instance_id = args[1]->Int32Value(); |
| 55 | 56 |
| 56 scoped_ptr<base::DictionaryValue> params; | 57 scoped_ptr<base::DictionaryValue> params; |
| 57 { | 58 { |
| 58 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 59 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 59 scoped_ptr<base::Value> params_as_value( | 60 scoped_ptr<base::Value> params_as_value( |
| 60 converter->FromV8Value(args[2], context()->v8_context())); | 61 converter->FromV8Value(args[2], context()->v8_context())); |
| 61 CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY)); | 62 CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY)); |
| 62 params.reset( | 63 params.reset( |
| 63 static_cast<base::DictionaryValue*>(params_as_value.release())); | 64 static_cast<base::DictionaryValue*>(params_as_value.release())); |
| 64 } | 65 } |
| 65 | 66 |
| 66 linked_ptr<ExtensionsGuestViewContainer::Request> request( | 67 linked_ptr<ExtensionsGuestViewContainer::AttachRequest> request( |
| 67 new ExtensionsGuestViewContainer::AttachRequest( | 68 new ExtensionsGuestViewContainer::AttachRequest( |
| 68 guest_view_container, | 69 element_instance_id, |
| 69 guest_instance_id, | 70 guest_instance_id, |
| 70 params.Pass(), | 71 params.Pass(), |
| 71 args.Length() == 4 ? args[3].As<v8::Function>() : | 72 args.Length() == 4 ? args[3].As<v8::Function>() : |
| 72 v8::Handle<v8::Function>(), | 73 v8::Handle<v8::Function>(), |
| 73 args.GetIsolate())); | 74 args.GetIsolate())); |
| 74 guest_view_container->IssueRequest(request); | 75 guest_view_container->AttachGuest(request); |
| 75 | 76 |
| 76 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); | 77 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); |
| 77 } | 78 } |
| 78 | 79 |
| 79 } // namespace extensions | 80 } // namespace extensions |
| OLD | NEW |