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

Side by Side Diff: android_webview/browser/aw_dev_tools_discovery_provider.cc

Issue 2289773002: Revert of DevTools: merge devtools target with devtools host, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 | « no previous file | chrome/browser/android/dev_tools_discovery_provider_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "android_webview/browser/aw_dev_tools_discovery_provider.h" 5 #include "android_webview/browser/aw_dev_tools_discovery_provider.h"
6 6
7 #include "android_webview/browser/browser_view_renderer.h" 7 #include "android_webview/browser/browser_view_renderer.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 22 matching lines...) Expand all
33 description.SetBoolean("empty", screen_rect.size().IsEmpty()); 33 description.SetBoolean("empty", screen_rect.size().IsEmpty());
34 if (!screen_rect.size().IsEmpty()) { 34 if (!screen_rect.size().IsEmpty()) {
35 description.SetInteger("width", screen_rect.width()); 35 description.SetInteger("width", screen_rect.width());
36 description.SetInteger("height", screen_rect.height()); 36 description.SetInteger("height", screen_rect.height());
37 } 37 }
38 std::string json; 38 std::string json;
39 base::JSONWriter::Write(description, &json); 39 base::JSONWriter::Write(description, &json);
40 return json; 40 return json;
41 } 41 }
42 42
43 class TargetDescriptor : public devtools_discovery::BasicTargetDescriptor {
44 public:
45 explicit TargetDescriptor(scoped_refptr<DevToolsAgentHost> agent_host);
46
47 // devtools_discovery::BasicTargetDescriptor overrides.
48 std::string GetDescription() const override { return description_; }
49
50 private:
51 std::string description_;
52
53 DISALLOW_COPY_AND_ASSIGN(TargetDescriptor);
54 };
55
56 TargetDescriptor::TargetDescriptor(scoped_refptr<DevToolsAgentHost> agent_host)
57 : BasicTargetDescriptor(agent_host) {
58 if (WebContents* web_contents = agent_host->GetWebContents())
59 description_ = GetViewDescription(web_contents);
60 }
61
43 } // namespace 62 } // namespace
44 63
45 namespace android_webview { 64 namespace android_webview {
46 65
47 // static 66 // static
48 void AwDevToolsDiscoveryProvider::Install() { 67 void AwDevToolsDiscoveryProvider::Install() {
49 devtools_discovery::DevToolsDiscoveryManager* discovery_manager = 68 devtools_discovery::DevToolsDiscoveryManager* discovery_manager =
50 devtools_discovery::DevToolsDiscoveryManager::GetInstance(); 69 devtools_discovery::DevToolsDiscoveryManager::GetInstance();
51 discovery_manager->AddProvider( 70 discovery_manager->AddProvider(
52 base::WrapUnique(new AwDevToolsDiscoveryProvider())); 71 base::WrapUnique(new AwDevToolsDiscoveryProvider()));
53 } 72 }
54 73
55 AwDevToolsDiscoveryProvider::AwDevToolsDiscoveryProvider() { 74 AwDevToolsDiscoveryProvider::AwDevToolsDiscoveryProvider() {
56 } 75 }
57 76
58 AwDevToolsDiscoveryProvider::~AwDevToolsDiscoveryProvider() { 77 AwDevToolsDiscoveryProvider::~AwDevToolsDiscoveryProvider() {
59 } 78 }
60 79
61 devtools_discovery::DevToolsTargetDescriptor::List 80 devtools_discovery::DevToolsTargetDescriptor::List
62 AwDevToolsDiscoveryProvider::GetDescriptors() { 81 AwDevToolsDiscoveryProvider::GetDescriptors() {
63 DevToolsAgentHost::List agent_hosts = DevToolsAgentHost::GetOrCreateAll(); 82 DevToolsAgentHost::List agent_hosts = DevToolsAgentHost::GetOrCreateAll();
64 devtools_discovery::DevToolsTargetDescriptor::List result; 83 devtools_discovery::DevToolsTargetDescriptor::List result;
65 result.reserve(agent_hosts.size()); 84 result.reserve(agent_hosts.size());
66 for (auto& agent_host : agent_hosts) { 85 for (const auto& agent_host : agent_hosts)
67 agent_host->SetDescriptionOverride( 86 result.push_back(new TargetDescriptor(agent_host));
68 GetViewDescription(agent_host->GetWebContents()));
69 result.push_back(new devtools_discovery::BasicTargetDescriptor(agent_host));
70 }
71 return result; 87 return result;
72 } 88 }
73 89
74 } // namespace android_webview 90 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/dev_tools_discovery_provider_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698