| 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 25 matching lines...) Expand all Loading... |
| 36 #include "V8PerContextData.h" | 36 #include "V8PerContextData.h" |
| 37 #include <v8.h> | 37 #include <v8.h> |
| 38 #include <wtf/PassRefPtr.h> | 38 #include <wtf/PassRefPtr.h> |
| 39 #include <wtf/RefCounted.h> | 39 #include <wtf/RefCounted.h> |
| 40 #include <wtf/RefPtr.h> | 40 #include <wtf/RefPtr.h> |
| 41 #include <wtf/text/WTFString.h> | 41 #include <wtf/text/WTFString.h> |
| 42 | 42 |
| 43 namespace WebCore { | 43 namespace WebCore { |
| 44 | 44 |
| 45 class DOMDataStore; | 45 class DOMDataStore; |
| 46 class ScriptExecutionContext; |
| 46 | 47 |
| 47 // This class represent a collection of DOM wrappers for a specific world. | 48 // This class represent a collection of DOM wrappers for a specific world. |
| 48 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { | 49 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { |
| 49 public: | 50 public: |
| 50 static const int mainWorldId = 0; | 51 static const int mainWorldId = 0; |
| 51 static const int mainWorldExtensionGroup = 0; | 52 static const int mainWorldExtensionGroup = 0; |
| 52 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte
nsionGroup); | 53 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte
nsionGroup); |
| 53 ~DOMWrapperWorld(); | 54 ~DOMWrapperWorld(); |
| 54 | 55 |
| 55 static bool isolatedWorldsExist() { return isolatedWorldCount; } | 56 static bool isolatedWorldsExist() { return isolatedWorldCount; } |
| 56 static bool isIsolatedWorldId(int worldId) { return worldId > mainWorldId; } | 57 static bool isIsolatedWorldId(int worldId) { return worldId > mainWorldId; } |
| 57 static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds); | 58 static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds); |
| 58 | 59 |
| 59 void makeContextWeak(v8::Handle<v8::Context>); | 60 void makeContextWeak(v8::Handle<v8::Context>); |
| 60 void setIsolatedWorldField(v8::Handle<v8::Context>); | 61 void setIsolatedWorldField(v8::Handle<v8::Context>); |
| 61 | 62 |
| 62 static DOMWrapperWorld* isolatedWorld(v8::Handle<v8::Context> context) | 63 static DOMWrapperWorld* isolatedWorld(v8::Handle<v8::Context> context) |
| 63 { | 64 { |
| 64 ASSERT(contextHasCorrectPrototype(context)); | 65 ASSERT(contextHasCorrectPrototype(context)); |
| 65 return static_cast<DOMWrapperWorld*>(context->GetAlignedPointerFromEmbed
derData(v8ContextIsolatedWorld)); | 66 return static_cast<DOMWrapperWorld*>(context->GetAlignedPointerFromEmbed
derData(v8ContextIsolatedWorld)); |
| 66 } | 67 } |
| 67 | 68 |
| 69 // Will return null if there is no DOMWrapperWorld representing the given Sc
riptExecutionContext. |
| 70 static DOMWrapperWorld* current(ScriptExecutionContext*); |
| 71 |
| 68 // Associates an isolated world (see above for description) with a security | 72 // Associates an isolated world (see above for description) with a security |
| 69 // origin. XMLHttpRequest instances used in that world will be considered | 73 // origin. XMLHttpRequest instances used in that world will be considered |
| 70 // to come from that origin, not the frame's. | 74 // to come from that origin, not the frame's. |
| 71 static void setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityO
rigin>); | 75 static void setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityO
rigin>); |
| 72 static void clearIsolatedWorldSecurityOrigin(int worldID); | 76 static void clearIsolatedWorldSecurityOrigin(int worldID); |
| 73 SecurityOrigin* isolatedWorldSecurityOrigin(); | 77 SecurityOrigin* isolatedWorldSecurityOrigin(); |
| 74 | 78 |
| 75 // Associated an isolated world with a Content Security Policy. Resources | 79 // Associated an isolated world with a Content Security Policy. Resources |
| 76 // embedded into the main world's DOM from script executed in an isolated | 80 // embedded into the main world's DOM from script executed in an isolated |
| 77 // world should be restricted based on the isolated world's DOM, not the | 81 // world should be restricted based on the isolated world's DOM, not the |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 123 |
| 120 DOMWrapperWorld* mainThreadNormalWorld(); | 124 DOMWrapperWorld* mainThreadNormalWorld(); |
| 121 | 125 |
| 122 // FIXME: this is a workaround for a problem in ScriptController | 126 // FIXME: this is a workaround for a problem in ScriptController |
| 123 // Do not use this anywhere else!! | 127 // Do not use this anywhere else!! |
| 124 DOMWrapperWorld* existingWindowShellWorkaroundWorld(); | 128 DOMWrapperWorld* existingWindowShellWorkaroundWorld(); |
| 125 | 129 |
| 126 } // namespace WebCore | 130 } // namespace WebCore |
| 127 | 131 |
| 128 #endif // DOMWrapperWorld_h | 132 #endif // DOMWrapperWorld_h |
| OLD | NEW |