OLD | NEW |
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/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 description.SetBoolean("visible", bvr->IsVisible()); | 28 description.SetBoolean("visible", bvr->IsVisible()); |
29 gfx::Rect screen_rect = bvr->GetScreenRect(); | 29 gfx::Rect screen_rect = bvr->GetScreenRect(); |
30 description.SetInteger("screenX", screen_rect.x()); | 30 description.SetInteger("screenX", screen_rect.x()); |
31 description.SetInteger("screenY", screen_rect.y()); | 31 description.SetInteger("screenY", screen_rect.y()); |
32 description.SetBoolean("empty", screen_rect.size().IsEmpty()); | 32 description.SetBoolean("empty", screen_rect.size().IsEmpty()); |
33 if (!screen_rect.size().IsEmpty()) { | 33 if (!screen_rect.size().IsEmpty()) { |
34 description.SetInteger("width", screen_rect.width()); | 34 description.SetInteger("width", screen_rect.width()); |
35 description.SetInteger("height", screen_rect.height()); | 35 description.SetInteger("height", screen_rect.height()); |
36 } | 36 } |
37 std::string json; | 37 std::string json; |
38 base::JSONWriter::Write(&description, &json); | 38 base::JSONWriter::Write(description, &json); |
39 return json; | 39 return json; |
40 } | 40 } |
41 | 41 |
42 class TargetDescriptor : public devtools_discovery::BasicTargetDescriptor { | 42 class TargetDescriptor : public devtools_discovery::BasicTargetDescriptor { |
43 public: | 43 public: |
44 explicit TargetDescriptor(scoped_refptr<DevToolsAgentHost> agent_host); | 44 explicit TargetDescriptor(scoped_refptr<DevToolsAgentHost> agent_host); |
45 | 45 |
46 // devtools_discovery::BasicTargetDescriptor overrides. | 46 // devtools_discovery::BasicTargetDescriptor overrides. |
47 std::string GetDescription() const override { return description_; } | 47 std::string GetDescription() const override { return description_; } |
48 | 48 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 AwDevToolsDiscoveryProvider::GetDescriptors() { | 80 AwDevToolsDiscoveryProvider::GetDescriptors() { |
81 DevToolsAgentHost::List agent_hosts = DevToolsAgentHost::GetOrCreateAll(); | 81 DevToolsAgentHost::List agent_hosts = DevToolsAgentHost::GetOrCreateAll(); |
82 devtools_discovery::DevToolsTargetDescriptor::List result; | 82 devtools_discovery::DevToolsTargetDescriptor::List result; |
83 result.reserve(agent_hosts.size()); | 83 result.reserve(agent_hosts.size()); |
84 for (const auto& agent_host : agent_hosts) | 84 for (const auto& agent_host : agent_hosts) |
85 result.push_back(new TargetDescriptor(agent_host)); | 85 result.push_back(new TargetDescriptor(agent_host)); |
86 return result; | 86 return result; |
87 } | 87 } |
88 | 88 |
89 } // namespace android_webview | 89 } // namespace android_webview |
OLD | NEW |