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

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

Issue 765843003: Refactor GuestViewContainer::AttachRequest to allow for other request types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid a new static Created 6 years 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
« no previous file with comments | « extensions/renderer/guest_view/guest_view_container.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 26 matching lines...) Expand all
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( 47 ExtensionsGuestViewContainer::FromID(element_instance_id);
48 context()->GetRenderView()->GetRoutingID(), element_instance_id);
49 48
50 // TODO(fsamuel): Should we be reporting an error if the element instance ID 49 // TODO(fsamuel): Should we be reporting an error if the element instance ID
51 // is invalid? 50 // is invalid?
52 if (!guest_view_container) 51 if (!guest_view_container)
53 return; 52 return;
54 53
55 int guest_instance_id = args[1]->Int32Value(); 54 int guest_instance_id = args[1]->Int32Value();
56 55
57 scoped_ptr<base::DictionaryValue> params; 56 scoped_ptr<base::DictionaryValue> params;
58 { 57 {
59 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 58 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
60 scoped_ptr<base::Value> params_as_value( 59 scoped_ptr<base::Value> params_as_value(
61 converter->FromV8Value(args[2], context()->v8_context())); 60 converter->FromV8Value(args[2], context()->v8_context()));
62 CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY)); 61 CHECK(params_as_value->IsType(base::Value::TYPE_DICTIONARY));
63 params.reset( 62 params.reset(
64 static_cast<base::DictionaryValue*>(params_as_value.release())); 63 static_cast<base::DictionaryValue*>(params_as_value.release()));
65 } 64 }
66 65
67 linked_ptr<ExtensionsGuestViewContainer::AttachRequest> request( 66 linked_ptr<ExtensionsGuestViewContainer::Request> request(
68 new ExtensionsGuestViewContainer::AttachRequest( 67 new ExtensionsGuestViewContainer::AttachRequest(
69 element_instance_id, 68 guest_view_container,
70 guest_instance_id, 69 guest_instance_id,
71 params.Pass(), 70 params.Pass(),
72 args.Length() == 4 ? args[3].As<v8::Function>() : 71 args.Length() == 4 ? args[3].As<v8::Function>() :
73 v8::Handle<v8::Function>(), 72 v8::Handle<v8::Function>(),
74 args.GetIsolate())); 73 args.GetIsolate()));
75 guest_view_container->AttachGuest(request); 74 guest_view_container->IssueRequest(request);
76 75
77 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); 76 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
78 } 77 }
79 78
80 } // namespace extensions 79 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/guest_view/guest_view_container.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698