OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NullExecutionContext_h | 5 #ifndef NullExecutionContext_h |
6 #define NullExecutionContext_h | 6 #define NullExecutionContext_h |
7 | 7 |
8 #include "bindings/core/v8/SourceLocation.h" | 8 #include "bindings/core/v8/SourceLocation.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/dom/SecurityContext.h" | 10 #include "core/dom/SecurityContext.h" |
11 #include "core/events/EventQueue.h" | 11 #include "core/events/EventQueue.h" |
12 #include "core/inspector/ConsoleMessage.h" | 12 #include "core/inspector/ConsoleMessage.h" |
13 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
14 #include "platform/weborigin/KURL.h" | 14 #include "platform/weborigin/KURL.h" |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class NullExecutionContext final | 19 class NullExecutionContext final |
20 : public GarbageCollectedFinalized<NullExecutionContext>, | 20 : public GarbageCollectedFinalized<NullExecutionContext>, |
21 public SecurityContext, | 21 public SecurityContext, |
22 public ExecutionContext { | 22 public ExecutionContext { |
23 USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext); | 23 USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext); |
24 | 24 |
25 public: | 25 public: |
26 NullExecutionContext(); | 26 NullExecutionContext(); |
27 | 27 |
| 28 void SetURL(const KURL& url) { url_ = url; } |
| 29 |
28 void DisableEval(const String&) override {} | 30 void DisableEval(const String&) override {} |
29 String UserAgent() const override { return String(); } | 31 String UserAgent() const override { return String(); } |
30 | 32 |
31 void PostTask( | 33 void PostTask( |
32 TaskType, | 34 TaskType, |
33 const WebTraceLocation&, | 35 const WebTraceLocation&, |
34 std::unique_ptr<ExecutionContextTask>, | 36 std::unique_ptr<ExecutionContextTask>, |
35 const String& task_name_for_instrumentation = g_empty_string) override; | 37 const String& task_name_for_instrumentation = g_empty_string) override; |
36 | 38 |
37 EventTarget* ErrorEventTarget() override { return nullptr; } | 39 EventTarget* ErrorEventTarget() override { return nullptr; } |
38 EventQueue* GetEventQueue() const override { return queue_.Get(); } | 40 EventQueue* GetEventQueue() const override { return queue_.Get(); } |
39 | 41 |
40 bool TasksNeedSuspension() override { return tasks_need_suspension_; } | 42 bool TasksNeedSuspension() override { return tasks_need_suspension_; } |
41 void SetTasksNeedSuspension(bool flag) { tasks_need_suspension_ = flag; } | 43 void SetTasksNeedSuspension(bool flag) { tasks_need_suspension_ = flag; } |
42 | 44 |
43 void DidUpdateSecurityOrigin() override {} | 45 void DidUpdateSecurityOrigin() override {} |
44 SecurityContext& GetSecurityContext() override { return *this; } | 46 SecurityContext& GetSecurityContext() override { return *this; } |
45 DOMTimerCoordinator* Timers() override { return nullptr; } | 47 DOMTimerCoordinator* Timers() override { return nullptr; } |
46 | 48 |
47 void AddConsoleMessage(ConsoleMessage*) override {} | 49 void AddConsoleMessage(ConsoleMessage*) override {} |
48 void ExceptionThrown(ErrorEvent*) override {} | 50 void ExceptionThrown(ErrorEvent*) override {} |
49 | 51 |
50 void SetIsSecureContext(bool); | 52 void SetIsSecureContext(bool); |
51 bool IsSecureContext( | 53 bool IsSecureContext( |
52 String& error_message, | 54 String& error_message, |
53 const SecureContextCheck = kStandardSecureContextCheck) const override; | 55 const SecureContextCheck = kStandardSecureContextCheck) const override; |
54 | 56 |
55 void SetUpSecurityContext(); | 57 void SetUpSecurityContext(); |
56 | 58 |
| 59 using SecurityContext::GetSecurityOrigin; |
| 60 using SecurityContext::GetContentSecurityPolicy; |
| 61 |
57 DEFINE_INLINE_TRACE() { | 62 DEFINE_INLINE_TRACE() { |
58 visitor->Trace(queue_); | 63 visitor->Trace(queue_); |
59 SecurityContext::Trace(visitor); | 64 SecurityContext::Trace(visitor); |
60 ExecutionContext::Trace(visitor); | 65 ExecutionContext::Trace(visitor); |
61 } | 66 } |
62 | 67 |
63 protected: | 68 protected: |
64 const KURL& VirtualURL() const override { return dummy_url_; } | 69 const KURL& VirtualURL() const override { return url_; } |
65 KURL VirtualCompleteURL(const String&) const override { return dummy_url_; } | 70 KURL VirtualCompleteURL(const String&) const override { return url_; } |
66 | 71 |
67 private: | 72 private: |
68 bool tasks_need_suspension_; | 73 bool tasks_need_suspension_; |
69 bool is_secure_context_; | 74 bool is_secure_context_; |
70 Member<EventQueue> queue_; | 75 Member<EventQueue> queue_; |
71 | 76 |
72 KURL dummy_url_; | 77 KURL url_; |
73 }; | 78 }; |
74 | 79 |
75 } // namespace blink | 80 } // namespace blink |
76 | 81 |
77 #endif // NullExecutionContext_h | 82 #endif // NullExecutionContext_h |
OLD | NEW |