| 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_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ | 5 #ifndef ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ |
| 6 #define ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ | 6 #define ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ |
| 7 | 7 |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "ash/common/wm_window_observer.h" | 9 #include "ash/common/wm_window_observer.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 WmWindow* GetWindowFromNodeId(int nodeId); | 39 WmWindow* GetWindowFromNodeId(int nodeId); |
| 40 views::Widget* GetWidgetFromNodeId(int nodeId); | 40 views::Widget* GetWidgetFromNodeId(int nodeId); |
| 41 views::View* GetViewFromNodeId(int nodeId); | 41 views::View* GetViewFromNodeId(int nodeId); |
| 42 | 42 |
| 43 int GetNodeIdFromWindow(WmWindow* window); | 43 int GetNodeIdFromWindow(WmWindow* window); |
| 44 int GetNodeIdFromWidget(views::Widget* widget); | 44 int GetNodeIdFromWidget(views::Widget* widget); |
| 45 int GetNodeIdFromView(views::View* view); | 45 int GetNodeIdFromView(views::View* view); |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree(); |
| 49 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow( |
| 50 WmWindow* window); |
| 51 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForRootWidget( |
| 52 views::Widget* widget); |
| 48 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForView( | 53 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForView( |
| 49 views::View* view); | 54 views::View* view); |
| 50 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForRootWidget( | 55 |
| 51 views::Widget* widget); | 56 void AddWindowTree(WmWindow* window); |
| 52 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildTreeForWindow( | 57 // |remove_observer| ensures that we don't add a duplicate observer in any |
| 53 WmWindow* window); | 58 // observer callback. For example, |remove_observer| is false when rebuilding |
| 54 std::unique_ptr<ui::devtools::protocol::DOM::Node> BuildInitialTree(); | 59 // the tree in OnWindowStackingChanged so that the observer is not removed and |
| 55 void AddWindowNode(WmWindow* window); | 60 // re-added, thus causing endless calls on the observer. |
| 56 void RemoveWindowNode(WmWindow* window); | 61 void RemoveWindowTree(WmWindow* window, bool remove_observer); |
| 57 void RemoveWidgetNode(views::Widget* widget); | 62 void RemoveWindowNode(WmWindow* window, bool remove_observer); |
| 58 void RemoveViewNode(views::View* view); | 63 |
| 64 void RemoveWidgetTree(views::Widget* widget, bool remove_observer); |
| 65 void RemoveWidgetNode(views::Widget* widget, bool remove_observer); |
| 66 |
| 67 void RemoveViewTree(views::View* view, |
| 68 views::View* parent, |
| 69 bool remove_observer); |
| 70 void RemoveViewNode(views::View* view, |
| 71 views::View* parent, |
| 72 bool remove_observer); |
| 73 |
| 59 void RemoveObserverFromAllWindows(); | 74 void RemoveObserverFromAllWindows(); |
| 60 void AddRootWindowObservers(); | |
| 61 void Reset(); | 75 void Reset(); |
| 62 | 76 |
| 63 ash::WmShell* shell_; | 77 ash::WmShell* shell_; |
| 64 | 78 |
| 65 using WindowToNodeIdMap = std::unordered_map<WmWindow*, int>; | 79 using WindowToNodeIdMap = std::unordered_map<WmWindow*, int>; |
| 66 WindowToNodeIdMap window_to_node_id_map_; | 80 WindowToNodeIdMap window_to_node_id_map_; |
| 67 using NodeIdToWindowMap = std::unordered_map<int, WmWindow*>; | 81 using NodeIdToWindowMap = std::unordered_map<int, WmWindow*>; |
| 68 NodeIdToWindowMap node_id_to_window_map_; | 82 NodeIdToWindowMap node_id_to_window_map_; |
| 69 | 83 |
| 70 using WidgetToNodeIdMap = std::unordered_map<views::Widget*, int>; | 84 using WidgetToNodeIdMap = std::unordered_map<views::Widget*, int>; |
| 71 WidgetToNodeIdMap widget_to_node_id_map_; | 85 WidgetToNodeIdMap widget_to_node_id_map_; |
| 72 using NodeIdToWidgetMap = std::unordered_map<int, views::Widget*>; | 86 using NodeIdToWidgetMap = std::unordered_map<int, views::Widget*>; |
| 73 NodeIdToWidgetMap node_id_to_widget_map_; | 87 NodeIdToWidgetMap node_id_to_widget_map_; |
| 74 | 88 |
| 75 using ViewToNodeIdMap = std::unordered_map<views::View*, int>; | 89 using ViewToNodeIdMap = std::unordered_map<views::View*, int>; |
| 76 ViewToNodeIdMap view_to_node_id_map_; | 90 ViewToNodeIdMap view_to_node_id_map_; |
| 77 using NodeIdToViewMap = std::unordered_map<int, views::View*>; | 91 using NodeIdToViewMap = std::unordered_map<int, views::View*>; |
| 78 NodeIdToViewMap node_id_to_view_map_; | 92 NodeIdToViewMap node_id_to_view_map_; |
| 79 | 93 |
| 80 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent); | 94 DISALLOW_COPY_AND_ASSIGN(AshDevToolsDOMAgent); |
| 81 }; | 95 }; |
| 82 | 96 |
| 83 } // namespace devtools | 97 } // namespace devtools |
| 84 } // namespace ash | 98 } // namespace ash |
| 85 | 99 |
| 86 #endif // ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ | 100 #endif // ASH_COMMON_DEVTOOLS_ASH_DEVTOOLS_DOM_AGENT_H_ |
| OLD | NEW |