OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/debugger/devtools_http_handler_impl.h" | 5 #include "content/browser/debugger/devtools_http_handler_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // messages sent for DevToolsClient to a DebuggerShell instance. | 89 // messages sent for DevToolsClient to a DebuggerShell instance. |
90 class DevToolsClientHostImpl : public DevToolsClientHost { | 90 class DevToolsClientHostImpl : public DevToolsClientHost { |
91 public: | 91 public: |
92 DevToolsClientHostImpl( | 92 DevToolsClientHostImpl( |
93 MessageLoop* message_loop, | 93 MessageLoop* message_loop, |
94 net::HttpServer* server, | 94 net::HttpServer* server, |
95 int connection_id) | 95 int connection_id) |
96 : message_loop_(message_loop), | 96 : message_loop_(message_loop), |
97 server_(server), | 97 server_(server), |
98 connection_id_(connection_id), | 98 connection_id_(connection_id), |
99 is_closed_(false) { | 99 is_closed_(false), |
100 detach_reason_("target_closed") { | |
100 } | 101 } |
101 | 102 |
102 ~DevToolsClientHostImpl() {} | 103 ~DevToolsClientHostImpl() {} |
103 | 104 |
104 // DevToolsClientHost interface | 105 // DevToolsClientHost interface |
105 virtual void InspectedContentsClosing() { | 106 virtual void InspectedContentsClosing() { |
106 if (is_closed_) | 107 if (is_closed_) |
107 return; | 108 return; |
108 is_closed_ = true; | 109 is_closed_ = true; |
110 | |
111 std::string response; | |
112 DictionaryValue message; | |
113 message.SetString("method", "Inspector.detached"); | |
114 DictionaryValue* params = new DictionaryValue(); | |
115 message.Set("params", params); | |
116 params->SetString("reason", detach_reason_); | |
117 base::JSONWriter::WriteWithOptions(&message, | |
yurys
2012/11/01 15:37:11
Can you provide a method in WebKit API that would
pfeldman
2012/11/01 16:24:49
We can't delegate it to the dying renderer, but I
pfeldman
2012/11/01 16:54:32
Done.
| |
118 base::JSONWriter::OPTIONS_PRETTY_PRINT, | |
119 &response); | |
120 message_loop_->PostTask( | |
121 FROM_HERE, | |
122 base::Bind(&net::HttpServer::SendOverWebSocket, | |
123 server_, | |
124 connection_id_, | |
125 response)); | |
126 | |
109 message_loop_->PostTask( | 127 message_loop_->PostTask( |
110 FROM_HERE, | 128 FROM_HERE, |
111 base::Bind(&net::HttpServer::Close, server_, connection_id_)); | 129 base::Bind(&net::HttpServer::Close, server_, connection_id_)); |
112 } | 130 } |
113 | 131 |
114 virtual void DispatchOnInspectorFrontend(const std::string& data) { | 132 virtual void DispatchOnInspectorFrontend(const std::string& data) { |
115 message_loop_->PostTask( | 133 message_loop_->PostTask( |
116 FROM_HERE, | 134 FROM_HERE, |
117 base::Bind(&net::HttpServer::SendOverWebSocket, | 135 base::Bind(&net::HttpServer::SendOverWebSocket, |
118 server_, | 136 server_, |
119 connection_id_, | 137 connection_id_, |
120 data)); | 138 data)); |
121 } | 139 } |
122 | 140 |
123 virtual void ContentsReplaced(WebContents* new_contents) { | 141 virtual void ContentsReplaced(WebContents* new_contents) { |
124 } | 142 } |
125 | 143 |
144 virtual void ReplacedWithAnotherClient() { | |
145 detach_reason_ = "replaced_with_devtools"; | |
146 } | |
147 | |
126 private: | 148 private: |
127 virtual void FrameNavigating(const std::string& url) {} | 149 virtual void FrameNavigating(const std::string& url) {} |
128 MessageLoop* message_loop_; | 150 MessageLoop* message_loop_; |
129 net::HttpServer* server_; | 151 net::HttpServer* server_; |
130 int connection_id_; | 152 int connection_id_; |
131 bool is_closed_; | 153 bool is_closed_; |
154 std::string detach_reason_; | |
132 }; | 155 }; |
133 | 156 |
134 } // namespace | 157 } // namespace |
135 | 158 |
136 // static | 159 // static |
137 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) { | 160 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) { |
138 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { | 161 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { |
139 if (name == kDevtoolsResources[i].name) | 162 if (name == kDevtoolsResources[i].name) |
140 return kDevtoolsResources[i].value; | 163 return kDevtoolsResources[i].value; |
141 } | 164 } |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 page_info.id.c_str())); | 735 page_info.id.c_str())); |
713 std::string devtools_frontend_url = GetFrontendURLInternal( | 736 std::string devtools_frontend_url = GetFrontendURLInternal( |
714 page_info.id.c_str(), | 737 page_info.id.c_str(), |
715 host); | 738 host); |
716 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url); | 739 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url); |
717 } | 740 } |
718 return dictionary; | 741 return dictionary; |
719 } | 742 } |
720 | 743 |
721 } // namespace content | 744 } // namespace content |
OLD | NEW |