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

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

Issue 2571063002: Remove Blink-in-JS (Closed)
Patch Set: Created 4 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
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 30 matching lines...) Expand all
41 #include <v8.h> 41 #include <v8.h>
42 42
43 namespace blink { 43 namespace blink {
44 44
45 class DOMDataStore; 45 class DOMDataStore;
46 46
47 enum WorldIdConstants { 47 enum WorldIdConstants {
48 MainWorldId = 0, 48 MainWorldId = 0,
49 // Embedder isolated worlds can use IDs in [1, 1<<29). 49 // Embedder isolated worlds can use IDs in [1, 1<<29).
50 EmbedderWorldIdLimit = (1 << 29), 50 EmbedderWorldIdLimit = (1 << 29),
51 PrivateScriptIsolatedWorldId,
52 DocumentXMLTreeViewerWorldId, 51 DocumentXMLTreeViewerWorldId,
53 IsolatedWorldIdLimit, 52 IsolatedWorldIdLimit,
54 WorkerWorldId, 53 WorkerWorldId,
55 TestingWorldId, 54 TestingWorldId,
56 }; 55 };
57 56
58 class DOMObjectHolderBase; 57 class DOMObjectHolderBase;
59 58
60 // This class represent a collection of DOM wrappers for a specific world. 59 // This class represent a collection of DOM wrappers for a specific world.
61 class CORE_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { 60 class CORE_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
62 public: 61 public:
63 static PassRefPtr<DOMWrapperWorld> create(v8::Isolate*, 62 static PassRefPtr<DOMWrapperWorld> create(v8::Isolate*,
64 int worldId = -1, 63 int worldId = -1,
65 int extensionGroup = -1); 64 int extensionGroup = -1);
66 65
67 static const int mainWorldExtensionGroup = 0; 66 static const int mainWorldExtensionGroup = 0;
68 static const int privateScriptIsolatedWorldExtensionGroup = 1;
69 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(v8::Isolate*, 67 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(v8::Isolate*,
70 int worldId, 68 int worldId,
71 int extensionGroup); 69 int extensionGroup);
72 ~DOMWrapperWorld(); 70 ~DOMWrapperWorld();
73 void dispose(); 71 void dispose();
74 72
75 static bool isolatedWorldsExist() { return isolatedWorldCount; } 73 static bool isolatedWorldsExist() { return isolatedWorldCount; }
76 static void allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld>>& worlds); 74 static void allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld>>& worlds);
77 static void markWrappersInAllWorlds(ScriptWrappable*, 75 static void markWrappersInAllWorlds(ScriptWrappable*,
78 const ScriptWrappableVisitor*); 76 const ScriptWrappableVisitor*);
79 static void setWrapperReferencesInAllWorlds( 77 static void setWrapperReferencesInAllWorlds(
80 const v8::Persistent<v8::Object>& parent, 78 const v8::Persistent<v8::Object>& parent,
81 ScriptWrappable*, 79 ScriptWrappable*,
82 v8::Isolate*); 80 v8::Isolate*);
83 81
84 static DOMWrapperWorld& world(v8::Local<v8::Context> context) { 82 static DOMWrapperWorld& world(v8::Local<v8::Context> context) {
85 return ScriptState::from(context)->world(); 83 return ScriptState::from(context)->world();
86 } 84 }
87 85
88 static DOMWrapperWorld& current(v8::Isolate* isolate) { 86 static DOMWrapperWorld& current(v8::Isolate* isolate) {
89 return world(isolate->GetCurrentContext()); 87 return world(isolate->GetCurrentContext());
90 } 88 }
91 89
92 static DOMWrapperWorld& mainWorld(); 90 static DOMWrapperWorld& mainWorld();
93 static DOMWrapperWorld& privateScriptIsolatedWorld();
94 static PassRefPtr<DOMWrapperWorld> fromWorldId(v8::Isolate*, 91 static PassRefPtr<DOMWrapperWorld> fromWorldId(v8::Isolate*,
95 int worldId, 92 int worldId,
96 int extensionGroup); 93 int extensionGroup);
97 94
98 static void setIsolatedWorldHumanReadableName(int worldID, const String&); 95 static void setIsolatedWorldHumanReadableName(int worldID, const String&);
99 String isolatedWorldHumanReadableName(); 96 String isolatedWorldHumanReadableName();
100 97
101 // Associates an isolated world (see above for description) with a security 98 // Associates an isolated world (see above for description) with a security
102 // origin. XMLHttpRequest instances used in that world will be considered 99 // origin. XMLHttpRequest instances used in that world will be considered
103 // to come from that origin, not the frame's. 100 // to come from that origin, not the frame's.
104 static void setIsolatedWorldSecurityOrigin(int worldId, 101 static void setIsolatedWorldSecurityOrigin(int worldId,
105 PassRefPtr<SecurityOrigin>); 102 PassRefPtr<SecurityOrigin>);
106 SecurityOrigin* isolatedWorldSecurityOrigin(); 103 SecurityOrigin* isolatedWorldSecurityOrigin();
107 104
108 // Associated an isolated world with a Content Security Policy. Resources 105 // Associated an isolated world with a Content Security Policy. Resources
109 // embedded into the main world's DOM from script executed in an isolated 106 // embedded into the main world's DOM from script executed in an isolated
110 // world should be restricted based on the isolated world's DOM, not the 107 // world should be restricted based on the isolated world's DOM, not the
111 // main world's. 108 // main world's.
112 // 109 //
113 // FIXME: Right now, resource injection simply bypasses the main world's 110 // FIXME: Right now, resource injection simply bypasses the main world's
114 // DOM. More work is necessary to allow the isolated world's policy to be 111 // DOM. More work is necessary to allow the isolated world's policy to be
115 // applied correctly. 112 // applied correctly.
116 static void setIsolatedWorldContentSecurityPolicy(int worldId, 113 static void setIsolatedWorldContentSecurityPolicy(int worldId,
117 const String& policy); 114 const String& policy);
118 bool isolatedWorldHasContentSecurityPolicy(); 115 bool isolatedWorldHasContentSecurityPolicy();
119 116
120 bool isMainWorld() const { return m_worldId == MainWorldId; } 117 bool isMainWorld() const { return m_worldId == MainWorldId; }
121 bool isPrivateScriptIsolatedWorld() const {
122 return m_worldId == PrivateScriptIsolatedWorldId;
123 }
124 bool isWorkerWorld() const { return m_worldId == WorkerWorldId; } 118 bool isWorkerWorld() const { return m_worldId == WorkerWorldId; }
125 bool isIsolatedWorld() const { 119 bool isIsolatedWorld() const {
126 return MainWorldId < m_worldId && m_worldId < IsolatedWorldIdLimit; 120 return MainWorldId < m_worldId && m_worldId < IsolatedWorldIdLimit;
127 } 121 }
128 122
129 int worldId() const { return m_worldId; } 123 int worldId() const { return m_worldId; }
130 int extensionGroup() const { return m_extensionGroup; } 124 int extensionGroup() const { return m_extensionGroup; }
131 DOMDataStore& domDataStore() const { return *m_domDataStore; } 125 DOMDataStore& domDataStore() const { return *m_domDataStore; }
132 126
133 public: 127 public:
(...skipping 12 matching lines...) Expand all
146 140
147 const int m_worldId; 141 const int m_worldId;
148 const int m_extensionGroup; 142 const int m_extensionGroup;
149 std::unique_ptr<DOMDataStore> m_domDataStore; 143 std::unique_ptr<DOMDataStore> m_domDataStore;
150 HashSet<std::unique_ptr<DOMObjectHolderBase>> m_domObjectHolders; 144 HashSet<std::unique_ptr<DOMObjectHolderBase>> m_domObjectHolders;
151 }; 145 };
152 146
153 } // namespace blink 147 } // namespace blink
154 148
155 #endif // DOMWrapperWorld_h 149 #endif // DOMWrapperWorld_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/bindings.gni ('k') | third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698