| OLD | NEW |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 class DOMDataStore; | 44 class DOMDataStore; |
| 45 class ScriptController; | 45 class ScriptController; |
| 46 class ExecutionContext; | 46 class ExecutionContext; |
| 47 | 47 |
| 48 enum WorldIdConstants { | 48 enum WorldIdConstants { |
| 49 MainWorldId = 0, | 49 MainWorldId = 0, |
| 50 // Embedder isolated worlds can use IDs in [1, 1<<29). | 50 // Embedder isolated worlds can use IDs in [1, 1<<29). |
| 51 EmbedderWorldIdLimit = (1 << 29), | 51 EmbedderWorldIdLimit = (1 << 29), |
| 52 ScriptPreprocessorIsolatedWorldId, | 52 ScriptPreprocessorIsolatedWorldId, |
| 53 WorkerWorldId, | 53 WorkerWorldId, |
| 54 TestingWorldId, | |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 // This class represent a collection of DOM wrappers for a specific world. | 56 // This class represent a collection of DOM wrappers for a specific world. |
| 58 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { | 57 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { |
| 59 public: | 58 public: |
| 60 static PassRefPtr<DOMWrapperWorld> create(int worldId = -1, int extensionGro
up = -1); | 59 static PassRefPtr<DOMWrapperWorld> create(int worldId, int extensionGroup); |
| 61 | 60 |
| 62 static const int mainWorldExtensionGroup = 0; | 61 static const int mainWorldExtensionGroup = 0; |
| 63 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte
nsionGroup); | 62 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte
nsionGroup); |
| 64 ~DOMWrapperWorld(); | 63 ~DOMWrapperWorld(); |
| 65 | 64 |
| 66 static bool isolatedWorldsExist() { return isolatedWorldCount; } | 65 static bool isolatedWorldsExist() { return isolatedWorldCount; } |
| 67 static void getAllWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& world
s); | 66 static void getAllWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& world
s); |
| 68 | 67 |
| 69 static DOMWrapperWorld* world(v8::Handle<v8::Context> context) | 68 static DOMWrapperWorld* world(v8::Handle<v8::Context> context) |
| 70 { | 69 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 90 // | 89 // |
| 91 // FIXME: Right now, resource injection simply bypasses the main world's | 90 // FIXME: Right now, resource injection simply bypasses the main world's |
| 92 // DOM. More work is necessary to allow the isolated world's policy to be | 91 // DOM. More work is necessary to allow the isolated world's policy to be |
| 93 // applied correctly. | 92 // applied correctly. |
| 94 static void setIsolatedWorldContentSecurityPolicy(int worldID, const String&
policy); | 93 static void setIsolatedWorldContentSecurityPolicy(int worldID, const String&
policy); |
| 95 static void clearIsolatedWorldContentSecurityPolicy(int worldID); | 94 static void clearIsolatedWorldContentSecurityPolicy(int worldID); |
| 96 bool isolatedWorldHasContentSecurityPolicy(); | 95 bool isolatedWorldHasContentSecurityPolicy(); |
| 97 | 96 |
| 98 bool isMainWorld() const { return m_worldId == MainWorldId; } | 97 bool isMainWorld() const { return m_worldId == MainWorldId; } |
| 99 bool isWorkerWorld() const { return m_worldId == WorkerWorldId; } | 98 bool isWorkerWorld() const { return m_worldId == WorkerWorldId; } |
| 100 bool isIsolatedWorld() const { return MainWorldId < m_worldId && m_worldId
<= EmbedderWorldIdLimit; } | 99 bool isIsolatedWorld() const { return !isMainWorld() && !isWorkerWorld(); } |
| 101 | 100 |
| 102 int worldId() const { return m_worldId; } | 101 int worldId() const { return m_worldId; } |
| 103 int extensionGroup() const { return m_extensionGroup; } | 102 int extensionGroup() const { return m_extensionGroup; } |
| 104 DOMDataStore& domDataStore() { return *m_domDataStore; } | 103 DOMDataStore& domDataStore() { return *m_domDataStore; } |
| 105 | 104 |
| 106 private: | 105 private: |
| 107 static unsigned isolatedWorldCount; | 106 static unsigned isolatedWorldCount; |
| 108 | 107 |
| 109 DOMWrapperWorld(int worldId, int extensionGroup); | 108 DOMWrapperWorld(int worldId, int extensionGroup); |
| 110 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>); | 109 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>); |
| 111 | 110 |
| 112 const int m_worldId; | 111 const int m_worldId; |
| 113 const int m_extensionGroup; | 112 const int m_extensionGroup; |
| 114 OwnPtr<DOMDataStore> m_domDataStore; | 113 OwnPtr<DOMDataStore> m_domDataStore; |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 } // namespace WebCore | 116 } // namespace WebCore |
| 118 | 117 |
| 119 #endif // DOMWrapperWorld_h | 118 #endif // DOMWrapperWorld_h |
| OLD | NEW |