Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: content/browser/devtools/devtools_http_handler_impl.cc

Issue 12319114: Extract debugger target enumeration into a separate class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@debugger
Patch Set: Rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/message_loop_proxy.h" 16 #include "base/message_loop_proxy.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/stringprintf.h"
19 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
20 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
21 #include "base/values.h" 20 #include "base/values.h"
22 #include "content/browser/devtools/devtools_agent_host_impl.h"
23 #include "content/browser/devtools/devtools_browser_target.h" 21 #include "content/browser/devtools/devtools_browser_target.h"
24 #include "content/browser/devtools/devtools_tracing_handler.h" 22 #include "content/browser/devtools/devtools_tracing_handler.h"
25 #include "content/browser/renderer_host/render_view_host_impl.h"
26 #include "content/browser/web_contents/web_contents_impl.h" 23 #include "content/browser/web_contents/web_contents_impl.h"
27 #include "content/common/devtools_messages.h" 24 #include "content/common/devtools_messages.h"
28 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/devtools_agent_host.h" 26 #include "content/public/browser/devtools_agent_host.h"
30 #include "content/public/browser/devtools_client_host.h" 27 #include "content/public/browser/devtools_client_host.h"
31 #include "content/public/browser/devtools_http_handler_delegate.h" 28 #include "content/public/browser/devtools_http_handler_delegate.h"
32 #include "content/public/browser/devtools_manager.h" 29 #include "content/public/browser/devtools_manager.h"
33 #include "content/public/browser/favicon_status.h" 30 #include "content/public/browser/favicon_status.h"
34 #include "content/public/browser/navigation_entry.h" 31 #include "content/public/browser/navigation_entry.h"
35 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/notification_types.h" 33 #include "content/public/browser/notification_types.h"
37 #include "content/public/browser/render_process_host.h"
38 #include "content/public/browser/render_view_host.h" 34 #include "content/public/browser/render_view_host.h"
39 #include "content/public/browser/render_widget_host.h"
40 #include "content/public/common/content_client.h" 35 #include "content/public/common/content_client.h"
41 #include "content/public/common/url_constants.h" 36 #include "content/public/common/url_constants.h"
42 #include "googleurl/src/gurl.h" 37 #include "googleurl/src/gurl.h"
43 #include "grit/devtools_resources_map.h" 38 #include "grit/devtools_resources_map.h"
44 #include "net/base/escape.h" 39 #include "net/base/escape.h"
45 #include "net/base/io_buffer.h" 40 #include "net/base/io_buffer.h"
46 #include "net/base/ip_endpoint.h" 41 #include "net/base/ip_endpoint.h"
47 #include "net/server/http_server_request_info.h" 42 #include "net/server/http_server_request_info.h"
48 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 43 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h"
50 #include "ui/base/layout.h" 45 #include "ui/base/layout.h"
51 #include "webkit/user_agent/user_agent.h" 46 #include "webkit/user_agent/user_agent.h"
52 #include "webkit/user_agent/user_agent_util.h" 47 #include "webkit/user_agent/user_agent_util.h"
53 48
54 namespace content { 49 namespace content {
55 50
56 const int kBufferSize = 16 * 1024; 51 const int kBufferSize = 16 * 1024;
57 52
58 namespace { 53 namespace {
59 54
60 static const char* kDevToolsHandlerThreadName = "Chrome_DevToolsHandlerThread"; 55 static const char* kDevToolsHandlerThreadName = "Chrome_DevToolsHandlerThread";
61 56
57 static const char* kThumbUrlPrefix = "/thumb/";
58
62 class DevToolsDefaultBindingHandler 59 class DevToolsDefaultBindingHandler
63 : public DevToolsHttpHandler::DevToolsAgentHostBinding { 60 : public DevToolsHttpHandler::DevToolsAgentHostBinding {
64 public: 61 public:
65 DevToolsDefaultBindingHandler() { 62 DevToolsDefaultBindingHandler() {
66 } 63 }
67 64
68 void GarbageCollect() { 65 void GarbageCollect() {
69 AgentsMap::iterator it = agents_map_.begin(); 66 AgentsMap::iterator it = agents_map_.begin();
70 while (it != agents_map_.end()) { 67 while (it != agents_map_.end()) {
71 if (!it->second->GetRenderViewHost()) 68 if (!it->second->GetRenderViewHost())
72 agents_map_.erase(it++); 69 agents_map_.erase(it++);
73 else 70 else
74 ++it; 71 ++it;
75 } 72 }
76 } 73 }
77 74
78 virtual std::string GetIdentifier(DevToolsAgentHost* agent_host) OVERRIDE { 75 virtual std::string GetIdentifier(DevToolsAgentHost* agent_host) OVERRIDE {
79 GarbageCollect(); 76 GarbageCollect();
80 DevToolsAgentHostImpl* agent_host_impl = 77 std::string id = agent_host->GetId();
81 static_cast<DevToolsAgentHostImpl*>(agent_host);
82 std::string id = base::StringPrintf("%d", agent_host_impl->id());
83 agents_map_[id] = agent_host; 78 agents_map_[id] = agent_host;
84 return id; 79 return id;
85 } 80 }
86 81
87 virtual DevToolsAgentHost* ForIdentifier( 82 virtual DevToolsAgentHost* ForIdentifier(
88 const std::string& identifier) OVERRIDE { 83 const std::string& identifier) OVERRIDE {
89 GarbageCollect(); 84 GarbageCollect();
90 AgentsMap::iterator it = agents_map_.find(identifier); 85 AgentsMap::iterator it = agents_map_.find(identifier);
91 if (it != agents_map_.end()) 86 if (it != agents_map_.end())
92 return it->second; 87 return it->second;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 145 }
151 146
152 private: 147 private:
153 MessageLoop* message_loop_; 148 MessageLoop* message_loop_;
154 net::HttpServer* server_; 149 net::HttpServer* server_;
155 int connection_id_; 150 int connection_id_;
156 bool is_closed_; 151 bool is_closed_;
157 std::string detach_reason_; 152 std::string detach_reason_;
158 }; 153 };
159 154
155 static base::TimeTicks GetLastSelectedTime(RenderViewHost* rvh) {
156 WebContents* web_contents = rvh->GetDelegate()->GetAsWebContents();
157 if (!web_contents)
158 return base::TimeTicks();
159
160 return web_contents->GetLastSelectedTime();
161 }
162
163 typedef std::pair<RenderViewHost*, base::TimeTicks> PageInfo;
164
165 static bool TimeComparator(const PageInfo& info1, const PageInfo& info2) {
166 return info1.second > info2.second;
167 }
168
160 } // namespace 169 } // namespace
161 170
162 // static 171 // static
163 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) { 172 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) {
164 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { 173 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) {
165 if (name == kDevtoolsResources[i].name) 174 if (name == kDevtoolsResources[i].name)
166 return kDevtoolsResources[i].value; 175 return kDevtoolsResources[i].value;
167 } 176 }
168 return -1; 177 return -1;
169 } 178 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 BrowserThread::PostTask( 310 BrowserThread::PostTask(
302 BrowserThread::UI, 311 BrowserThread::UI,
303 FROM_HERE, 312 FROM_HERE,
304 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI, 313 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI,
305 this, 314 this,
306 connection_id, 315 connection_id,
307 info)); 316 info));
308 return; 317 return;
309 } 318 }
310 319
311 if (info.path.find("/thumb/") == 0) { 320 if (info.path.find(kThumbUrlPrefix) == 0) {
312 // Thumbnail request. 321 // Thumbnail request.
322 const std::string target_id = info.path.substr(strlen(kThumbUrlPrefix));
323 DevToolsAgentHost* agent_host = binding_->ForIdentifier(target_id);
324 GURL page_url;
325 if (agent_host) {
326 RenderViewHost* rvh = agent_host->GetRenderViewHost();
327 if (rvh)
328 page_url = rvh->GetDelegate()->GetURL();
329 }
313 BrowserThread::PostTask( 330 BrowserThread::PostTask(
314 BrowserThread::UI, 331 BrowserThread::UI,
315 FROM_HERE, 332 FROM_HERE,
316 base::Bind(&DevToolsHttpHandlerImpl::OnThumbnailRequestUI, 333 base::Bind(&DevToolsHttpHandlerImpl::OnThumbnailRequestUI,
317 this, 334 this,
318 connection_id, 335 connection_id,
319 info)); 336 page_url));
320 return; 337 return;
321 } 338 }
322 339
323 if (info.path == "" || info.path == "/") { 340 if (info.path == "" || info.path == "/") {
324 // Discovery page request. 341 // Discovery page request.
325 BrowserThread::PostTask( 342 BrowserThread::PostTask(
326 BrowserThread::UI, 343 BrowserThread::UI,
327 FROM_HERE, 344 FROM_HERE,
328 base::Bind(&DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI, 345 base::Bind(&DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI,
329 this, 346 this,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 void DevToolsHttpHandlerImpl::OnClose(int connection_id) { 405 void DevToolsHttpHandlerImpl::OnClose(int connection_id) {
389 BrowserThread::PostTask( 406 BrowserThread::PostTask(
390 BrowserThread::UI, 407 BrowserThread::UI,
391 FROM_HERE, 408 FROM_HERE,
392 base::Bind( 409 base::Bind(
393 &DevToolsHttpHandlerImpl::OnCloseUI, 410 &DevToolsHttpHandlerImpl::OnCloseUI,
394 this, 411 this,
395 connection_id)); 412 connection_id));
396 } 413 }
397 414
398 struct DevToolsHttpHandlerImpl::PageInfo {
399 PageInfo()
400 : attached(false) {
401 }
402
403 std::string id;
404 std::string url;
405 std::string type;
406 bool attached;
407 std::string title;
408 std::string thumbnail_url;
409 std::string favicon_url;
410 std::string description;
411 base::TimeTicks last_selected_time;
412 };
413
414 // static
415 bool DevToolsHttpHandlerImpl::SortPageListByTime(const PageInfo& info1,
416 const PageInfo& info2) {
417 return info1.last_selected_time > info2.last_selected_time;
418 }
419
420 DevToolsHttpHandlerImpl::PageList DevToolsHttpHandlerImpl::GeneratePageList() {
421 PageList page_list;
422 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
423 !it.IsAtEnd(); it.Advance()) {
424 RenderProcessHost* render_process_host = it.GetCurrentValue();
425 DCHECK(render_process_host);
426
427 // Ignore processes that don't have a connection, such as crashed contents.
428 if (!render_process_host->HasConnection())
429 continue;
430
431 RenderProcessHost::RenderWidgetHostsIterator rwit(
432 render_process_host->GetRenderWidgetHostsIterator());
433 for (; !rwit.IsAtEnd(); rwit.Advance()) {
434 const RenderWidgetHost* widget = rwit.GetCurrentValue();
435 DCHECK(widget);
436 if (!widget || !widget->IsRenderView())
437 continue;
438
439 RenderViewHost* host =
440 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
441 // Don't report swapped out views.
442 if (static_cast<RenderViewHostImpl*>(host)->is_swapped_out())
443 continue;
444
445 page_list.push_back(CreatePageInfo(host, delegate_->GetTargetType(host)));
446 }
447 }
448 std::sort(page_list.begin(), page_list.end(), SortPageListByTime);
449 return page_list;
450 }
451
452 std::string DevToolsHttpHandlerImpl::GetFrontendURLInternal( 415 std::string DevToolsHttpHandlerImpl::GetFrontendURLInternal(
453 const std::string rvh_id, 416 const std::string rvh_id,
454 const std::string& host) { 417 const std::string& host) {
455 return base::StringPrintf( 418 return base::StringPrintf(
456 "%s%sws=%s/devtools/page/%s", 419 "%s%sws=%s/devtools/page/%s",
457 overridden_frontend_url_.c_str(), 420 overridden_frontend_url_.c_str(),
458 overridden_frontend_url_.find("?") == std::string::npos ? "?" : "&", 421 overridden_frontend_url_.find("?") == std::string::npos ? "?" : "&",
459 host.c_str(), 422 host.c_str(),
460 rvh_id.c_str()); 423 rvh_id.c_str());
461 } 424 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 webkit_glue::GetWebKitVersion()); 488 webkit_glue::GetWebKitVersion());
526 version.SetString("Browser", 489 version.SetString("Browser",
527 content::GetContentClient()->GetProduct()); 490 content::GetContentClient()->GetProduct());
528 version.SetString("User-Agent", 491 version.SetString("User-Agent",
529 webkit_glue::GetUserAgent(GURL(chrome::kAboutBlankURL))); 492 webkit_glue::GetUserAgent(GURL(chrome::kAboutBlankURL)));
530 SendJson(connection_id, net::HTTP_OK, &version, "", jsonp); 493 SendJson(connection_id, net::HTTP_OK, &version, "", jsonp);
531 return; 494 return;
532 } 495 }
533 496
534 if (command == "list") { 497 if (command == "list") {
535 PageList page_list = GeneratePageList(); 498 typedef std::vector<PageInfo> PageList;
499 PageList page_list;
500
501 std::vector<RenderViewHost*> rvh_list =
502 DevToolsAgentHost::GetValidRenderViewHosts();
503 for (std::vector<RenderViewHost*>::iterator it = rvh_list.begin();
504 it != rvh_list.end(); ++it)
505 page_list.push_back(PageInfo(*it, GetLastSelectedTime(*it)));
506
507 std::sort(page_list.begin(), page_list.end(), TimeComparator);
508
536 base::ListValue json_pages_list; 509 base::ListValue json_pages_list;
537 std::string host = info.headers["Host"]; 510 std::string host = info.headers["Host"];
538 for (PageList::iterator i = page_list.begin(); i != page_list.end(); ++i) 511 for (PageList::iterator i = page_list.begin(); i != page_list.end(); ++i)
539 json_pages_list.Append(SerializePageInfo(*i, host)); 512 json_pages_list.Append(SerializePageInfo(i->first, host));
540 SendJson(connection_id, net::HTTP_OK, &json_pages_list, "", jsonp); 513 SendJson(connection_id, net::HTTP_OK, &json_pages_list, "", jsonp);
541 return; 514 return;
542 } 515 }
543 516
544 if (command == "new") { 517 if (command == "new") {
545 RenderViewHost* rvh = delegate_->CreateNewTarget(); 518 RenderViewHost* rvh = delegate_->CreateNewTarget();
546 if (!rvh) { 519 if (!rvh) {
547 SendJson(connection_id, 520 SendJson(connection_id,
548 net::HTTP_INTERNAL_SERVER_ERROR, 521 net::HTTP_INTERNAL_SERVER_ERROR,
549 NULL, 522 NULL,
550 "Could not create new page", 523 "Could not create new page",
551 jsonp); 524 jsonp);
552 return; 525 return;
553 } 526 }
554 PageInfo page_info =
555 CreatePageInfo(rvh, DevToolsHttpHandlerDelegate::kTargetTypeTab);
556 std::string host = info.headers["Host"]; 527 std::string host = info.headers["Host"];
557 scoped_ptr<base::DictionaryValue> dictionary( 528 scoped_ptr<base::DictionaryValue> dictionary(SerializePageInfo(rvh, host));
558 SerializePageInfo(page_info, host));
559 SendJson(connection_id, net::HTTP_OK, dictionary.get(), "", jsonp); 529 SendJson(connection_id, net::HTTP_OK, dictionary.get(), "", jsonp);
560 return; 530 return;
561 } 531 }
562 532
563 if (command == "activate" || command == "close") { 533 if (command == "activate" || command == "close") {
564 DevToolsAgentHost* agent_host = binding_->ForIdentifier(target_id); 534 DevToolsAgentHost* agent_host = binding_->ForIdentifier(target_id);
565 RenderViewHost* rvh = agent_host ? agent_host->GetRenderViewHost() : NULL; 535 RenderViewHost* rvh = agent_host ? agent_host->GetRenderViewHost() : NULL;
566 if (!rvh) { 536 if (!rvh) {
567 SendJson(connection_id, 537 SendJson(connection_id,
568 net::HTTP_NOT_FOUND, 538 net::HTTP_NOT_FOUND,
(...skipping 17 matching lines...) Expand all
586 } 556 }
587 SendJson(connection_id, 557 SendJson(connection_id,
588 net::HTTP_NOT_FOUND, 558 net::HTTP_NOT_FOUND,
589 NULL, 559 NULL,
590 "Unknown command: " + command, 560 "Unknown command: " + command,
591 jsonp); 561 jsonp);
592 return; 562 return;
593 } 563 }
594 564
595 void DevToolsHttpHandlerImpl::OnThumbnailRequestUI( 565 void DevToolsHttpHandlerImpl::OnThumbnailRequestUI(
596 int connection_id, 566 int connection_id, const GURL& page_url) {
597 const net::HttpServerRequestInfo& info) { 567 std::string data = delegate_->GetPageThumbnailData(page_url);
598 std::string prefix = "/thumb/";
599 size_t pos = info.path.find(prefix);
600 if (pos != 0) {
601 Send404(connection_id);
602 return;
603 }
604
605 std::string page_url = info.path.substr(prefix.length());
606 std::string data = delegate_->GetPageThumbnailData(GURL(page_url));
607 if (!data.empty()) 568 if (!data.empty())
608 Send200(connection_id, data, "image/png"); 569 Send200(connection_id, data, "image/png");
609 else 570 else
610 Send404(connection_id); 571 Send404(connection_id);
611 } 572 }
612 573
613 void DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI(int connection_id) { 574 void DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI(int connection_id) {
614 std::string response = delegate_->GetDiscoveryPageHTML(); 575 std::string response = delegate_->GetDiscoveryPageHTML();
615 Send200(connection_id, response, "text/html; charset=UTF-8"); 576 Send200(connection_id, response, "text/html; charset=UTF-8");
616 } 577 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 int connection_id, 797 int connection_id,
837 const net::HttpServerRequestInfo& request) { 798 const net::HttpServerRequestInfo& request) {
838 if (!thread_.get()) 799 if (!thread_.get())
839 return; 800 return;
840 thread_->message_loop()->PostTask( 801 thread_->message_loop()->PostTask(
841 FROM_HERE, 802 FROM_HERE,
842 base::Bind(&net::HttpServer::AcceptWebSocket, server_.get(), 803 base::Bind(&net::HttpServer::AcceptWebSocket, server_.get(),
843 connection_id, request)); 804 connection_id, request));
844 } 805 }
845 806
846 DevToolsHttpHandlerImpl::PageInfo 807 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializePageInfo(
847 DevToolsHttpHandlerImpl::CreatePageInfo(RenderViewHost* rvh, 808 RenderViewHost* rvh,
848 DevToolsHttpHandlerDelegate::TargetType type) { 809 const std::string& host) {
849 RenderViewHostDelegate* host_delegate = rvh->GetDelegate(); 810 base::DictionaryValue* dictionary = new base::DictionaryValue;
811
850 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetFor(rvh)); 812 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetFor(rvh));
851 DevToolsClientHost* client_host = DevToolsManager::GetInstance()->
852 GetDevToolsClientHostFor(agent);
853 PageInfo page_info;
854 page_info.id = binding_->GetIdentifier(agent);
855 page_info.attached = client_host != NULL;
856 page_info.url = host_delegate->GetURL().spec();
857 813
858 switch (type) { 814 std::string id = binding_->GetIdentifier(agent);
815 dictionary->SetString("id", id);
816
817 switch (delegate_->GetTargetType(rvh)) {
859 case DevToolsHttpHandlerDelegate::kTargetTypeTab: 818 case DevToolsHttpHandlerDelegate::kTargetTypeTab:
860 page_info.type = "page"; 819 dictionary->SetString("type", "page");
861 break; 820 break;
862 default: 821 default:
863 page_info.type = "other"; 822 dictionary->SetString("type", "other");
864 } 823 }
865 824
866 WebContents* web_contents = host_delegate->GetAsWebContents(); 825 WebContents* web_contents = rvh->GetDelegate()->GetAsWebContents();
867 if (web_contents) { 826 if (web_contents) {
868 page_info.title = UTF16ToUTF8( 827 dictionary->SetString("title", UTF16ToUTF8(
869 net::EscapeForHTML(web_contents->GetTitle())); 828 net::EscapeForHTML(web_contents->GetTitle())));
870 page_info.last_selected_time = web_contents->GetLastSelectedTime(); 829 dictionary->SetString("url", web_contents->GetURL().spec());
830 dictionary->SetString("thumbnailUrl", std::string(kThumbUrlPrefix) + id);
871 831
872 NavigationController& controller = web_contents->GetController(); 832 NavigationController& controller = web_contents->GetController();
873 NavigationEntry* entry = controller.GetActiveEntry(); 833 NavigationEntry* entry = controller.GetActiveEntry();
874 if (entry != NULL && entry->GetURL().is_valid()) { 834 if (entry != NULL && entry->GetURL().is_valid()) {
875 page_info.thumbnail_url = "/thumb/" + entry->GetURL().spec(); 835 dictionary->SetString("faviconUrl", entry->GetFavicon().url.spec());
876 page_info.favicon_url = entry->GetFavicon().url.spec();
877 } 836 }
878 } 837 }
879 838
880 page_info.description = delegate_->GetViewDescription(rvh); 839 if (!DevToolsManager::GetInstance()->GetDevToolsClientHostFor(agent)) {
881
882 return page_info;
883 }
884
885 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializePageInfo(
886 const PageInfo& page_info,
887 const std::string& host) {
888 base::DictionaryValue* dictionary = new base::DictionaryValue;
889 dictionary->SetString("title", page_info.title);
890 dictionary->SetString("url", page_info.url);
891 dictionary->SetString("type", page_info.type);
892 dictionary->SetString("id", page_info.id);
893 dictionary->SetString("thumbnailUrl", page_info.thumbnail_url);
894 dictionary->SetString("faviconUrl", page_info.favicon_url);
895 if (!page_info.attached) {
896 dictionary->SetString("webSocketDebuggerUrl", 840 dictionary->SetString("webSocketDebuggerUrl",
897 base::StringPrintf("ws://%s/devtools/page/%s", 841 base::StringPrintf("ws://%s/devtools/page/%s",
898 host.c_str(), 842 host.c_str(),
899 page_info.id.c_str())); 843 id.c_str()));
900 std::string devtools_frontend_url = GetFrontendURLInternal( 844 std::string devtools_frontend_url = GetFrontendURLInternal(
901 page_info.id.c_str(), 845 id.c_str(),
902 host); 846 host);
903 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url); 847 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url);
904 } 848 }
905 dictionary->SetString("description", page_info.description); 849 dictionary->SetString("description", delegate_->GetViewDescription(rvh));
906 return dictionary; 850 return dictionary;
907 } 851 }
908 852
909 } // namespace content 853 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_http_handler_impl.h ('k') | content/browser/devtools/render_view_devtools_agent_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698