OLD | NEW |
(Empty) | |
| 1 // Copyright 2011, Google Inc. |
| 2 // All rights reserved. |
| 3 // |
| 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are |
| 6 // met: |
| 7 // |
| 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above |
| 11 // copyright notice, this list of conditions and the following disclaimer |
| 12 // in the documentation and/or other materials provided with the |
| 13 // distribution. |
| 14 // * Neither the name of Google Inc. nor the names of its |
| 15 // contributors may be used to endorse or promote products derived from |
| 16 // this software without specific prior written permission. |
| 17 // |
| 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 |
| 30 #ifndef DartController_h |
| 31 #define DartController_h |
| 32 |
| 33 #include "DartApplicationLoader.h" |
| 34 #include "ScriptSourceCode.h" |
| 35 |
| 36 #include <dart_api.h> |
| 37 #include <wtf/Vector.h> |
| 38 #include <wtf/text/WTFString.h> |
| 39 |
| 40 struct NPObject; |
| 41 |
| 42 namespace WebCore { |
| 43 |
| 44 class Frame; |
| 45 class ScriptExecutionContext; |
| 46 |
| 47 // VM state per single Dart <SCRIPT> tag. |
| 48 class DartPerScriptState { |
| 49 public: |
| 50 PassRefPtr<DartApplicationLoader> dartApplicationLoader() { return m_dartApp
licationLoader; } |
| 51 Dart_Isolate isolate() { return m_isolate; } |
| 52 |
| 53 DartPerScriptState(Document*, NPObject* layoutTestController); |
| 54 ~DartPerScriptState(); |
| 55 |
| 56 private: |
| 57 RefPtr<DartApplicationLoader> m_dartApplicationLoader; |
| 58 Dart_Isolate m_isolate; |
| 59 }; |
| 60 |
| 61 // This class provides the linkage between a Frame and its attached |
| 62 // Dart isolates. It is similar to ScriptController for JavaScript. |
| 63 // The DartController is owned by its Frame. |
| 64 class DartController { |
| 65 public: |
| 66 DartController(Frame*); |
| 67 |
| 68 bool isScriptTypeSupported(const String& mimeType); |
| 69 void evaluate(const ScriptSourceCode&); |
| 70 |
| 71 // Creates a property of the global object of a frame. |
| 72 void bindToWindowObject(Frame*, const String& key, NPObject*); |
| 73 |
| 74 // FIXME: proper implementation. |
| 75 static bool processingUserGesture() { return false; } |
| 76 |
| 77 void clearWindowShell(); |
| 78 |
| 79 Dart_Handle callFunction(Dart_Handle function, int argc, Dart_Handle* argv); |
| 80 |
| 81 Frame* frame() const { return m_frame; } |
| 82 |
| 83 static DartController* retrieve(Frame*); |
| 84 static DartController* retrieve(ScriptExecutionContext*); |
| 85 |
| 86 static void setDartVMFlags(const String&); |
| 87 |
| 88 static void setupDOMEnabledIsolate(ScriptExecutionContext*); |
| 89 |
| 90 private: |
| 91 static void initVMIfNeeded(); |
| 92 static bool initializeIsolateCallback(void*, char** errorMsg); |
| 93 |
| 94 void didLeaveScriptContext(int recursion); |
| 95 |
| 96 // The frame that owns this controller. |
| 97 Frame* m_frame; |
| 98 |
| 99 typedef Vector< OwnPtr<DartPerScriptState> > DartScriptsList; |
| 100 // Dart VM states associated with scripts in this document. |
| 101 DartScriptsList m_states; |
| 102 |
| 103 // NPObject for layoutTestController if any. |
| 104 NPObject* m_layoutTestController; |
| 105 }; |
| 106 |
| 107 } |
| 108 |
| 109 #endif // DartController_h |
OLD | NEW |