2 * Copyright (C) 2014 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef JSGlobalObjectInspectorController_h
27 #define JSGlobalObjectInspectorController_h
29 #include "InspectorAgentRegistry.h"
30 #include "InspectorEnvironment.h"
31 #include <wtf/Forward.h>
32 #include <wtf/Noncopyable.h>
33 #include <wtf/text/WTFString.h>
35 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
36 #include "AugmentableInspectorController.h"
54 class BackendDispatcher
;
55 class FrontendChannel
;
56 class InjectedScriptManager
;
58 class InspectorConsoleAgent
;
59 class InspectorDebuggerAgent
;
60 class JSGlobalObjectConsoleClient
;
61 class ScriptCallStack
;
63 class JSGlobalObjectInspectorController final
64 : public InspectorEnvironment
65 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
66 , public AugmentableInspectorController
69 WTF_MAKE_NONCOPYABLE(JSGlobalObjectInspectorController
);
70 WTF_MAKE_FAST_ALLOCATED
;
72 JSGlobalObjectInspectorController(JSC::JSGlobalObject
&);
73 ~JSGlobalObjectInspectorController();
75 void connectFrontend(FrontendChannel
*, bool isAutomaticInspection
);
76 void disconnectFrontend(DisconnectReason
);
77 void dispatchMessageFromFrontend(const String
&);
79 void globalObjectDestroyed();
81 bool includesNativeCallStackWhenReportingExceptions() const { return m_includeNativeCallStackWithExceptions
; }
82 void setIncludesNativeCallStackWhenReportingExceptions(bool includesNativeCallStack
) { m_includeNativeCallStackWithExceptions
= includesNativeCallStack
; }
85 void reportAPIException(JSC::ExecState
*, JSC::Exception
*);
87 JSC::ConsoleClient
* consoleClient() const;
89 virtual bool developerExtrasEnabled() const override
;
90 virtual bool canAccessInspectedScriptState(JSC::ExecState
*) const override
{ return true; }
91 virtual InspectorFunctionCallHandler
functionCallHandler() const override
;
92 virtual InspectorEvaluateHandler
evaluateHandler() const override
;
93 virtual void willCallInjectedScriptFunction(JSC::ExecState
*, const String
&, int) override
{ }
94 virtual void didCallInjectedScriptFunction(JSC::ExecState
*) override
{ }
95 virtual void frontendInitialized() override
;
96 virtual Ref
<WTF::Stopwatch
> executionStopwatch() override
;
98 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
99 virtual AugmentableInspectorControllerClient
* augmentableInspectorControllerClient() const override
{ return m_augmentingClient
; }
100 virtual void setAugmentableInspectorControllerClient(AugmentableInspectorControllerClient
* client
) override
{ m_augmentingClient
= client
; }
102 virtual FrontendChannel
* frontendChannel() const override
{ return m_frontendChannel
; }
103 virtual void appendExtraAgent(std::unique_ptr
<InspectorAgentBase
>) override
;
107 void appendAPIBacktrace(ScriptCallStack
* callStack
);
109 JSC::JSGlobalObject
& m_globalObject
;
110 std::unique_ptr
<InjectedScriptManager
> m_injectedScriptManager
;
111 std::unique_ptr
<JSGlobalObjectConsoleClient
> m_consoleClient
;
112 InspectorAgent
* m_inspectorAgent
;
113 InspectorConsoleAgent
* m_consoleAgent
;
114 InspectorDebuggerAgent
* m_debuggerAgent
;
115 AgentRegistry m_agents
;
116 FrontendChannel
* m_frontendChannel
;
117 RefPtr
<BackendDispatcher
> m_backendDispatcher
;
118 Ref
<WTF::Stopwatch
> m_executionStopwatch
;
119 bool m_includeNativeCallStackWithExceptions
;
120 bool m_isAutomaticInspection
;
122 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
123 AugmentableInspectorControllerClient
* m_augmentingClient
;
127 } // namespace Inspector
129 #endif // !defined(JSGlobalObjectInspectorController_h)