OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/debugger/devtools_http_protocol_handler.h" | 5 #include "chrome/browser/debugger/devtools_http_protocol_handler.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/thread.h" | 11 #include "base/thread.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
14 #include "chrome/browser/browser_thread.h" | 14 #include "chrome/browser/browser_thread.h" |
15 #include "chrome/browser/debugger/devtools_client_host.h" | 15 #include "chrome/browser/debugger/devtools_client_host.h" |
16 #include "chrome/browser/debugger/devtools_manager.h" | 16 #include "chrome/browser/debugger/devtools_manager.h" |
17 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 18 #include "chrome/browser/tab_contents_wrapper.h" |
18 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
19 #include "chrome/browser/tabs/tab_strip_model.h" | 20 #include "chrome/browser/tabs/tab_strip_model.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/common/devtools_messages.h" | 22 #include "chrome/common/devtools_messages.h" |
22 #include "chrome/common/net/url_request_context_getter.h" | 23 #include "chrome/common/net/url_request_context_getter.h" |
23 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
24 #include "net/base/io_buffer.h" | 25 #include "net/base/io_buffer.h" |
25 #include "net/base/listen_socket.h" | 26 #include "net/base/listen_socket.h" |
26 #include "net/server/http_server_request_info.h" | 27 #include "net/server/http_server_request_info.h" |
27 #include "net/url_request/url_request_context.h" | 28 #include "net/url_request/url_request_context.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 167 } |
167 | 168 |
168 void DevToolsHttpProtocolHandler::OnHttpRequestUI( | 169 void DevToolsHttpProtocolHandler::OnHttpRequestUI( |
169 HttpListenSocket* socket, | 170 HttpListenSocket* socket, |
170 const HttpServerRequestInfo& info) { | 171 const HttpServerRequestInfo& info) { |
171 std::string response = "<html><body>"; | 172 std::string response = "<html><body>"; |
172 for (BrowserList::const_iterator it = BrowserList::begin(), | 173 for (BrowserList::const_iterator it = BrowserList::begin(), |
173 end = BrowserList::end(); it != end; ++it) { | 174 end = BrowserList::end(); it != end; ++it) { |
174 TabStripModel* model = (*it)->tabstrip_model(); | 175 TabStripModel* model = (*it)->tabstrip_model(); |
175 for (int i = 0, size = model->count(); i < size; ++i) { | 176 for (int i = 0, size = model->count(); i < size; ++i) { |
176 TabContents* tab_contents = model->GetTabContentsAt(i); | 177 TabContentsWrapper* tab_contents = model->GetTabContentsAt(i); |
177 NavigationController& controller = tab_contents->controller(); | 178 NavigationController& controller = tab_contents->controller(); |
178 NavigationEntry* entry = controller.GetActiveEntry(); | 179 NavigationEntry* entry = controller.GetActiveEntry(); |
179 if (entry == NULL) | 180 if (entry == NULL) |
180 continue; | 181 continue; |
181 | 182 |
182 if (!entry->url().is_valid()) | 183 if (!entry->url().is_valid()) |
183 continue; | 184 continue; |
184 | 185 |
185 DevToolsClientHost* client_host = DevToolsManager::GetInstance()-> | 186 DevToolsClientHost* client_host = DevToolsManager::GetInstance()-> |
186 GetDevToolsClientHostFor(tab_contents->render_view_host()); | 187 GetDevToolsClientHostFor(tab_contents->tab_contents()-> |
| 188 render_view_host()); |
187 if (!client_host) { | 189 if (!client_host) { |
188 response += StringPrintf( | 190 response += StringPrintf( |
189 "<a href='/devtools/devtools.html?page=%d'>%s (%s)</a><br>", | 191 "<a href='/devtools/devtools.html?page=%d'>%s (%s)</a><br>", |
190 controller.session_id().id(), | 192 controller.session_id().id(), |
191 UTF16ToUTF8(entry->title()).c_str(), | 193 UTF16ToUTF8(entry->title()).c_str(), |
192 entry->url().spec().c_str()); | 194 entry->url().spec().c_str()); |
193 } else { | 195 } else { |
194 response += StringPrintf( | 196 response += StringPrintf( |
195 "%s (%s)<br>", | 197 "%s (%s)<br>", |
196 UTF16ToUTF8(entry->title()).c_str(), | 198 UTF16ToUTF8(entry->title()).c_str(), |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 TabStripModel* model = (*it)->tabstrip_model(); | 411 TabStripModel* model = (*it)->tabstrip_model(); |
410 for (int i = 0, size = model->count(); i < size; ++i) { | 412 for (int i = 0, size = model->count(); i < size; ++i) { |
411 NavigationController& controller = | 413 NavigationController& controller = |
412 model->GetTabContentsAt(i)->controller(); | 414 model->GetTabContentsAt(i)->controller(); |
413 if (controller.session_id().id() == session_id) | 415 if (controller.session_id().id() == session_id) |
414 return controller.tab_contents(); | 416 return controller.tab_contents(); |
415 } | 417 } |
416 } | 418 } |
417 return NULL; | 419 return NULL; |
418 } | 420 } |
OLD | NEW |