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 SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ | 5 #ifndef SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ |
6 #define SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ | 6 #define SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ |
7 | 7 |
8 #include "sky/engine/core/dom/ContextLifecycleObserver.h" | 8 #include "sky/engine/core/dom/ContextLifecycleObserver.h" |
9 #include "sky/engine/core/dom/Document.h" | 9 #include "sky/engine/core/dom/Document.h" |
10 #include "sky/engine/core/events/EventTarget.h" | 10 #include "sky/engine/core/events/EventTarget.h" |
11 #include "sky/engine/wtf/RefCounted.h" | 11 #include "sky/engine/wtf/RefCounted.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 class Application; | 14 class Application; |
15 | 15 |
| 16 class LibraryEntry { |
| 17 public: |
| 18 LibraryEntry(PassRefPtr<DartValue> library, TextPosition position) |
| 19 : dart_library_(library), text_position_(position) {} |
| 20 |
| 21 DartValue* library() const { return dart_library_.get(); } |
| 22 const TextPosition& position() const { return text_position_; } |
| 23 |
| 24 private: |
| 25 RefPtr<DartValue> dart_library_; |
| 26 TextPosition text_position_; |
| 27 }; |
| 28 |
16 class AbstractModule : public RefCounted<AbstractModule>, | 29 class AbstractModule : public RefCounted<AbstractModule>, |
17 public EventTargetWithInlineData, | 30 public EventTargetWithInlineData, |
18 public ContextLifecycleObserver { | 31 public ContextLifecycleObserver { |
19 REFCOUNTED_EVENT_TARGET(AbstractModule); | 32 REFCOUNTED_EVENT_TARGET(AbstractModule); |
20 public: | 33 public: |
21 virtual ~AbstractModule(); | 34 virtual ~AbstractModule(); |
22 | 35 |
23 Document* document() const { return document_.get(); } | 36 Document* document() const { return document_.get(); } |
24 const String& url() const { return url_; } | 37 const String& url() const { return url_; } |
25 | 38 |
26 virtual bool isApplication() const { return false; } | 39 virtual bool isApplication() const { return false; } |
27 | 40 |
28 void set_library(RefPtr<DartValue> library) { library_ = library; } | 41 String UrlForLibraryAt(TextPosition); |
29 | 42 |
30 DartValue* library() const { return library_.get(); } | 43 void AddLibrary(RefPtr<DartValue> library, TextPosition position); |
| 44 const Vector<LibraryEntry>& libraries() const { return libraries_; } |
31 | 45 |
32 protected: | 46 protected: |
33 AbstractModule(ExecutionContext*, PassRefPtr<Document>, const String& url); | 47 AbstractModule(ExecutionContext*, PassRefPtr<Document>, const String& url); |
34 | 48 |
35 virtual Application* GetApplication() = 0; | 49 virtual Application* GetApplication() = 0; |
36 | 50 |
37 private: | 51 private: |
38 ExecutionContext* executionContext() const override; | 52 ExecutionContext* executionContext() const override; |
39 | 53 |
40 RefPtr<Document> document_; | 54 RefPtr<Document> document_; |
41 String url_; | 55 String url_; |
42 RefPtr<DartValue> library_; | 56 Vector<LibraryEntry> libraries_; |
43 }; | 57 }; |
44 | 58 |
45 } // namespace blink | 59 } // namespace blink |
46 | 60 |
47 #endif // SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ | 61 #endif // SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ |
OLD | NEW |