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

Side by Side Diff: chrome/browser/devtools/device/devtools_device_discovery.cc

Issue 2575363002: Fixed not working inspector in case of Remote Target (Closed)
Patch Set: Fixed not working inspector in case of Remote Target Created 3 years, 12 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
« no previous file with comments | « chrome/browser/devtools/device/devtools_device_discovery.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/devtools/device/devtools_device_discovery.h" 5 #include "chrome/browser/devtools/device/devtools_device_discovery.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 remote_id_(value ? GetStringProperty(value, "id") : ""), 245 remote_id_(value ? GetStringProperty(value, "id") : ""),
246 frontend_url_(value ? GetFrontendURLFromValue(value) : ""), 246 frontend_url_(value ? GetFrontendURLFromValue(value) : ""),
247 title_(value ? base::UTF16ToUTF8(net::UnescapeForHTML(base::UTF8ToUTF16( 247 title_(value ? base::UTF16ToUTF8(net::UnescapeForHTML(base::UTF8ToUTF16(
248 GetStringProperty(value, "title")))) : ""), 248 GetStringProperty(value, "title")))) : ""),
249 description_(value ? GetStringProperty(value, "description") : ""), 249 description_(value ? GetStringProperty(value, "description") : ""),
250 url_(GURL(value ? GetStringProperty(value, "url") : "")), 250 url_(GURL(value ? GetStringProperty(value, "url") : "")),
251 favicon_url_(GURL(value ? GetStringProperty(value, "faviconUrl") : "")), 251 favicon_url_(GURL(value ? GetStringProperty(value, "faviconUrl") : "")),
252 socket_opened_(false), 252 socket_opened_(false),
253 agent_host_(nullptr), 253 agent_host_(nullptr),
254 proxy_(nullptr) { 254 proxy_(nullptr) {
255 if (!GURL(frontend_url_).has_scheme() && value) {
256 frontend_url_ = GetStringProperty(value, "Proxy-devtoolsFrontendUrl");
257 }
255 } 258 }
256 259
257 AgentHostDelegate::~AgentHostDelegate() { 260 AgentHostDelegate::~AgentHostDelegate() {
258 } 261 }
259 262
260 void AgentHostDelegate::Attach(content::DevToolsExternalAgentProxy* proxy) { 263 void AgentHostDelegate::Attach(content::DevToolsExternalAgentProxy* proxy) {
261 proxy_ = proxy; 264 proxy_ = proxy;
262 content::RecordAction( 265 content::RecordAction(
263 base::StartsWith(browser_id_, kWebViewSocketPrefix, 266 base::StartsWith(browser_id_, kWebViewSocketPrefix,
264 base::CompareCase::SENSITIVE) 267 base::CompareCase::SENSITIVE)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (value && value->GetAsDictionary(&dict)) { 454 if (value && value->GetAsDictionary(&dict)) {
452 std::string browser_name; 455 std::string browser_name;
453 if (dict->GetString("Browser", &browser_name)) { 456 if (dict->GetString("Browser", &browser_name)) {
454 std::vector<std::string> parts = base::SplitString( 457 std::vector<std::string> parts = base::SplitString(
455 browser_name, "/", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 458 browser_name, "/", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
456 if (parts.size() == 2) 459 if (parts.size() == 2)
457 browser->version_ = parts[1]; 460 browser->version_ = parts[1];
458 else 461 else
459 browser->version_ = browser_name; 462 browser->version_ = browser_name;
460 } 463 }
464 std::string webkit_version;
465 if (dict->GetString("WebKit-Version", &webkit_version)) {
466 browser->webkit_version_ = webkit_version;
467 }
461 std::string package; 468 std::string package;
462 if (dict->GetString("Android-Package", &package)) { 469 if (dict->GetString("Android-Package", &package)) {
463 browser->display_name_ = 470 browser->display_name_ =
464 AndroidDeviceManager::GetBrowserName(browser->socket(), package); 471 AndroidDeviceManager::GetBrowserName(browser->socket(), package);
465 } 472 }
466 } 473 }
467 } 474 }
468 475
469 void DevToolsDeviceDiscovery::DiscoveryRequest::ReceivedPages( 476 void DevToolsDeviceDiscovery::DiscoveryRequest::ReceivedPages(
470 scoped_refptr<AndroidDeviceManager::Device> device, 477 scoped_refptr<AndroidDeviceManager::Device> device,
471 scoped_refptr<RemoteBrowser> browser, 478 scoped_refptr<RemoteBrowser> browser,
472 int result, 479 int result,
473 const std::string& response) { 480 const std::string& response) {
474 DCHECK_CURRENTLY_ON(BrowserThread::UI); 481 DCHECK_CURRENTLY_ON(BrowserThread::UI);
475 if (result < 0) 482 if (result < 0)
476 return; 483 return;
477 std::unique_ptr<base::Value> value = base::JSONReader::Read(response); 484 std::unique_ptr<base::Value> value = base::JSONReader::Read(response);
478 base::ListValue* list_value; 485 base::ListValue* list_value;
479 if (value && value->GetAsList(&list_value)) { 486 if (value && value->GetAsList(&list_value)) {
480 for (const auto& page_value : *list_value) { 487 for (const auto& page_value : *list_value) {
481 base::DictionaryValue* dict; 488 base::DictionaryValue* dict;
482 if (page_value->GetAsDictionary(&dict)) 489 if (page_value->GetAsDictionary(&dict)) {
490 const char kFrontEndURL[] =
491 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/inspector.ht ml";
492 dict->SetString("Proxy-devtoolsFrontendUrl",
493 base::StringPrintf(kFrontEndURL, browser->WebKitRevision().c_str()));
483 browser->pages_.push_back( 494 browser->pages_.push_back(
484 new RemotePage(device, browser->browser_id_, *dict)); 495 new RemotePage(device, browser->browser_id_, *dict));
496 }
485 } 497 }
486 } 498 }
487 } 499 }
488 500
489 // DevToolsDeviceDiscovery::RemotePage ---------------------------------------- 501 // DevToolsDeviceDiscovery::RemotePage ----------------------------------------
490 502
491 DevToolsDeviceDiscovery::RemotePage::RemotePage( 503 DevToolsDeviceDiscovery::RemotePage::RemotePage(
492 scoped_refptr<AndroidDeviceManager::Device> device, 504 scoped_refptr<AndroidDeviceManager::Device> device,
493 const std::string& browser_id, 505 const std::string& browser_id,
494 const base::DictionaryValue& dict) 506 const base::DictionaryValue& dict)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 for (const base::StringPiece& part : 550 for (const base::StringPiece& part :
539 base::SplitStringPiece( 551 base::SplitStringPiece(
540 version_, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { 552 version_, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
541 int value = 0; 553 int value = 0;
542 base::StringToInt(part, &value); 554 base::StringToInt(part, &value);
543 result.push_back(value); 555 result.push_back(value);
544 } 556 }
545 return result; 557 return result;
546 } 558 }
547 559
560 std::string DevToolsDeviceDiscovery::RemoteBrowser::WebKitRevision() {
561 std::string webkit_revision;
562 size_t l = webkit_version_.find('@');
563 size_t r = webkit_version_.rfind(')');
564 if (l != std::string::npos && r != std::string::npos && r > l)
565 webkit_revision = webkit_version_.substr(l, r-l);
566 return webkit_revision;
567 }
568
548 DevToolsDeviceDiscovery::RemoteBrowser::~RemoteBrowser() { 569 DevToolsDeviceDiscovery::RemoteBrowser::~RemoteBrowser() {
549 } 570 }
550 571
551 // DevToolsDeviceDiscovery::RemoteDevice -------------------------------------- 572 // DevToolsDeviceDiscovery::RemoteDevice --------------------------------------
552 573
553 DevToolsDeviceDiscovery::RemoteDevice::RemoteDevice( 574 DevToolsDeviceDiscovery::RemoteDevice::RemoteDevice(
554 const std::string& serial, 575 const std::string& serial,
555 const AndroidDeviceManager::DeviceInfo& device_info) 576 const AndroidDeviceManager::DeviceInfo& device_info)
556 : serial_(serial), 577 : serial_(serial),
557 model_(device_info.model), 578 model_(device_info.model),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 633 }
613 634
614 void DevToolsDeviceDiscovery::ReceivedDeviceList( 635 void DevToolsDeviceDiscovery::ReceivedDeviceList(
615 const CompleteDevices& complete_devices) { 636 const CompleteDevices& complete_devices) {
616 DCHECK_CURRENTLY_ON(BrowserThread::UI); 637 DCHECK_CURRENTLY_ON(BrowserThread::UI);
617 task_scheduler_.Run(base::Bind(&DevToolsDeviceDiscovery::RequestDeviceList, 638 task_scheduler_.Run(base::Bind(&DevToolsDeviceDiscovery::RequestDeviceList,
618 weak_factory_.GetWeakPtr())); 639 weak_factory_.GetWeakPtr()));
619 // |callback_| should be run last as it may destroy |this|. 640 // |callback_| should be run last as it may destroy |this|.
620 callback_.Run(complete_devices); 641 callback_.Run(complete_devices);
621 } 642 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/device/devtools_device_discovery.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698