OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/tools/test_shell/test_shell_devtools_agent.h" | 5 #include "webkit/tools/test_shell/test_shell_devtools_agent.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "grit/webkit_chromium_resources.h" | 9 #include "grit/webkit_chromium_resources.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 virtual void quitNow() { | 37 virtual void quitNow() { |
38 message_loop_->QuitNow(); | 38 message_loop_->QuitNow(); |
39 } | 39 } |
40 private: | 40 private: |
41 MessageLoop* message_loop_; | 41 MessageLoop* message_loop_; |
42 }; | 42 }; |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 // static | |
47 void TestShellDevToolsAgent::DispatchMessageLoop() { | |
48 MessageLoop* current = MessageLoop::current(); | |
49 bool old_state = current->NestableTasksAllowed(); | |
50 current->SetNestableTasksAllowed(true); | |
51 current->RunAllPending(); | |
52 current->SetNestableTasksAllowed(old_state); | |
53 } | |
54 | |
55 TestShellDevToolsAgent::TestShellDevToolsAgent() | 46 TestShellDevToolsAgent::TestShellDevToolsAgent() |
56 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 47 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
57 dev_tools_client_(NULL) { | 48 dev_tools_client_(NULL) { |
58 static int dev_tools_agent_counter; | 49 static int dev_tools_agent_counter; |
59 routing_id_ = ++dev_tools_agent_counter; | 50 routing_id_ = ++dev_tools_agent_counter; |
60 if (routing_id_ == 1) | |
61 WebDevToolsAgent::setMessageLoopDispatchHandler( | |
62 &TestShellDevToolsAgent::DispatchMessageLoop); | |
63 } | 51 } |
64 | 52 |
65 TestShellDevToolsAgent::~TestShellDevToolsAgent() { | 53 TestShellDevToolsAgent::~TestShellDevToolsAgent() { |
66 } | 54 } |
67 | 55 |
68 void TestShellDevToolsAgent::SetWebView(WebKit::WebView* web_view) { | 56 void TestShellDevToolsAgent::SetWebView(WebKit::WebView* web_view) { |
69 web_view_ = web_view; | 57 web_view_ = web_view; |
70 } | 58 } |
71 | 59 |
72 void TestShellDevToolsAgent::sendMessageToInspectorFrontend( | 60 void TestShellDevToolsAgent::sendMessageToInspectorFrontend( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 130 |
143 bool TestShellDevToolsAgent::evaluateInWebInspector( | 131 bool TestShellDevToolsAgent::evaluateInWebInspector( |
144 long call_id, | 132 long call_id, |
145 const std::string& script) { | 133 const std::string& script) { |
146 WebDevToolsAgent* agent = GetWebAgent(); | 134 WebDevToolsAgent* agent = GetWebAgent(); |
147 if (!agent) | 135 if (!agent) |
148 return false; | 136 return false; |
149 agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); | 137 agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script)); |
150 return true; | 138 return true; |
151 } | 139 } |
OLD | NEW |