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

Side by Side Diff: third_party/WebKit/Source/platform/bindings/DOMWrapperWorld.h

Issue 2848653003: Add a DevTools command to create an isolated world for a given frame (Closed)
Patch Set: Rebased 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 class PLATFORM_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { 52 class PLATFORM_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
53 public: 53 public:
54 // Per-thread global identifiers for DOMWrapperWorld. 54 // Per-thread global identifiers for DOMWrapperWorld.
55 enum WorldId { 55 enum WorldId {
56 kInvalidWorldId = -1, 56 kInvalidWorldId = -1,
57 kMainWorldId = 0, 57 kMainWorldId = 0,
58 58
59 // Embedder isolated worlds can use IDs in [1, 1<<29). 59 // Embedder isolated worlds can use IDs in [1, 1<<29).
60 kEmbedderWorldIdLimit = (1 << 29), 60 kEmbedderWorldIdLimit = (1 << 29),
61 kDocumentXMLTreeViewerWorldId, 61 kDocumentXMLTreeViewerWorldId,
62 kDevToolsFirstIsolatedWorldId,
63 kDevToolsLastIsolatedWorldId = kDevToolsFirstIsolatedWorldId + 100,
62 kIsolatedWorldIdLimit, 64 kIsolatedWorldIdLimit,
63 65
64 // Other worlds can use IDs after this. Don't manually pick up an ID from 66 // Other worlds can use IDs after this. Don't manually pick up an ID from
65 // this range. generateWorldIdForType() picks it up on behalf of you. 67 // this range. generateWorldIdForType() picks it up on behalf of you.
66 kUnspecifiedWorldIdStart, 68 kUnspecifiedWorldIdStart,
67 }; 69 };
68 70
69 enum class WorldType { 71 enum class WorldType {
70 kMain, 72 kMain,
71 kIsolated, 73 kIsolated,
74 kInspectorIsolated,
72 kGarbageCollector, 75 kGarbageCollector,
73 kRegExp, 76 kRegExp,
74 kTesting, 77 kTesting,
75 kWorker, 78 kWorker,
76 }; 79 };
77 80
78 // Creates a world other than IsolatedWorld. 81 // Creates a world other than IsolatedWorld. Note this can return nullptr if
82 // GenerateWorldIdForType fails to allocate a valid id.
79 static PassRefPtr<DOMWrapperWorld> Create(v8::Isolate*, WorldType); 83 static PassRefPtr<DOMWrapperWorld> Create(v8::Isolate*, WorldType);
80 84
81 // Ensures an IsolatedWorld for |worldId|. 85 // Ensures an IsolatedWorld for |worldId|.
82 static PassRefPtr<DOMWrapperWorld> EnsureIsolatedWorld(v8::Isolate*, 86 static PassRefPtr<DOMWrapperWorld> EnsureIsolatedWorld(v8::Isolate*,
83 int world_id); 87 int world_id);
84 ~DOMWrapperWorld(); 88 ~DOMWrapperWorld();
85 void Dispose(); 89 void Dispose();
86 90
87 // Called from performance-sensitive functions, so we should keep this simple 91 // Called from performance-sensitive functions, so we should keep this simple
88 // and fast as much as possible. 92 // and fast as much as possible.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // 125 //
122 // FIXME: Right now, resource injection simply bypasses the main world's 126 // FIXME: Right now, resource injection simply bypasses the main world's
123 // DOM. More work is necessary to allow the isolated world's policy to be 127 // DOM. More work is necessary to allow the isolated world's policy to be
124 // applied correctly. 128 // applied correctly.
125 static void SetIsolatedWorldContentSecurityPolicy(int world_id, 129 static void SetIsolatedWorldContentSecurityPolicy(int world_id,
126 const String& policy); 130 const String& policy);
127 bool IsolatedWorldHasContentSecurityPolicy(); 131 bool IsolatedWorldHasContentSecurityPolicy();
128 132
129 bool IsMainWorld() const { return world_type_ == WorldType::kMain; } 133 bool IsMainWorld() const { return world_type_ == WorldType::kMain; }
130 bool IsWorkerWorld() const { return world_type_ == WorldType::kWorker; } 134 bool IsWorkerWorld() const { return world_type_ == WorldType::kWorker; }
131 bool IsIsolatedWorld() const { return world_type_ == WorldType::kIsolated; } 135 bool IsIsolatedWorld() const {
136 return world_type_ == WorldType::kIsolated ||
137 world_type_ == WorldType::kInspectorIsolated;
138 }
132 139
133 int GetWorldId() const { return world_id_; } 140 int GetWorldId() const { return world_id_; }
134 DOMDataStore& DomDataStore() const { return *dom_data_store_; } 141 DOMDataStore& DomDataStore() const { return *dom_data_store_; }
135 142
136 template <typename T> 143 template <typename T>
137 void RegisterDOMObjectHolder(v8::Isolate* isolate, 144 void RegisterDOMObjectHolder(v8::Isolate* isolate,
138 T* object, 145 T* object,
139 v8::Local<v8::Value> wrapper) { 146 v8::Local<v8::Value> wrapper) {
140 RegisterDOMObjectHolderInternal( 147 RegisterDOMObjectHolderInternal(
141 DOMObjectHolder<T>::Create(isolate, object, wrapper)); 148 DOMObjectHolder<T>::Create(isolate, object, wrapper));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 225
219 const WorldType world_type_; 226 const WorldType world_type_;
220 const int world_id_; 227 const int world_id_;
221 std::unique_ptr<DOMDataStore> dom_data_store_; 228 std::unique_ptr<DOMDataStore> dom_data_store_;
222 HashSet<std::unique_ptr<DOMObjectHolderBase>> dom_object_holders_; 229 HashSet<std::unique_ptr<DOMObjectHolderBase>> dom_object_holders_;
223 }; 230 };
224 231
225 } // namespace blink 232 } // namespace blink
226 233
227 #endif // DOMWrapperWorld_h 234 #endif // DOMWrapperWorld_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698