| OLD | NEW |
| (Empty) |
| 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 "DRTDevToolsAgent.h" | |
| 33 | |
| 34 #include "DRTDevToolsClient.h" | |
| 35 | |
| 36 #include "Task.h" | |
| 37 #include "WebDevToolsAgent.h" | |
| 38 #include "WebView.h" | |
| 39 #include "webkit/support/webkit_support.h" | |
| 40 #include "public/platform/WebCString.h" | |
| 41 | |
| 42 using namespace WebKit; | |
| 43 using namespace WebTestRunner; | |
| 44 | |
| 45 DRTDevToolsAgent::DRTDevToolsAgent() | |
| 46 : m_drtDevToolsClient(0) | |
| 47 , m_webView(0) | |
| 48 { | |
| 49 static int devToolsAgentCounter = 0; | |
| 50 | |
| 51 m_routingID = ++devToolsAgentCounter; | |
| 52 } | |
| 53 | |
| 54 void DRTDevToolsAgent::reset() | |
| 55 { | |
| 56 m_taskList.revokeAll(); | |
| 57 } | |
| 58 | |
| 59 void DRTDevToolsAgent::setWebView(WebView* webView) | |
| 60 { | |
| 61 m_webView = webView; | |
| 62 } | |
| 63 | |
| 64 void DRTDevToolsAgent::sendMessageToInspectorFrontend(const WebString& data) | |
| 65 { | |
| 66 if (m_drtDevToolsClient) | |
| 67 m_drtDevToolsClient->asyncCall(data); | |
| 68 } | |
| 69 | |
| 70 void DRTDevToolsAgent::runtimePropertyChanged(const WebString& name, const WebSt
ring& value) | |
| 71 { | |
| 72 // FIXME: Implement. | |
| 73 } | |
| 74 | |
| 75 WebDevToolsAgentClient::WebKitClientMessageLoop* DRTDevToolsAgent::createClientM
essageLoop() | |
| 76 { | |
| 77 return webkit_support::CreateDevToolsMessageLoop(); | |
| 78 } | |
| 79 | |
| 80 void DRTDevToolsAgent::asyncCall(const WebString& args) | |
| 81 { | |
| 82 postTask(new AsyncCallTask(this, args)); | |
| 83 } | |
| 84 | |
| 85 void DRTDevToolsAgent::call(const WebString& args) | |
| 86 { | |
| 87 WebDevToolsAgent* agent = webDevToolsAgent(); | |
| 88 if (agent) | |
| 89 agent->dispatchOnInspectorBackend(args); | |
| 90 } | |
| 91 | |
| 92 WebDevToolsAgent* DRTDevToolsAgent::webDevToolsAgent() | |
| 93 { | |
| 94 if (!m_webView) | |
| 95 return 0; | |
| 96 return m_webView->devToolsAgent(); | |
| 97 } | |
| 98 | |
| 99 void DRTDevToolsAgent::attach(DRTDevToolsClient* client) | |
| 100 { | |
| 101 ASSERT(!m_drtDevToolsClient); | |
| 102 m_drtDevToolsClient = client; | |
| 103 WebDevToolsAgent* agent = webDevToolsAgent(); | |
| 104 if (agent) | |
| 105 agent->attach(); | |
| 106 } | |
| 107 | |
| 108 void DRTDevToolsAgent::detach() | |
| 109 { | |
| 110 ASSERT(m_drtDevToolsClient); | |
| 111 WebDevToolsAgent* agent = webDevToolsAgent(); | |
| 112 if (agent) | |
| 113 agent->detach(); | |
| 114 m_drtDevToolsClient = 0; | |
| 115 } | |
| 116 | |
| 117 bool DRTDevToolsAgent::evaluateInWebInspector(long callID, const std::string& sc
ript) | |
| 118 { | |
| 119 WebDevToolsAgent* agent = webDevToolsAgent(); | |
| 120 if (!agent) | |
| 121 return false; | |
| 122 agent->evaluateInWebInspector(callID, WebString::fromUTF8(script)); | |
| 123 return true; | |
| 124 } | |
| OLD | NEW |