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

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

Issue 2931393003: [Content] Update V8ValueConverter::create to return a std::unique_ptr (Closed)
Patch Set: rebase Created 3 years, 6 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
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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 // TODO(fsamuel): Should we be reporting an error if the element instance ID 157 // TODO(fsamuel): Should we be reporting an error if the element instance ID
158 // is invalid? 158 // is invalid?
159 if (!guest_view_container) 159 if (!guest_view_container)
160 return; 160 return;
161 // Retain a weak pointer so we can easily test if the container goes away. 161 // Retain a weak pointer so we can easily test if the container goes away.
162 auto weak_ptr = guest_view_container->GetWeakPtr(); 162 auto weak_ptr = guest_view_container->GetWeakPtr();
163 163
164 int guest_instance_id = args[1]->Int32Value(); 164 int guest_instance_id = args[1]->Int32Value();
165 165
166 std::unique_ptr<base::DictionaryValue> params; 166 std::unique_ptr<base::DictionaryValue> params = base::DictionaryValue::From(
167 { 167 content::V8ValueConverter::Create()->FromV8Value(
168 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 168 args[2], context()->v8_context()));
169 std::unique_ptr<base::Value> params_as_value( 169 CHECK(params);
170 converter->FromV8Value(args[2], context()->v8_context())); 170
171 params = base::DictionaryValue::From(std::move(params_as_value));
172 CHECK(params);
173 }
174 // We should be careful that some malicious JS in the GuestView's embedder 171 // We should be careful that some malicious JS in the GuestView's embedder
175 // hasn't destroyed |guest_view_container| during the enumeration of the 172 // hasn't destroyed |guest_view_container| during the enumeration of the
176 // properties of the guest's object during extraction of |params| above 173 // properties of the guest's object during extraction of |params| above
177 // (see https://crbug.com/683523). 174 // (see https://crbug.com/683523).
178 if (!weak_ptr) 175 if (!weak_ptr)
179 return; 176 return;
180 177
181 // Add flag to |params| to indicate that the element size is specified in 178 // Add flag to |params| to indicate that the element size is specified in
182 // logical units. 179 // logical units.
183 params->SetBoolean(guest_view::kElementSizeIsLogical, true); 180 params->SetBoolean(guest_view::kElementSizeIsLogical, true);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 239
243 int element_instance_id = args[0]->Int32Value(); 240 int element_instance_id = args[0]->Int32Value();
244 int guest_instance_id = args[1]->Int32Value(); 241 int guest_instance_id = args[1]->Int32Value();
245 242
246 // Get the WebLocalFrame before (possibly) executing any user-space JS while 243 // Get the WebLocalFrame before (possibly) executing any user-space JS while
247 // getting the |params|. We track the status of the RenderFrame via an 244 // getting the |params|. We track the status of the RenderFrame via an
248 // observer in case it is deleted during user code execution. 245 // observer in case it is deleted during user code execution.
249 content::RenderFrame* render_frame = GetRenderFrame(args[3]); 246 content::RenderFrame* render_frame = GetRenderFrame(args[3]);
250 RenderFrameStatus render_frame_status(render_frame); 247 RenderFrameStatus render_frame_status(render_frame);
251 248
252 std::unique_ptr<base::DictionaryValue> params; 249 std::unique_ptr<base::DictionaryValue> params = base::DictionaryValue::From(
253 { 250 content::V8ValueConverter::Create()->FromV8Value(
254 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 251 args[2], context()->v8_context()));
255 std::unique_ptr<base::Value> params_as_value( 252 CHECK(params);
256 converter->FromV8Value(args[2], context()->v8_context())); 253
257 params = base::DictionaryValue::From(std::move(params_as_value));
258 CHECK(params);
259 }
260 if (!render_frame_status.is_ok()) 254 if (!render_frame_status.is_ok())
261 return; 255 return;
262 256
263 blink::WebLocalFrame* frame = render_frame->GetWebFrame(); 257 blink::WebLocalFrame* frame = render_frame->GetWebFrame();
264 // Parent must exist. 258 // Parent must exist.
265 blink::WebFrame* parent_frame = frame->Parent(); 259 blink::WebFrame* parent_frame = frame->Parent();
266 DCHECK(parent_frame); 260 DCHECK(parent_frame);
267 DCHECK(parent_frame->IsWebLocalFrame()); 261 DCHECK(parent_frame->IsWebLocalFrame());
268 262
269 // Add flag to |params| to indicate that the element size is specified in 263 // Add flag to |params| to indicate that the element size is specified in
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // EnterFullscreen() and do it directly rather than having a generic "run with 445 // EnterFullscreen() and do it directly rather than having a generic "run with
452 // user gesture" function. 446 // user gesture" function.
453 blink::WebScopedUserGesture user_gesture(context()->web_frame()); 447 blink::WebScopedUserGesture user_gesture(context()->web_frame());
454 CHECK_EQ(args.Length(), 1); 448 CHECK_EQ(args.Length(), 1);
455 CHECK(args[0]->IsFunction()); 449 CHECK(args[0]->IsFunction());
456 context()->SafeCallFunction( 450 context()->SafeCallFunction(
457 v8::Local<v8::Function>::Cast(args[0]), 0, nullptr); 451 v8::Local<v8::Function>::Cast(args[0]), 0, nullptr);
458 } 452 }
459 453
460 } // namespace extensions 454 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/event_bindings.cc ('k') | extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698