| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 return "application/javascript"; | 257 return "application/javascript"; |
| 258 } else if (EndsWith(filename, ".png", false)) { | 258 } else if (EndsWith(filename, ".png", false)) { |
| 259 return "image/png"; | 259 return "image/png"; |
| 260 } else if (EndsWith(filename, ".gif", false)) { | 260 } else if (EndsWith(filename, ".gif", false)) { |
| 261 return "image/gif"; | 261 return "image/gif"; |
| 262 } | 262 } |
| 263 NOTREACHED(); | 263 NOTREACHED(); |
| 264 return "text/plain"; | 264 return "text/plain"; |
| 265 } | 265 } |
| 266 | 266 |
| 267 void DevToolsHttpHandlerImpl::Observe(int type, | |
| 268 const NotificationSource& source, | |
| 269 const NotificationDetails& details) { | |
| 270 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); | |
| 271 DevToolsManager* manager = DevToolsManager::GetInstance(); | |
| 272 for (ConnectionToClientHostMap::iterator it = | |
| 273 connection_to_client_host_ui_.begin(); | |
| 274 it != connection_to_client_host_ui_.end(); ++it) { | |
| 275 DevToolsAgentHost* agent = manager->GetDevToolsAgentHostFor(it->second); | |
| 276 if (!agent) | |
| 277 continue; | |
| 278 RenderViewHost* rvh = agent->GetRenderViewHost(); | |
| 279 if (rvh && rvh->GetProcess() == process) | |
| 280 it->second->InspectedContentsClosing(); | |
| 281 } | |
| 282 } | |
| 283 | |
| 284 void DevToolsHttpHandlerImpl::OnHttpRequest( | 267 void DevToolsHttpHandlerImpl::OnHttpRequest( |
| 285 int connection_id, | 268 int connection_id, |
| 286 const net::HttpServerRequestInfo& info) { | 269 const net::HttpServerRequestInfo& info) { |
| 287 if (info.path.find("/json") == 0) { | 270 if (info.path.find("/json") == 0) { |
| 288 BrowserThread::PostTask( | 271 BrowserThread::PostTask( |
| 289 BrowserThread::UI, | 272 BrowserThread::UI, |
| 290 FROM_HERE, | 273 FROM_HERE, |
| 291 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI, | 274 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI, |
| 292 this, | 275 this, |
| 293 connection_id, | 276 connection_id, |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 DevToolsHttpHandlerDelegate* delegate) | 628 DevToolsHttpHandlerDelegate* delegate) |
| 646 : overridden_frontend_url_(frontend_url), | 629 : overridden_frontend_url_(frontend_url), |
| 647 socket_factory_(socket_factory), | 630 socket_factory_(socket_factory), |
| 648 delegate_(delegate) { | 631 delegate_(delegate) { |
| 649 if (overridden_frontend_url_.empty()) | 632 if (overridden_frontend_url_.empty()) |
| 650 overridden_frontend_url_ = "/devtools/devtools.html"; | 633 overridden_frontend_url_ = "/devtools/devtools.html"; |
| 651 | 634 |
| 652 default_binding_.reset(new DevToolsDefaultBindingHandler); | 635 default_binding_.reset(new DevToolsDefaultBindingHandler); |
| 653 binding_ = default_binding_.get(); | 636 binding_ = default_binding_.get(); |
| 654 | 637 |
| 655 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, | |
| 656 NotificationService::AllBrowserContextsAndSources()); | |
| 657 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, | |
| 658 NotificationService::AllBrowserContextsAndSources()); | |
| 659 | |
| 660 // Balanced in ResetHandlerThreadAndRelease(). | 638 // Balanced in ResetHandlerThreadAndRelease(). |
| 661 AddRef(); | 639 AddRef(); |
| 662 } | 640 } |
| 663 | 641 |
| 664 // Runs on the handler thread | 642 // Runs on the handler thread |
| 665 void DevToolsHttpHandlerImpl::Init() { | 643 void DevToolsHttpHandlerImpl::Init() { |
| 666 server_ = new net::HttpServer(*socket_factory_.get(), this); | 644 server_ = new net::HttpServer(*socket_factory_.get(), this); |
| 667 } | 645 } |
| 668 | 646 |
| 669 // Runs on the handler thread | 647 // Runs on the handler thread |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 std::string devtools_frontend_url = GetFrontendURLInternal( | 778 std::string devtools_frontend_url = GetFrontendURLInternal( |
| 801 id.c_str(), | 779 id.c_str(), |
| 802 host); | 780 host); |
| 803 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url); | 781 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url); |
| 804 } | 782 } |
| 805 dictionary->SetString("description", delegate_->GetViewDescription(rvh)); | 783 dictionary->SetString("description", delegate_->GetViewDescription(rvh)); |
| 806 return dictionary; | 784 return dictionary; |
| 807 } | 785 } |
| 808 | 786 |
| 809 } // namespace content | 787 } // namespace content |
| OLD | NEW |