• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc. 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 
31 #include "config.h"
32 #include "DRTDevToolsClient.h"
33 
34 #include "DRTDevToolsAgent.h"
35 
36 #include "WebDevToolsAgent.h"
37 #include "WebDevToolsFrontend.h"
38 #include "WebFrame.h"
39 #include "WebScriptSource.h"
40 #include "WebView.h"
41 #include "webkit/support/webkit_support.h"
42 
43 using namespace WebKit;
44 
DRTDevToolsClient(DRTDevToolsAgent * agent,WebView * webView)45 DRTDevToolsClient::DRTDevToolsClient(DRTDevToolsAgent* agent, WebView* webView)
46     : m_webView(webView)
47     , m_drtDevToolsAgent(agent)
48 {
49     m_webDevToolsFrontend.set(WebDevToolsFrontend::create(m_webView,
50                                                           this,
51                                                           WebString::fromUTF8("en-US")));
52     m_drtDevToolsAgent->attach(this);
53 }
54 
~DRTDevToolsClient()55 DRTDevToolsClient::~DRTDevToolsClient()
56 {
57     // There is a chance that the page will be destroyed at detach step of
58     // m_drtDevToolsAgent and we should clean pending requests a bit earlier.
59     m_taskList.revokeAll();
60     if (m_drtDevToolsAgent)
61         m_drtDevToolsAgent->detach();
62 }
63 
reset()64 void DRTDevToolsClient::reset()
65 {
66     m_taskList.revokeAll();
67 }
68 
sendFrontendLoaded()69 void DRTDevToolsClient::sendFrontendLoaded() {
70     if (m_drtDevToolsAgent)
71         m_drtDevToolsAgent->frontendLoaded();
72 }
73 
sendMessageToBackend(const WebString & data)74 void DRTDevToolsClient::sendMessageToBackend(const WebString& data)
75 {
76     if (m_drtDevToolsAgent)
77         m_drtDevToolsAgent->asyncCall(data);
78 }
79 
sendDebuggerCommandToAgent(const WebString & command)80 void DRTDevToolsClient::sendDebuggerCommandToAgent(const WebString& command)
81 {
82     WebDevToolsAgent::executeDebuggerCommand(command, 1);
83 }
84 
activateWindow()85 void DRTDevToolsClient::activateWindow()
86 {
87     // Not implemented.
88 }
89 
closeWindow()90 void DRTDevToolsClient::closeWindow()
91 {
92     // Not implemented.
93 }
94 
dockWindow()95 void DRTDevToolsClient::dockWindow()
96 {
97     // Not implemented.
98 }
99 
undockWindow()100 void DRTDevToolsClient::undockWindow()
101 {
102     // Not implemented.
103 }
104 
asyncCall(const WebString & args)105 void DRTDevToolsClient::asyncCall(const WebString& args)
106 {
107     postTask(new AsyncCallTask(this, args));
108 }
109 
call(const WebString & args)110 void DRTDevToolsClient::call(const WebString& args)
111 {
112     m_webDevToolsFrontend->dispatchOnInspectorFrontend(args);
113 }
114 
115