| 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 #include "ash/common/devtools/ash_devtools_dom_agent.h" | 5 #include "ash/common/devtools/ash_devtools_dom_agent.h" |
| 6 | 6 |
| 7 #include "ash/common/wm_window.h" | 7 #include "ash/common/wm_window.h" |
| 8 #include "components/ui_devtools/devtools_server.h" | 8 #include "components/ui_devtools/devtools_server.h" |
| 9 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
| 10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| 11 | 11 |
| 12 namespace ash { | 12 namespace ash { |
| 13 namespace devtools { | 13 namespace devtools { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 using namespace ui::devtools::protocol; | 16 using namespace ui::devtools::protocol; |
| 17 | 17 |
| 18 std::unique_ptr<DOM::Node> BuildNode( | 18 std::unique_ptr<DOM::Node> BuildNode( |
| 19 const std::string& name, | 19 const std::string& name, |
| 20 std::unique_ptr<Array<std::string>> attributes, | 20 std::unique_ptr<Array<std::string>> attributes, |
| 21 std::unique_ptr<Array<DOM::Node>> children) { | 21 std::unique_ptr<Array<DOM::Node>> children) { |
| 22 static DOM::NodeId node_ids = 0; | 22 static DOM::NodeId node_ids = 0; |
| 23 constexpr int kDomElementNodeType = 1; | 23 constexpr int kDomElementNodeType = 1; |
| 24 return DOM::Node::create() | 24 std::unique_ptr<DOM::Node> node = DOM::Node::create() |
| 25 .setNodeId(node_ids++) | 25 .setNodeId(node_ids++) |
| 26 .setNodeName(name) | 26 .setNodeName(name) |
| 27 .setNodeType(kDomElementNodeType) | 27 .setNodeType(kDomElementNodeType) |
| 28 .setAttributes(std::move(attributes)) | 28 .setAttributes(std::move(attributes)) |
| 29 .setChildNodeCount(children->length()) | 29 .build(); |
| 30 .setChildren(std::move(children)) | 30 node->setChildNodeCount(children->length()); |
| 31 .build(); | 31 node->setChildren(std::move(children)); |
| 32 return node; |
| 32 } | 33 } |
| 33 | 34 |
| 34 std::unique_ptr<Array<std::string>> GetAttributes(const ash::WmWindow* window) { | 35 std::unique_ptr<Array<std::string>> GetAttributes(const ash::WmWindow* window) { |
| 35 std::unique_ptr<Array<std::string>> attributes = Array<std::string>::create(); | 36 std::unique_ptr<Array<std::string>> attributes = Array<std::string>::create(); |
| 36 attributes->addItem("name"); | 37 attributes->addItem("name"); |
| 37 attributes->addItem(window->GetName()); | 38 attributes->addItem(window->GetName()); |
| 38 attributes->addItem("active"); | 39 attributes->addItem("active"); |
| 39 attributes->addItem(window->IsActive() ? "true" : "false"); | 40 attributes->addItem(window->IsActive() ? "true" : "false"); |
| 40 return attributes; | 41 return attributes; |
| 41 } | 42 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 108 } |
| 108 | 109 |
| 109 ui::devtools::protocol::Response AshDevToolsDOMAgent::getDocument( | 110 ui::devtools::protocol::Response AshDevToolsDOMAgent::getDocument( |
| 110 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) { | 111 std::unique_ptr<ui::devtools::protocol::DOM::Node>* out_root) { |
| 111 *out_root = BuildInitialTree(); | 112 *out_root = BuildInitialTree(); |
| 112 return ui::devtools::protocol::Response::OK(); | 113 return ui::devtools::protocol::Response::OK(); |
| 113 } | 114 } |
| 114 | 115 |
| 115 } // namespace devtools | 116 } // namespace devtools |
| 116 } // namespace ash | 117 } // namespace ash |
| OLD | NEW |