OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ | 5 #ifndef COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ |
6 #define ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ | 6 #define COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ |
7 | 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" | 8 #include "components/ui_devtools/DOM.h" |
12 #include "components/ui_devtools/devtools_base_agent.h" | 9 #include "components/ui_devtools/devtools_base_agent.h" |
| 10 #include "components/ui_devtools/views/ui_element_delegate.h" |
13 #include "ui/aura/env_observer.h" | 11 #include "ui/aura/env_observer.h" |
14 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
15 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
16 | 14 |
17 namespace aura { | 15 namespace aura { |
18 class Window; | 16 class Window; |
19 } | 17 } |
20 | 18 |
21 namespace ash { | 19 namespace ui { |
22 namespace devtools { | 20 namespace devtools { |
23 | 21 |
24 class UIElement; | 22 class UIElement; |
25 | 23 |
26 class ASH_EXPORT AshDevToolsDOMAgentObserver { | 24 class UIDevToolsDOMAgentObserver { |
27 public: | 25 public: |
28 // TODO(thanhph): Use UIElement* as input argument instead. | 26 // TODO(thanhph): Use UIElement* as input argument instead. |
29 virtual void OnNodeBoundsChanged(int node_id) = 0; | 27 virtual void OnNodeBoundsChanged(int node_id) = 0; |
30 }; | 28 }; |
31 | 29 |
32 class ASH_EXPORT AshDevToolsDOMAgent | 30 class UIDevToolsDOMAgent : public ui::devtools::UiDevToolsBaseAgent< |
33 : public NON_EXPORTED_BASE(ui::devtools::UiDevToolsBaseAgent< | 31 ui::devtools::protocol::DOM::Metainfo>, |
34 ui::devtools::protocol::DOM::Metainfo>), | 32 public UIElementDelegate, |
35 public UIElementDelegate, | 33 public aura::EnvObserver { |
36 public aura::EnvObserver { | |
37 public: | 34 public: |
38 AshDevToolsDOMAgent(); | 35 UIDevToolsDOMAgent(); |
39 ~AshDevToolsDOMAgent() override; | 36 ~UIDevToolsDOMAgent() override; |
40 | 37 |
41 // DOM::Backend: | 38 // DOM::Backend: |
42 ui::devtools::protocol::Response disable() override; | 39 ui::devtools::protocol::Response disable() override; |
43 ui::devtools::protocol::Response getDocument( | 40 ui::devtools::protocol::Response getDocument( |
44 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) override; | 41 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) override; |
45 ui::devtools::protocol::Response highlightNode( | 42 ui::devtools::protocol::Response highlightNode( |
46 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig> | 43 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig> |
47 highlight_config, | 44 highlight_config, |
48 ui::devtools::protocol::Maybe<int> node_id) override; | 45 ui::devtools::protocol::Maybe<int> node_id) override; |
49 ui::devtools::protocol::Response hideHighlight() override; | 46 ui::devtools::protocol::Response hideHighlight() override; |
50 | 47 |
51 // UIElementDelegate: | 48 // UIElementDelegate: |
52 void OnUIElementAdded(UIElement* parent, UIElement* child) override; | 49 void OnUIElementAdded(UIElement* parent, UIElement* child) override; |
53 void OnUIElementReordered(UIElement* parent, UIElement* child) override; | 50 void OnUIElementReordered(UIElement* parent, UIElement* child) override; |
54 void OnUIElementRemoved(UIElement* ui_element) override; | 51 void OnUIElementRemoved(UIElement* ui_element) override; |
55 void OnUIElementBoundsChanged(UIElement* ui_element) override; | 52 void OnUIElementBoundsChanged(UIElement* ui_element) override; |
56 bool IsHighlightingWindow(aura::Window* window) override; | 53 bool IsHighlightingWindow(aura::Window* window) override; |
57 | 54 |
58 void AddObserver(AshDevToolsDOMAgentObserver* observer); | 55 void AddObserver(UIDevToolsDOMAgentObserver* observer); |
59 void RemoveObserver(AshDevToolsDOMAgentObserver* observer); | 56 void RemoveObserver(UIDevToolsDOMAgentObserver* observer); |
60 UIElement* GetElementFromNodeId(int node_id); | 57 UIElement* GetElementFromNodeId(int node_id); |
61 UIElement* window_element_root() const { return window_element_root_.get(); }; | 58 UIElement* window_element_root() const { return window_element_root_.get(); }; |
62 const std::vector<aura::Window*>& root_windows() const { | 59 const std::vector<aura::Window*>& root_windows() const { |
63 return root_windows_; | 60 return root_windows_; |
64 }; | 61 }; |
65 | 62 |
66 private: | 63 private: |
67 // aura::EnvObserver: | 64 // aura::EnvObserver: |
68 void OnWindowInitialized(aura::Window* window) override {} | 65 void OnWindowInitialized(aura::Window* window) override {} |
69 void OnHostInitialized(aura::WindowTreeHost* host) override; | 66 void OnHostInitialized(aura::WindowTreeHost* host) override; |
(...skipping 21 matching lines...) Expand all Loading... |
91 ui::devtools::protocol::Response HighlightNode( | 88 ui::devtools::protocol::Response HighlightNode( |
92 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig> | 89 std::unique_ptr<ui::devtools::protocol::DOM::HighlightConfig> |
93 highlight_config, | 90 highlight_config, |
94 int node_id); | 91 int node_id); |
95 | 92 |
96 bool is_building_tree_; | 93 bool is_building_tree_; |
97 std::unique_ptr<UIElement> window_element_root_; | 94 std::unique_ptr<UIElement> window_element_root_; |
98 std::unordered_map<int, UIElement*> node_id_to_ui_element_; | 95 std::unordered_map<int, UIElement*> node_id_to_ui_element_; |
99 std::unique_ptr<views::Widget> widget_for_highlighting_; | 96 std::unique_ptr<views::Widget> widget_for_highlighting_; |
100 std::vector<aura::Window*> root_windows_; | 97 std::vector<aura::Window*> root_windows_; |
101 base::ObserverList<AshDevToolsDOMAgentObserver> observers_; | 98 base::ObserverList<UIDevToolsDOMAgentObserver> observers_; |
102 | 99 |
103 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent); | 100 DISALLOW_COPY_AND_ASSIGN(UIDevToolsDOMAgent); |
104 }; | 101 }; |
105 | 102 |
106 } // namespace devtools | 103 } // namespace devtools |
107 } // namespace ash | 104 } // namespace ui |
108 | 105 |
109 #endif // ASH_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ | 106 #endif // COMPONENTS_UI_DEVTOOLS_VIEWS_UI_DEVTOOLS_DOM_AGENT_H_ |
OLD | NEW |