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 24 matching lines...) Expand all Loading... | |
35 #include "content/public/browser/render_widget_host.h" | 35 #include "content/public/browser/render_widget_host.h" |
36 #include "content/public/common/content_client.h" | 36 #include "content/public/common/content_client.h" |
37 #include "content/public/common/url_constants.h" | 37 #include "content/public/common/url_constants.h" |
38 #include "googleurl/src/gurl.h" | 38 #include "googleurl/src/gurl.h" |
39 #include "grit/devtools_resources_map.h" | 39 #include "grit/devtools_resources_map.h" |
40 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
41 #include "net/base/io_buffer.h" | 41 #include "net/base/io_buffer.h" |
42 #include "net/base/ip_endpoint.h" | 42 #include "net/base/ip_endpoint.h" |
43 #include "net/server/http_server_request_info.h" | 43 #include "net/server/http_server_request_info.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" |
45 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | |
45 #include "ui/base/layout.h" | 46 #include "ui/base/layout.h" |
46 #include "webkit/user_agent/user_agent.h" | 47 #include "webkit/user_agent/user_agent.h" |
47 #include "webkit/user_agent/user_agent_util.h" | 48 #include "webkit/user_agent/user_agent_util.h" |
48 | 49 |
49 namespace content { | 50 namespace content { |
50 | 51 |
51 const int kBufferSize = 16 * 1024; | 52 const int kBufferSize = 16 * 1024; |
52 | 53 |
53 namespace { | 54 namespace { |
54 | 55 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // messages sent for DevToolsClient to a DebuggerShell instance. | 90 // messages sent for DevToolsClient to a DebuggerShell instance. |
90 class DevToolsClientHostImpl : public DevToolsClientHost { | 91 class DevToolsClientHostImpl : public DevToolsClientHost { |
91 public: | 92 public: |
92 DevToolsClientHostImpl( | 93 DevToolsClientHostImpl( |
93 MessageLoop* message_loop, | 94 MessageLoop* message_loop, |
94 net::HttpServer* server, | 95 net::HttpServer* server, |
95 int connection_id) | 96 int connection_id) |
96 : message_loop_(message_loop), | 97 : message_loop_(message_loop), |
97 server_(server), | 98 server_(server), |
98 connection_id_(connection_id), | 99 connection_id_(connection_id), |
99 is_closed_(false) { | 100 is_closed_(false), |
101 detach_reason_("target_closed") { | |
100 } | 102 } |
101 | 103 |
102 ~DevToolsClientHostImpl() {} | 104 ~DevToolsClientHostImpl() {} |
103 | 105 |
104 // DevToolsClientHost interface | 106 // DevToolsClientHost interface |
105 virtual void InspectedContentsClosing() { | 107 virtual void InspectedContentsClosing() { |
106 if (is_closed_) | 108 if (is_closed_) |
107 return; | 109 return; |
108 is_closed_ = true; | 110 is_closed_ = true; |
111 | |
112 std::string response = | |
113 WebKit::WebDevToolsAgent::inspectorDetachedEvent( | |
yurys
2012/11/02 06:59:58
You need to make sure that WebKit is is initialize
| |
114 WebKit::WebString::fromUTF8(detach_reason_)).utf8(); | |
115 message_loop_->PostTask( | |
116 FROM_HERE, | |
117 base::Bind(&net::HttpServer::SendOverWebSocket, | |
118 server_, | |
119 connection_id_, | |
120 response)); | |
121 | |
109 message_loop_->PostTask( | 122 message_loop_->PostTask( |
110 FROM_HERE, | 123 FROM_HERE, |
111 base::Bind(&net::HttpServer::Close, server_, connection_id_)); | 124 base::Bind(&net::HttpServer::Close, server_, connection_id_)); |
112 } | 125 } |
113 | 126 |
114 virtual void DispatchOnInspectorFrontend(const std::string& data) { | 127 virtual void DispatchOnInspectorFrontend(const std::string& data) { |
115 message_loop_->PostTask( | 128 message_loop_->PostTask( |
116 FROM_HERE, | 129 FROM_HERE, |
117 base::Bind(&net::HttpServer::SendOverWebSocket, | 130 base::Bind(&net::HttpServer::SendOverWebSocket, |
118 server_, | 131 server_, |
119 connection_id_, | 132 connection_id_, |
120 data)); | 133 data)); |
121 } | 134 } |
122 | 135 |
123 virtual void ContentsReplaced(WebContents* new_contents) { | 136 virtual void ContentsReplaced(WebContents* new_contents) { |
124 } | 137 } |
125 | 138 |
139 virtual void ReplacedWithAnotherClient() { | |
140 detach_reason_ = "replaced_with_devtools"; | |
141 } | |
142 | |
126 private: | 143 private: |
127 virtual void FrameNavigating(const std::string& url) {} | 144 virtual void FrameNavigating(const std::string& url) {} |
128 MessageLoop* message_loop_; | 145 MessageLoop* message_loop_; |
129 net::HttpServer* server_; | 146 net::HttpServer* server_; |
130 int connection_id_; | 147 int connection_id_; |
131 bool is_closed_; | 148 bool is_closed_; |
149 std::string detach_reason_; | |
132 }; | 150 }; |
133 | 151 |
134 } // namespace | 152 } // namespace |
135 | 153 |
136 // static | 154 // static |
137 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) { | 155 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) { |
138 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { | 156 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { |
139 if (name == kDevtoolsResources[i].name) | 157 if (name == kDevtoolsResources[i].name) |
140 return kDevtoolsResources[i].value; | 158 return kDevtoolsResources[i].value; |
141 } | 159 } |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 page_info.id.c_str())); | 730 page_info.id.c_str())); |
713 std::string devtools_frontend_url = GetFrontendURLInternal( | 731 std::string devtools_frontend_url = GetFrontendURLInternal( |
714 page_info.id.c_str(), | 732 page_info.id.c_str(), |
715 host); | 733 host); |
716 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url); | 734 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url); |
717 } | 735 } |
718 return dictionary; | 736 return dictionary; |
719 } | 737 } |
720 | 738 |
721 } // namespace content | 739 } // namespace content |
OLD | NEW |