tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebCore / inspector / InjectedScriptHost.h
1 /*
2  * Copyright (C) 2007 Apple Inc. All rights reserved.
3  * Copyright (C) 2009 Google Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer. 
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution. 
14  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission. 
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef InjectedScriptHost_h
31 #define InjectedScriptHost_h
32
33 #include "ConsoleTypes.h"
34 #include "InspectorAgent.h"
35 #include "ScriptState.h"
36 #include <wtf/RefCounted.h>
37 #include <wtf/Vector.h>
38
39 namespace WebCore {
40
41 class Database;
42 class InjectedScript;
43 class InspectorAgent;
44 class InspectorConsoleAgent;
45 class InspectorDOMStorageAgent;
46 class InspectorDatabaseAgent;
47 class InspectorFrontend;
48 class InspectorObject;
49 class InspectorValue;
50 class Node;
51 class ScriptObject;
52 class ScriptValue;
53 class Storage;
54
55 class InjectedScriptHost : public RefCounted<InjectedScriptHost> {
56 public:
57     static PassRefPtr<InjectedScriptHost> create();
58     ~InjectedScriptHost();
59
60     void init(InspectorAgent* inspectorAgent
61             , InspectorConsoleAgent* consoleAgent
62 #if ENABLE(SQL_DATABASE)
63             , InspectorDatabaseAgent* databaseAgent
64 #endif
65             , InspectorDOMStorageAgent* domStorageAgent
66         )
67     {
68         m_inspectorAgent = inspectorAgent;
69         m_consoleAgent = consoleAgent;
70 #if ENABLE(SQL_DATABASE)
71         m_databaseAgent = databaseAgent;
72 #endif
73         m_domStorageAgent = domStorageAgent;
74     }
75
76     static Node* scriptValueAsNode(ScriptValue);
77     static ScriptValue nodeAsScriptValue(ScriptState*, Node*);
78
79     void disconnect();
80
81     void addInspectedNode(Node*);
82     void clearInspectedNodes();
83
84     void inspectImpl(PassRefPtr<InspectorValue> objectToInspect, PassRefPtr<InspectorValue> hints);
85     void clearConsoleMessages();
86     void copyText(const String& text);
87     Node* inspectedNode(unsigned int num);
88 #if ENABLE(SQL_DATABASE)
89     int databaseIdImpl(Database*);
90 #endif
91     int storageIdImpl(Storage*);
92 #if ENABLE(WORKERS)
93     long nextWorkerId();
94     void didCreateWorker(long id, const String& url, bool isSharedWorker);
95     void didDestroyWorker(long id);
96 #endif
97
98 private:
99     InjectedScriptHost();
100
101     InspectorAgent* m_inspectorAgent;
102     InspectorConsoleAgent* m_consoleAgent;
103 #if ENABLE(SQL_DATABASE)
104     InspectorDatabaseAgent* m_databaseAgent;
105 #endif
106     InspectorDOMStorageAgent* m_domStorageAgent;
107     long m_lastWorkerId;
108     Vector<RefPtr<Node> > m_inspectedNodes;
109 };
110
111 } // namespace WebCore
112
113 #endif // !defined(InjectedScriptHost_h)