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

Side by Side Diff: ash/devtools/ash_devtools_dom_agent.h

Issue 2899783002: Move DevTools out of ash and turn it to a component. (Closed)
Patch Set: add README.md Created 3 years, 6 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 | « ash/devtools/ash_devtools_css_agent.cc ('k') | ash/devtools/ash_devtools_dom_agent.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 #ifndef ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
6 #define ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
7
8 #include "ash/ash_export.h"
9 #include "ash/devtools/ui_element_delegate.h"
10 #include "base/macros.h"
11 #include "components/ui_devtools/DOM.h"
12 #include "components/ui_devtools/devtools_base_agent.h"
13 #include "ui/aura/env_observer.h"
14 #include "ui/views/view.h"
15 #include "ui/views/widget/widget.h"
16
17 namespace aura {
18 class Window;
19 }
20
21 namespace ash {
22 namespace devtools {
23
24 class UIElement;
25
26 class ASH_EXPORT AshDevToolsDOMAgentObserver {
27 public:
28 // TODO(thanhph): Use UIElement* as input argument instead.
29 virtual void OnNodeBoundsChanged(int node_id) = 0;
30 };
31
32 class ASH_EXPORT AshDevToolsDOMAgent
33 : public NON_EXPORTED_BASE(ui::devtools::UiDevToolsBaseAgent<
34 ui::devtools::protocol::DOM::Metainfo>),
35 public UIElementDelegate,
36 public aura::EnvObserver {
37 public:
38 AshDevToolsDOMAgent();
39 ~AshDevToolsDOMAgent() override;
40
41 // DOM::Backend:
42 ui::devtools::protocol::Response disable() override;
43 ui::devtools::protocol::Response getDocument(
44 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) override;
45 ui::devtools::protocol::Response highlightNode(
46 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig>
47 highlight_config,
48 ui::devtools::protocol::Maybe<int> node_id) override;
49 ui::devtools::protocol::Response hideHighlight() override;
50
51 // UIElementDelegate:
52 void OnUIElementAdded(UIElement* parent, UIElement* child) override;
53 void OnUIElementReordered(UIElement* parent, UIElement* child) override;
54 void OnUIElementRemoved(UIElement* ui_element) override;
55 void OnUIElementBoundsChanged(UIElement* ui_element) override;
56 bool IsHighlightingWindow(aura::Window* window) override;
57
58 void AddObserver(AshDevToolsDOMAgentObserver* observer);
59 void RemoveObserver(AshDevToolsDOMAgentObserver* observer);
60 UIElement* GetElementFromNodeId(int node_id);
61 UIElement* window_element_root() const { return window_element_root_.get(); };
62 const std::vector<aura::Window*>& root_windows() const {
63 return root_windows_;
64 };
65
66 private:
67 // aura::EnvObserver:
68 void OnWindowInitialized(aura::Window* window) override {}
69 void OnHostInitialized(aura::WindowTreeHost* host) override;
70
71 void OnNodeBoundsChanged(int node_id);
72 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree();
73 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForUIElement(
74 UIElement* ui_element);
75 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow(
76 UIElement* window_element_root,
77 aura::Window* window);
78 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForRootWidget(
79 UIElement* widget_element,
80 views::Widget* widget);
81 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForView(
82 UIElement* view_element,
83 views::View* view);
84 void RemoveDomNode(UIElement* ui_element);
85 void Reset();
86 void InitializeHighlightingWidget();
87 void UpdateHighlight(
88 const std::pair<aura::Window*, gfx::Rect>& window_and_bounds,
89 SkColor background,
90 SkColor border);
91 ui::devtools::protocol::Response HighlightNode(
92 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig>
93 highlight_config,
94 int node_id);
95
96 bool is_building_tree_;
97 std::unique_ptr<UIElement> window_element_root_;
98 std::unordered_map<int, UIElement*> node_id_to_ui_element_;
99 std::unique_ptr<views::Widget> widget_for_highlighting_;
100 std::vector<aura::Window*> root_windows_;
101 base::ObserverList<AshDevToolsDOMAgentObserver> observers_;
102
103 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent);
104 };
105
106 } // namespace devtools
107 } // namespace ash
108
109 #endif // ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_
OLDNEW
« no previous file with comments | « ash/devtools/ash_devtools_css_agent.cc ('k') | ash/devtools/ash_devtools_dom_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698