InspectorAgent.h 3.84 KB
Newer Older
1
2
/*
 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011 Google Inc. All rights reserved.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 *     its contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef InspectorAgent_h
#define InspectorAgent_h

33
#include "InspectorBaseAgent.h"
34
#include <wtf/HashMap.h>
35
#include <wtf/PassOwnPtr.h>
36
37
38
39
40
41
#include <wtf/Vector.h>

namespace WebCore {

class DOMWrapperWorld;
class DocumentLoader;
42
class Frame;
43
class InjectedScriptManager;
44
class InspectorInspectorFrontendDispatcher;
45
class InspectorObject;
46
class InstrumentingAgents;
47
48
class Page;

49
50
typedef String ErrorString;

51
class InspectorAgent : public InspectorBaseAgent, public InspectorInspectorBackendDispatcherHandler {
52
53
    WTF_MAKE_NONCOPYABLE(InspectorAgent);
public:
54
    static PassOwnPtr<InspectorAgent> create(Page* page, InjectedScriptManager* injectedScriptManager, InstrumentingAgents* instrumentingAgents)
55
    {
56
        return adoptPtr(new InspectorAgent(page, injectedScriptManager, instrumentingAgents));
57
    }
58

59
    virtual ~InspectorAgent();
60

61
62
63
64
65
    bool developerExtrasEnabled() const;

    // Inspector front-end API.
    void enable(ErrorString*);
    void disable(ErrorString*);
66

67
68
    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
    virtual void willDestroyFrontendAndBackend() OVERRIDE;
69

70
    void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld&);
71

72
73
    void didCommitLoad();
    void domContentLoadedEventFired();
74

75
    bool hasFrontend() const { return !!m_frontendDispatcher; }
76
77
78
79

    // Generic code called from custom implementations.
    void evaluateForTestInFrontend(long testCallId, const String& script);

80
    void setInjectedScriptForOrigin(const String& origin, const String& source);
81

82
    void inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints);
83

84
private:
85
    InspectorAgent(Page*, InjectedScriptManager*, InstrumentingAgents*);
86

87
    Page* m_inspectedPage;
88
    std::unique_ptr<InspectorInspectorFrontendDispatcher> m_frontendDispatcher;
89
    RefPtr<InspectorInspectorBackendDispatcher> m_backendDispatcher;
90
    InjectedScriptManager* m_injectedScriptManager;
91

92
93
94
    Vector<pair<long, String>> m_pendingEvaluateTestCommands;
    pair<RefPtr<TypeBuilder::Runtime::RemoteObject>, RefPtr<InspectorObject>> m_pendingInspectData;
    HashMap<String, String> m_injectedScriptForOrigin;
95
96

    bool m_enabled;
97
98
99
100
101
};

} // namespace WebCore

#endif // !defined(InspectorAgent_h)