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

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

Issue 2300703005: DevTools: merge devtools_http_handler into content - it is used in all the embedders anyways. (Closed)
Patch Set: for_landing! 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "android_webview/browser/aw_dev_tools_discovery_provider.h"
6
7 #include "android_webview/browser/browser_view_renderer.h"
8 #include "base/json/json_writer.h"
9 #include "base/memory/ptr_util.h"
10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h"
13 #include "content/public/browser/devtools_agent_host.h"
14 #include "content/public/browser/web_contents.h"
15
16 using content::DevToolsAgentHost;
17 using content::WebContents;
18
19 namespace {
20
21 std::string GetViewDescription(WebContents* web_contents) {
22 android_webview::BrowserViewRenderer* bvr =
23 android_webview::BrowserViewRenderer::FromWebContents(web_contents);
24 if (!bvr) return "";
25 base::DictionaryValue description;
26 description.SetBoolean("attached", bvr->attached_to_window());
27 description.SetBoolean("visible", bvr->IsVisible());
28 gfx::Rect screen_rect = bvr->GetScreenRect();
29 description.SetInteger("screenX", screen_rect.x());
30 description.SetInteger("screenY", screen_rect.y());
31 description.SetBoolean("empty", screen_rect.size().IsEmpty());
32 if (!screen_rect.size().IsEmpty()) {
33 description.SetInteger("width", screen_rect.width());
34 description.SetInteger("height", screen_rect.height());
35 }
36 std::string json;
37 base::JSONWriter::Write(description, &json);
38 return json;
39 }
40
41 content::DevToolsAgentHost::List GetDescriptors() {
42 DevToolsAgentHost::List agent_hosts = DevToolsAgentHost::GetOrCreateAll();
43 for (auto& agent_host : agent_hosts) {
44 agent_host->SetDescriptionOverride(
45 GetViewDescription(agent_host->GetWebContents()));
46 }
47 return agent_hosts;
48 }
49
50 } // namespace
51
52 namespace android_webview {
53
54 // static
55 void AwDevToolsDiscoveryProvider::Install() {
56 content::DevToolsAgentHost::AddDiscoveryProvider(base::Bind(&GetDescriptors));
57 }
58
59 AwDevToolsDiscoveryProvider::AwDevToolsDiscoveryProvider() {
60 }
61
62 AwDevToolsDiscoveryProvider::~AwDevToolsDiscoveryProvider() {
63 }
64
65 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/aw_dev_tools_discovery_provider.h ('k') | android_webview/browser/aw_devtools_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698