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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp

Issue 2848653003: Add a DevTools command to create an isolated world for a given frame (Closed)
Patch Set: Changed so we don't pass in the id Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "core/loader/NavigationScheduler.h" 53 #include "core/loader/NavigationScheduler.h"
54 #include "core/loader/ProgressTracker.h" 54 #include "core/loader/ProgressTracker.h"
55 #include "core/plugins/PluginView.h" 55 #include "core/plugins/PluginView.h"
56 #include "core/probe/CoreProbes.h" 56 #include "core/probe/CoreProbes.h"
57 #include "platform/FrameViewBase.h" 57 #include "platform/FrameViewBase.h"
58 #include "platform/Histogram.h" 58 #include "platform/Histogram.h"
59 #include "platform/UserGestureIndicator.h" 59 #include "platform/UserGestureIndicator.h"
60 #include "platform/instrumentation/tracing/TraceEvent.h" 60 #include "platform/instrumentation/tracing/TraceEvent.h"
61 #include "platform/weborigin/SecurityOrigin.h" 61 #include "platform/weborigin/SecurityOrigin.h"
62 #include "platform/wtf/CurrentTime.h" 62 #include "platform/wtf/CurrentTime.h"
63 #include "platform/wtf/HashSet.h"
63 #include "platform/wtf/StdLibExtras.h" 64 #include "platform/wtf/StdLibExtras.h"
64 #include "platform/wtf/StringExtras.h" 65 #include "platform/wtf/StringExtras.h"
65 #include "platform/wtf/text/CString.h" 66 #include "platform/wtf/text/CString.h"
66 #include "platform/wtf/text/StringBuilder.h" 67 #include "platform/wtf/text/StringBuilder.h"
67 68
68 namespace blink { 69 namespace blink {
69 70
70 DEFINE_TRACE(ScriptController) { 71 DEFINE_TRACE(ScriptController) {
71 visitor->Trace(frame_); 72 visitor->Trace(frame_);
72 visitor->Trace(window_proxy_manager_); 73 visitor->Trace(window_proxy_manager_);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (results) { 365 if (results) {
365 for (size_t i = 0; i < result_array->Length(); ++i) { 366 for (size_t i = 0; i < result_array->Length(); ++i) {
366 v8::Local<v8::Value> value; 367 v8::Local<v8::Value> value;
367 if (!result_array->Get(context, i).ToLocal(&value)) 368 if (!result_array->Get(context, i).ToLocal(&value))
368 return; 369 return;
369 results->push_back(value); 370 results->push_back(value);
370 } 371 }
371 } 372 }
372 } 373 }
373 374
375 int ScriptController::CreateNewIsolatedWorld(const String& world_name) {
376 // Find an unused id, unfortunately there doesn't seem to be a better way of
377 // doing this because DOMWrapperWorld::Create doesn't support isolated worlds.
378 Vector<RefPtr<DOMWrapperWorld>> worlds;
379 DOMWrapperWorld::AllWorldsInCurrentThread(worlds);
380 WTF::HashSet<int> existingWorlds;
381 for (const auto& world : worlds) {
382 if (!world->IsIsolatedWorld())
383 continue;
384 existingWorlds.insert(world->GetWorldId());
385 }
386 int world_id = 1;
caseq 2017/04/28 21:41:30 I think allocating ids like this is going to bring
Sami 2017/05/02 09:47:19 Is there some registry of world ids? Should we jus
alex clarke (OOO till 29th) 2017/05/02 10:00:06 OK do you have any suggestions for what else we mi
387 while (existingWorlds.Contains(world_id)) {
388 world_id++;
389 }
390 DCHECK_LT(world_id, DOMWrapperWorld::kEmbedderWorldIdLimit);
391 RefPtr<DOMWrapperWorld> world =
392 DOMWrapperWorld::EnsureIsolatedWorld(GetIsolate(), world_id);
393
394 DOMWrapperWorld::SetIsolatedWorldHumanReadableName(world_id, world_name);
395 // Make sure the execution context exists.
396 WindowProxy(*world);
397 return world_id;
398 }
399
374 } // namespace blink 400 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698