| 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/devtools/devtools_http_handler_impl.h" | 5 #include "content/browser/devtools/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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 return "application/javascript"; | 271 return "application/javascript"; |
| 272 } else if (EndsWith(filename, ".png", false)) { | 272 } else if (EndsWith(filename, ".png", false)) { |
| 273 return "image/png"; | 273 return "image/png"; |
| 274 } else if (EndsWith(filename, ".gif", false)) { | 274 } else if (EndsWith(filename, ".gif", false)) { |
| 275 return "image/gif"; | 275 return "image/gif"; |
| 276 } | 276 } |
| 277 NOTREACHED(); | 277 NOTREACHED(); |
| 278 return "text/plain"; | 278 return "text/plain"; |
| 279 } | 279 } |
| 280 | 280 |
| 281 void DevToolsHttpHandlerImpl::Observe(int type, | |
| 282 const NotificationSource& source, | |
| 283 const NotificationDetails& details) { | |
| 284 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); | |
| 285 DevToolsManager* manager = DevToolsManager::GetInstance(); | |
| 286 for (ConnectionToClientHostMap::iterator it = | |
| 287 connection_to_client_host_ui_.begin(); | |
| 288 it != connection_to_client_host_ui_.end(); ++it) { | |
| 289 DevToolsAgentHost* agent = manager->GetDevToolsAgentHostFor(it->second); | |
| 290 if (!agent) | |
| 291 continue; | |
| 292 RenderViewHost* rvh = agent->GetRenderViewHost(); | |
| 293 // TODO(kaznacheev) Handle process termination for shared workers. | |
| 294 if (rvh && rvh->GetProcess() == process) | |
| 295 it->second->InspectedContentsClosing(); | |
| 296 } | |
| 297 } | |
| 298 | |
| 299 void DevToolsHttpHandlerImpl::OnHttpRequest( | 281 void DevToolsHttpHandlerImpl::OnHttpRequest( |
| 300 int connection_id, | 282 int connection_id, |
| 301 const net::HttpServerRequestInfo& info) { | 283 const net::HttpServerRequestInfo& info) { |
| 302 if (info.path.find("/json") == 0) { | 284 if (info.path.find("/json") == 0) { |
| 303 BrowserThread::PostTask( | 285 BrowserThread::PostTask( |
| 304 BrowserThread::UI, | 286 BrowserThread::UI, |
| 305 FROM_HERE, | 287 FROM_HERE, |
| 306 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI, | 288 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI, |
| 307 this, | 289 this, |
| 308 connection_id, | 290 connection_id, |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 DevToolsHttpHandlerDelegate* delegate) | 668 DevToolsHttpHandlerDelegate* delegate) |
| 687 : overridden_frontend_url_(frontend_url), | 669 : overridden_frontend_url_(frontend_url), |
| 688 socket_factory_(socket_factory), | 670 socket_factory_(socket_factory), |
| 689 delegate_(delegate) { | 671 delegate_(delegate) { |
| 690 if (overridden_frontend_url_.empty()) | 672 if (overridden_frontend_url_.empty()) |
| 691 overridden_frontend_url_ = "/devtools/devtools.html"; | 673 overridden_frontend_url_ = "/devtools/devtools.html"; |
| 692 | 674 |
| 693 default_binding_.reset(new DevToolsDefaultBindingHandler); | 675 default_binding_.reset(new DevToolsDefaultBindingHandler); |
| 694 binding_ = default_binding_.get(); | 676 binding_ = default_binding_.get(); |
| 695 | 677 |
| 696 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, | |
| 697 NotificationService::AllBrowserContextsAndSources()); | |
| 698 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, | |
| 699 NotificationService::AllBrowserContextsAndSources()); | |
| 700 | |
| 701 // Balanced in ResetHandlerThreadAndRelease(). | 678 // Balanced in ResetHandlerThreadAndRelease(). |
| 702 AddRef(); | 679 AddRef(); |
| 703 } | 680 } |
| 704 | 681 |
| 705 // Runs on the handler thread | 682 // Runs on the handler thread |
| 706 void DevToolsHttpHandlerImpl::Init() { | 683 void DevToolsHttpHandlerImpl::Init() { |
| 707 server_ = new net::HttpServer(*socket_factory_.get(), this); | 684 server_ = new net::HttpServer(*socket_factory_.get(), this); |
| 708 } | 685 } |
| 709 | 686 |
| 710 // Runs on the handler thread | 687 // Runs on the handler thread |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 host.c_str(), | 851 host.c_str(), |
| 875 kPageUrlPrefix, | 852 kPageUrlPrefix, |
| 876 id.c_str())); | 853 id.c_str())); |
| 877 std::string devtools_frontend_url = GetFrontendURLInternal( | 854 std::string devtools_frontend_url = GetFrontendURLInternal( |
| 878 id.c_str(), | 855 id.c_str(), |
| 879 host); | 856 host); |
| 880 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 857 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
| 881 } | 858 } |
| 882 | 859 |
| 883 } // namespace content | 860 } // namespace content |
| OLD | NEW |