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

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: Fixed compile 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"
21 #include "base/values.h"
22 #include "content/browser/devtools/devtools_agent_host_impl.h"
23 #include "content/browser/devtools/devtools_browser_target.h" 19 #include "content/browser/devtools/devtools_browser_target.h"
24 #include "content/browser/devtools/devtools_tracing_handler.h" 20 #include "content/browser/devtools/devtools_tracing_handler.h"
25 #include "content/browser/web_contents/web_contents_impl.h" 21 #include "content/browser/web_contents/web_contents_impl.h"
26 #include "content/common/devtools_messages.h" 22 #include "content/common/devtools_messages.h"
27 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/devtools_agent_host.h" 24 #include "content/public/browser/devtools_agent_host.h"
29 #include "content/public/browser/devtools_client_host.h" 25 #include "content/public/browser/devtools_client_host.h"
30 #include "content/public/browser/devtools_http_handler_delegate.h"
31 #include "content/public/browser/devtools_manager.h" 26 #include "content/public/browser/devtools_manager.h"
32 #include "content/public/browser/favicon_status.h" 27 #include "content/public/browser/devtools_target_list.h"
33 #include "content/public/browser/navigation_entry.h"
34 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
35 #include "content/public/browser/notification_types.h" 29 #include "content/public/browser/notification_types.h"
36 #include "content/public/browser/render_process_host.h"
37 #include "content/public/browser/render_view_host.h" 30 #include "content/public/browser/render_view_host.h"
38 #include "content/public/browser/render_widget_host.h"
39 #include "content/public/common/content_client.h" 31 #include "content/public/common/content_client.h"
40 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
41 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
42 #include "grit/devtools_resources_map.h" 34 #include "grit/devtools_resources_map.h"
43 #include "net/base/escape.h"
44 #include "net/base/io_buffer.h" 35 #include "net/base/io_buffer.h"
45 #include "net/base/ip_endpoint.h" 36 #include "net/base/ip_endpoint.h"
46 #include "net/server/http_server_request_info.h" 37 #include "net/server/http_server_request_info.h"
47 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 38 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h"
49 #include "ui/base/layout.h" 40 #include "ui/base/layout.h"
50 #include "webkit/user_agent/user_agent.h" 41 #include "webkit/user_agent/user_agent.h"
51 #include "webkit/user_agent/user_agent_util.h" 42 #include "webkit/user_agent/user_agent_util.h"
52 43
53 namespace content { 44 namespace content {
54 45
55 const int kBufferSize = 16 * 1024; 46 const int kBufferSize = 16 * 1024;
56 47
57 namespace { 48 namespace {
58 49
59 static const char* kDevToolsHandlerThreadName = "Chrome_DevToolsHandlerThread"; 50 static const char* kDevToolsHandlerThreadName = "Chrome_DevToolsHandlerThread";
60 51
52 static const char* kThumbUrlPrefix = "/thumb/";
53
61 class DevToolsDefaultBindingHandler 54 class DevToolsDefaultBindingHandler
62 : public DevToolsHttpHandler::DevToolsAgentHostBinding { 55 : public DevToolsHttpHandler::DevToolsAgentHostBinding {
63 public: 56 public:
64 DevToolsDefaultBindingHandler() { 57 DevToolsDefaultBindingHandler() {
65 } 58 }
66 59
67 void GarbageCollect() {
68 AgentsMap::iterator it = agents_map_.begin();
69 while (it != agents_map_.end()) {
70 if (!it->second->GetRenderViewHost())
71 agents_map_.erase(it++);
72 else
73 ++it;
74 }
75 }
76
77 virtual std::string GetIdentifier(DevToolsAgentHost* agent_host) OVERRIDE { 60 virtual std::string GetIdentifier(DevToolsAgentHost* agent_host) OVERRIDE {
78 GarbageCollect(); 61 DevToolsTargetList::GetInstance()->Register(agent_host);
79 DevToolsAgentHostImpl* agent_host_impl = 62 return agent_host->GetId();
80 static_cast<DevToolsAgentHostImpl*>(agent_host);
81 std::string id = base::StringPrintf("%d", agent_host_impl->id());
82 agents_map_[id] = agent_host;
83 return id;
84 } 63 }
85 64
86 virtual DevToolsAgentHost* ForIdentifier( 65 virtual DevToolsAgentHost* ForIdentifier(
87 const std::string& identifier) OVERRIDE { 66 const std::string& identifier) OVERRIDE {
88 GarbageCollect(); 67 return DevToolsTargetList::GetInstance()->Lookup(identifier);
89 AgentsMap::iterator it = agents_map_.find(identifier);
90 if (it != agents_map_.end())
91 return it->second;
92 return NULL;
93 } 68 }
94
95 private:
96 typedef std::map<std::string, scoped_refptr<DevToolsAgentHost> > AgentsMap;
97 AgentsMap agents_map_;
98 }; 69 };
99 70
100 // An internal implementation of DevToolsClientHost that delegates 71 // An internal implementation of DevToolsClientHost that delegates
101 // messages sent for DevToolsClient to a DebuggerShell instance. 72 // messages sent for DevToolsClient to a DebuggerShell instance.
102 class DevToolsClientHostImpl : public DevToolsClientHost { 73 class DevToolsClientHostImpl : public DevToolsClientHost {
103 public: 74 public:
104 DevToolsClientHostImpl( 75 DevToolsClientHostImpl(
105 MessageLoop* message_loop, 76 MessageLoop* message_loop,
106 net::HttpServer* server, 77 net::HttpServer* server,
107 int connection_id) 78 int connection_id)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 120 }
150 121
151 private: 122 private:
152 MessageLoop* message_loop_; 123 MessageLoop* message_loop_;
153 net::HttpServer* server_; 124 net::HttpServer* server_;
154 int connection_id_; 125 int connection_id_;
155 bool is_closed_; 126 bool is_closed_;
156 std::string detach_reason_; 127 std::string detach_reason_;
157 }; 128 };
158 129
130 static base::TimeTicks GetLastSelectedTime(DevToolsAgentHost* agent) {
131 RenderViewHost* rvh = agent->GetRenderViewHost();
132 if (!rvh)
133 return base::TimeTicks();
134
135 WebContents* web_contents = rvh->GetDelegate()->GetAsWebContents();
136 if (!web_contents)
137 return base::TimeTicks();
138
139 return web_contents->GetLastSelectedTime();
140 }
141
142 typedef std::pair<DevToolsAgentHost*, base::TimeTicks> PageInfo;
143
144 static bool TimeComparator(const PageInfo& info1, const PageInfo& info2) {
145 return info1.second > info2.second;
146 }
147
159 } // namespace 148 } // namespace
160 149
161 // static 150 // static
162 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) { 151 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) {
163 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { 152 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) {
164 if (name == kDevtoolsResources[i].name) 153 if (name == kDevtoolsResources[i].name)
165 return kDevtoolsResources[i].value; 154 return kDevtoolsResources[i].value;
166 } 155 }
167 return -1; 156 return -1;
168 } 157 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 BrowserThread::PostTask( 289 BrowserThread::PostTask(
301 BrowserThread::UI, 290 BrowserThread::UI,
302 FROM_HERE, 291 FROM_HERE,
303 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI, 292 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI,
304 this, 293 this,
305 connection_id, 294 connection_id,
306 info)); 295 info));
307 return; 296 return;
308 } 297 }
309 298
310 if (info.path.find("/thumb/") == 0) { 299 if (info.path.find(kThumbUrlPrefix) == 0) {
311 // Thumbnail request. 300 // Thumbnail request.
301 const std::string target_id = info.path.substr(strlen(kThumbUrlPrefix));
302 DevToolsAgentHost* agent_host = binding_->ForIdentifier(target_id);
303 GURL page_url;
304 if (agent_host)
305 page_url = agent_host->GetUrl();
312 BrowserThread::PostTask( 306 BrowserThread::PostTask(
313 BrowserThread::UI, 307 BrowserThread::UI,
314 FROM_HERE, 308 FROM_HERE,
315 base::Bind(&DevToolsHttpHandlerImpl::OnThumbnailRequestUI, 309 base::Bind(&DevToolsHttpHandlerImpl::OnThumbnailRequestUI,
316 this, 310 this,
317 connection_id, 311 connection_id,
318 info)); 312 page_url));
319 return; 313 return;
320 } 314 }
321 315
322 if (info.path == "" || info.path == "/") { 316 if (info.path == "" || info.path == "/") {
323 // Discovery page request. 317 // Discovery page request.
324 BrowserThread::PostTask( 318 BrowserThread::PostTask(
325 BrowserThread::UI, 319 BrowserThread::UI,
326 FROM_HERE, 320 FROM_HERE,
327 base::Bind(&DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI, 321 base::Bind(&DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI,
328 this, 322 this,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 void DevToolsHttpHandlerImpl::OnClose(int connection_id) { 381 void DevToolsHttpHandlerImpl::OnClose(int connection_id) {
388 BrowserThread::PostTask( 382 BrowserThread::PostTask(
389 BrowserThread::UI, 383 BrowserThread::UI,
390 FROM_HERE, 384 FROM_HERE,
391 base::Bind( 385 base::Bind(
392 &DevToolsHttpHandlerImpl::OnCloseUI, 386 &DevToolsHttpHandlerImpl::OnCloseUI,
393 this, 387 this,
394 connection_id)); 388 connection_id));
395 } 389 }
396 390
397 struct DevToolsHttpHandlerImpl::PageInfo {
398 PageInfo()
399 : attached(false) {
400 }
401
402 std::string id;
403 std::string url;
404 std::string type;
405 bool attached;
406 std::string title;
407 std::string thumbnail_url;
408 std::string favicon_url;
409 base::TimeTicks last_selected_time;
410 };
411
412 // static
413 bool DevToolsHttpHandlerImpl::SortPageListByTime(const PageInfo& info1,
414 const PageInfo& info2) {
415 return info1.last_selected_time > info2.last_selected_time;
416 }
417
418 DevToolsHttpHandlerImpl::PageList DevToolsHttpHandlerImpl::GeneratePageList() {
419 PageList page_list;
420 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
421 !it.IsAtEnd(); it.Advance()) {
422 RenderProcessHost* render_process_host = it.GetCurrentValue();
423 DCHECK(render_process_host);
424
425 // Ignore processes that don't have a connection, such as crashed contents.
426 if (!render_process_host->HasConnection())
427 continue;
428
429 RenderProcessHost::RenderWidgetHostsIterator rwit(
430 render_process_host->GetRenderWidgetHostsIterator());
431 for (; !rwit.IsAtEnd(); rwit.Advance()) {
432 const RenderWidgetHost* widget = rwit.GetCurrentValue();
433 DCHECK(widget);
434 if (!widget || !widget->IsRenderView())
435 continue;
436
437 RenderViewHost* host =
438 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
439 page_list.push_back(CreatePageInfo(host, delegate_->GetTargetType(host)));
440 }
441 }
442 std::sort(page_list.begin(), page_list.end(), SortPageListByTime);
443 return page_list;
444 }
445
446 std::string DevToolsHttpHandlerImpl::GetFrontendURLInternal( 391 std::string DevToolsHttpHandlerImpl::GetFrontendURLInternal(
447 const std::string rvh_id, 392 const std::string rvh_id,
448 const std::string& host) { 393 const std::string& host) {
449 return base::StringPrintf( 394 return base::StringPrintf(
450 "%s%sws=%s/devtools/page/%s", 395 "%s%sws=%s/devtools/page/%s",
451 overridden_frontend_url_.c_str(), 396 overridden_frontend_url_.c_str(),
452 overridden_frontend_url_.find("?") == std::string::npos ? "?" : "&", 397 overridden_frontend_url_.find("?") == std::string::npos ? "?" : "&",
453 host.c_str(), 398 host.c_str(),
454 rvh_id.c_str()); 399 rvh_id.c_str());
455 } 400 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 webkit_glue::GetWebKitVersion()); 464 webkit_glue::GetWebKitVersion());
520 version.SetString("Browser", 465 version.SetString("Browser",
521 content::GetContentClient()->GetProduct()); 466 content::GetContentClient()->GetProduct());
522 version.SetString("User-Agent", 467 version.SetString("User-Agent",
523 webkit_glue::GetUserAgent(GURL(chrome::kAboutBlankURL))); 468 webkit_glue::GetUserAgent(GURL(chrome::kAboutBlankURL)));
524 SendJson(connection_id, net::HTTP_OK, &version, "", jsonp); 469 SendJson(connection_id, net::HTTP_OK, &version, "", jsonp);
525 return; 470 return;
526 } 471 }
527 472
528 if (command == "list") { 473 if (command == "list") {
529 PageList page_list = GeneratePageList(); 474 typedef std::vector<PageInfo> PageList;
475 PageList page_list;
476
477 DevToolsTargetList* target_list = DevToolsTargetList::GetInstance();
478 target_list->Refresh();
pfeldman 2013/03/05 12:06:41 This should be its private detail.
Vladislav Kaznacheev 2013/03/05 13:35:44 Moved into begin() On 2013/03/05 12:06:41, pfeldma
479 for (DevToolsTargetList::AgentsMap::iterator it = target_list->begin();
480 it != target_list->end(); ++it) {
481 DevToolsAgentHost* agent_host = it->second;
482 page_list.push_back(
483 PageInfo(agent_host, GetLastSelectedTime(agent_host)));
484 }
485 std::sort(page_list.begin(), page_list.end(), TimeComparator);
486
530 base::ListValue json_pages_list; 487 base::ListValue json_pages_list;
531 std::string host = info.headers["Host"]; 488 std::string host = info.headers["Host"];
532 for (PageList::iterator i = page_list.begin(); i != page_list.end(); ++i) 489 for (PageList::iterator i = page_list.begin(); i != page_list.end(); ++i)
533 json_pages_list.Append(SerializePageInfo(*i, host)); 490 json_pages_list.Append(SerializePageInfo(i->first, host));
534 SendJson(connection_id, net::HTTP_OK, &json_pages_list, "", jsonp); 491 SendJson(connection_id, net::HTTP_OK, &json_pages_list, "", jsonp);
535 return; 492 return;
536 } 493 }
537 494
538 if (command == "new") { 495 if (command == "new") {
539 RenderViewHost* rvh = delegate_->CreateNewTarget(); 496 RenderViewHost* rvh = delegate_->CreateNewTarget();
540 if (!rvh) { 497 if (!rvh) {
541 SendJson(connection_id, 498 SendJson(connection_id,
542 net::HTTP_INTERNAL_SERVER_ERROR, 499 net::HTTP_INTERNAL_SERVER_ERROR,
543 NULL, 500 NULL,
544 "Could not create new page", 501 "Could not create new page",
545 jsonp); 502 jsonp);
546 return; 503 return;
547 } 504 }
548 PageInfo page_info =
549 CreatePageInfo(rvh, DevToolsHttpHandlerDelegate::kTargetTypeTab);
550 std::string host = info.headers["Host"]; 505 std::string host = info.headers["Host"];
551 scoped_ptr<base::DictionaryValue> dictionary( 506 scoped_ptr<base::DictionaryValue> dictionary(
552 SerializePageInfo(page_info, host)); 507 SerializePageInfo(DevToolsAgentHost::GetFor(rvh), host));
553 SendJson(connection_id, net::HTTP_OK, dictionary.get(), "", jsonp); 508 SendJson(connection_id, net::HTTP_OK, dictionary.get(), "", jsonp);
554 return; 509 return;
555 } 510 }
556 511
557 if (command == "activate" || command == "close") { 512 if (command == "activate" || command == "close") {
558 DevToolsAgentHost* agent_host = binding_->ForIdentifier(target_id); 513 DevToolsAgentHost* agent_host = binding_->ForIdentifier(target_id);
559 RenderViewHost* rvh = agent_host ? agent_host->GetRenderViewHost() : NULL; 514 RenderViewHost* rvh = agent_host ? agent_host->GetRenderViewHost() : NULL;
560 if (!rvh) { 515 if (!rvh) {
561 SendJson(connection_id, 516 SendJson(connection_id,
562 net::HTTP_NOT_FOUND, 517 net::HTTP_NOT_FOUND,
(...skipping 17 matching lines...) Expand all
580 } 535 }
581 SendJson(connection_id, 536 SendJson(connection_id,
582 net::HTTP_NOT_FOUND, 537 net::HTTP_NOT_FOUND,
583 NULL, 538 NULL,
584 "Unknown command: " + command, 539 "Unknown command: " + command,
585 jsonp); 540 jsonp);
586 return; 541 return;
587 } 542 }
588 543
589 void DevToolsHttpHandlerImpl::OnThumbnailRequestUI( 544 void DevToolsHttpHandlerImpl::OnThumbnailRequestUI(
590 int connection_id, 545 int connection_id, const GURL& page_url) {
591 const net::HttpServerRequestInfo& info) { 546 std::string data = delegate_->GetPageThumbnailData(page_url);
592 std::string prefix = "/thumb/";
593 size_t pos = info.path.find(prefix);
594 if (pos != 0) {
595 Send404(connection_id);
596 return;
597 }
598
599 std::string page_url = info.path.substr(prefix.length());
600 std::string data = delegate_->GetPageThumbnailData(GURL(page_url));
601 if (!data.empty()) 547 if (!data.empty())
602 Send200(connection_id, data, "image/png"); 548 Send200(connection_id, data, "image/png");
603 else 549 else
604 Send404(connection_id); 550 Send404(connection_id);
605 } 551 }
606 552
607 void DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI(int connection_id) { 553 void DevToolsHttpHandlerImpl::OnDiscoveryPageRequestUI(int connection_id) {
608 std::string response = delegate_->GetDiscoveryPageHTML(); 554 std::string response = delegate_->GetDiscoveryPageHTML();
609 Send200(connection_id, response, "text/html; charset=UTF-8"); 555 Send200(connection_id, response, "text/html; charset=UTF-8");
610 } 556 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 int connection_id, 776 int connection_id,
831 const net::HttpServerRequestInfo& request) { 777 const net::HttpServerRequestInfo& request) {
832 if (!thread_.get()) 778 if (!thread_.get())
833 return; 779 return;
834 thread_->message_loop()->PostTask( 780 thread_->message_loop()->PostTask(
835 FROM_HERE, 781 FROM_HERE,
836 base::Bind(&net::HttpServer::AcceptWebSocket, server_.get(), 782 base::Bind(&net::HttpServer::AcceptWebSocket, server_.get(),
837 connection_id, request)); 783 connection_id, request));
838 } 784 }
839 785
840 DevToolsHttpHandlerImpl::PageInfo 786 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializePageInfo(
841 DevToolsHttpHandlerImpl::CreatePageInfo(RenderViewHost* rvh, 787 DevToolsAgentHost* agent_host,
842 DevToolsHttpHandlerDelegate::TargetType type) { 788 const std::string& host) {
843 RenderViewHostDelegate* host_delegate = rvh->GetDelegate(); 789 base::DictionaryValue* dictionary = new base::DictionaryValue;
844 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetFor(rvh)); 790 dictionary->SetString("title", agent_host->GetTitle());
845 DevToolsClientHost* client_host = DevToolsManager::GetInstance()-> 791 dictionary->SetString("url", agent_host->GetUrl().spec());
846 GetDevToolsClientHostFor(agent); 792 switch (delegate_->GetTargetType(agent_host->GetRenderViewHost())) {
847 PageInfo page_info;
848 page_info.id = binding_->GetIdentifier(agent);
849 page_info.attached = client_host != NULL;
850 page_info.url = host_delegate->GetURL().spec();
851
852 switch (type) {
853 case DevToolsHttpHandlerDelegate::kTargetTypeTab: 793 case DevToolsHttpHandlerDelegate::kTargetTypeTab:
854 page_info.type = "page"; 794 dictionary->SetString("type", "page");
855 break; 795 break;
856 default: 796 default:
857 page_info.type = "other"; 797 dictionary->SetString("type", "other");
858 } 798 }
859 799 std::string id = binding_->GetIdentifier(agent_host);
860 WebContents* web_contents = host_delegate->GetAsWebContents(); 800 dictionary->SetString("id", id);
861 if (web_contents) { 801 dictionary->SetString("thumbnailUrl", std::string(kThumbUrlPrefix) + id);
862 page_info.title = UTF16ToUTF8( 802 dictionary->SetString("faviconUrl", agent_host->GetFaviconUrl().spec());
863 net::EscapeForHTML(web_contents->GetTitle())); 803 if (!DevToolsManager::GetInstance()->GetDevToolsClientHostFor(agent_host)) {
864 page_info.last_selected_time = web_contents->GetLastSelectedTime();
865
866 NavigationController& controller = web_contents->GetController();
867 NavigationEntry* entry = controller.GetActiveEntry();
868 if (entry != NULL && entry->GetURL().is_valid()) {
869 page_info.thumbnail_url = "/thumb/" + entry->GetURL().spec();
870 page_info.favicon_url = entry->GetFavicon().url.spec();
871 }
872 }
873 return page_info;
874 }
875
876 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializePageInfo(
877 const PageInfo& page_info,
878 const std::string& host) {
879 base::DictionaryValue* dictionary = new base::DictionaryValue;
880 dictionary->SetString("title", page_info.title);
881 dictionary->SetString("url", page_info.url);
882 dictionary->SetString("type", page_info.type);
883 dictionary->SetString("id", page_info.id);
884 dictionary->SetString("thumbnailUrl", page_info.thumbnail_url);
885 dictionary->SetString("faviconUrl", page_info.favicon_url);
886 if (!page_info.attached) {
887 dictionary->SetString("webSocketDebuggerUrl", 804 dictionary->SetString("webSocketDebuggerUrl",
888 base::StringPrintf("ws://%s/devtools/page/%s", 805 base::StringPrintf("ws://%s/devtools/page/%s",
889 host.c_str(), 806 host.c_str(),
890 page_info.id.c_str())); 807 id.c_str()));
891 std::string devtools_frontend_url = GetFrontendURLInternal( 808 std::string devtools_frontend_url = GetFrontendURLInternal(
892 page_info.id.c_str(), 809 id.c_str(),
893 host); 810 host);
894 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url); 811 dictionary->SetString("devtoolsFrontendUrl", devtools_frontend_url);
895 } 812 }
896 return dictionary; 813 return dictionary;
897 } 814 }
898 815
899 } // namespace content 816 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698