Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: third_party/WebKit/Source/core/inspector/InjectedScriptHost.h

Issue 1648523002: DevTools: move InjectedScript* to inspector/v8. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 "bindings/core/v8/ScriptState.h"
34 #include "core/InspectorTypeBuilder.h"
35 #include "core/inspector/InjectedScriptHostClient.h"
36 #include "wtf/Functional.h"
37 #include "wtf/PassOwnPtr.h"
38 #include "wtf/RefCounted.h"
39 #include "wtf/Vector.h"
40 #include "wtf/text/WTFString.h"
41 #include <v8.h>
42
43 namespace blink {
44
45 class EventTarget;
46 class InjectedScriptHostClient;
47 class InspectorConsoleAgent;
48 class JSONValue;
49 class V8DebuggerAgent;
50 class V8Debugger;
51
52 class EventListenerInfo;
53
54 // SECURITY NOTE: Although the InjectedScriptHost is intended for use solely by the inspector,
55 // a reference to the InjectedScriptHost may be leaked to the page being inspect ed. Thus, the
56 // InjectedScriptHost must never implemment methods that have more power over th e page than the
57 // page already has itself (e.g. origin restriction bypasses).
58
59 class InjectedScriptHost : public RefCounted<InjectedScriptHost> {
60 public:
61 static PassRefPtr<InjectedScriptHost> create();
62 ~InjectedScriptHost();
63
64 using InspectCallback = Function<void(PassRefPtr<TypeBuilder::Runtime::Remot eObject>, PassRefPtr<JSONObject>)>;
65 using ClearConsoleCallback = Function<void()>;
66
67 void init(V8DebuggerAgent* debuggerAgent, PassOwnPtr<InspectCallback> inspec tCallback, PassOwnPtr<ClearConsoleCallback> clearConsoleCallback, V8Debugger* de bugger, PassOwnPtr<InjectedScriptHostClient> injectedScriptHostClient)
68 {
69 m_debuggerAgent = debuggerAgent;
70 m_inspectCallback = std::move(inspectCallback);
71 m_clearConsoleCallback = std::move(clearConsoleCallback);
72 m_debugger = debugger;
73 m_client = std::move(injectedScriptHostClient);
74 }
75
76 void disconnect();
77
78 class InspectableObject {
79 USING_FAST_MALLOC(InspectableObject);
80 public:
81 virtual v8::Local<v8::Value> get(v8::Local<v8::Context>);
82 virtual ~InspectableObject() { }
83 };
84 void addInspectedObject(PassOwnPtr<InspectableObject>);
85 void clearInspectedObjects();
86 InspectableObject* inspectedObject(unsigned num);
87
88 void inspectImpl(PassRefPtr<JSONValue> objectToInspect, PassRefPtr<JSONValue > hints);
89
90 void clearConsoleMessages();
91 void debugFunction(const String& scriptId, int lineNumber, int columnNumber) ;
92 void undebugFunction(const String& scriptId, int lineNumber, int columnNumbe r);
93 void monitorFunction(const String& scriptId, int lineNumber, int columnNumbe r, const String& functionName);
94 void unmonitorFunction(const String& scriptId, int lineNumber, int columnNum ber);
95
96 V8Debugger& debugger() { return *m_debugger; }
97 InjectedScriptHostClient* client() { return m_client.get(); }
98
99 // FIXME: store this template in per isolate data
100 void setWrapperTemplate(v8::Local<v8::FunctionTemplate> wrapperTemplate, v8: :Isolate* isolate) { m_wrapperTemplate.Reset(isolate, wrapperTemplate); }
101 v8::Local<v8::FunctionTemplate> wrapperTemplate(v8::Isolate* isolate) { retu rn v8::Local<v8::FunctionTemplate>::New(isolate, m_wrapperTemplate); }
102
103 private:
104 InjectedScriptHost();
105
106 V8DebuggerAgent* m_debuggerAgent;
107 OwnPtr<InspectCallback> m_inspectCallback;
108 OwnPtr<ClearConsoleCallback> m_clearConsoleCallback;
109 V8Debugger* m_debugger;
110 Vector<OwnPtr<InspectableObject>> m_inspectedObjects;
111 OwnPtr<InspectableObject> m_defaultInspectableObject;
112 OwnPtr<InjectedScriptHostClient> m_client;
113 v8::Global<v8::FunctionTemplate> m_wrapperTemplate;
114 };
115
116 } // namespace blink
117
118 #endif // InjectedScriptHost_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698