| 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_css_agent.h" | 5 #include "ash/common/devtools/ash_devtools_css_agent.h" |
| 6 | 6 |
| 7 #include "ash/common/wm_window.h" | 7 #include "ash/common/wm_window.h" |
| 8 | 8 |
| 9 namespace ash { | 9 namespace ash { |
| 10 namespace devtools { | 10 namespace devtools { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 AshDevToolsCSSAgent::AshDevToolsCSSAgent(AshDevToolsDOMAgent* dom_agent) | 59 AshDevToolsCSSAgent::AshDevToolsCSSAgent(AshDevToolsDOMAgent* dom_agent) |
| 60 : dom_agent_(dom_agent) { | 60 : dom_agent_(dom_agent) { |
| 61 DCHECK(dom_agent_); | 61 DCHECK(dom_agent_); |
| 62 } | 62 } |
| 63 | 63 |
| 64 AshDevToolsCSSAgent::~AshDevToolsCSSAgent() {} | 64 AshDevToolsCSSAgent::~AshDevToolsCSSAgent() {} |
| 65 | 65 |
| 66 ui::devtools::protocol::Response AshDevToolsCSSAgent::getMatchedStylesForNode( | 66 ui::devtools::protocol::Response AshDevToolsCSSAgent::getMatchedStylesForNode( |
| 67 int nodeId, | 67 int node_id, |
| 68 ui::devtools::protocol::Maybe<ui::devtools::protocol::CSS::CSSStyle>* | 68 ui::devtools::protocol::Maybe<ui::devtools::protocol::CSS::CSSStyle>* |
| 69 inlineStyle) { | 69 inlineStyle) { |
| 70 *inlineStyle = GetStylesForNode(nodeId); | 70 *inlineStyle = GetStylesForNode(node_id); |
| 71 if (!inlineStyle) { |
| 72 return ui::devtools::protocol::Response::Error( |
| 73 "Node with that id not found"); |
| 74 } |
| 71 return ui::devtools::protocol::Response::OK(); | 75 return ui::devtools::protocol::Response::OK(); |
| 72 } | 76 } |
| 73 | 77 |
| 74 std::unique_ptr<ui::devtools::protocol::CSS::CSSStyle> | 78 std::unique_ptr<ui::devtools::protocol::CSS::CSSStyle> |
| 75 AshDevToolsCSSAgent::GetStylesForNode(int nodeId) { | 79 AshDevToolsCSSAgent::GetStylesForNode(int node_id) { |
| 76 WmWindow* window = dom_agent_->GetWindowFromNodeId(nodeId); | 80 WmWindow* window = dom_agent_->GetWindowFromNodeId(node_id); |
| 77 if (window) | 81 if (window) |
| 78 return BuildStyles(window); | 82 return BuildStyles(window); |
| 79 | 83 |
| 80 views::Widget* widget = dom_agent_->GetWidgetFromNodeId(nodeId); | 84 views::Widget* widget = dom_agent_->GetWidgetFromNodeId(node_id); |
| 81 if (widget) | 85 if (widget) |
| 82 return BuildStyles(widget); | 86 return BuildStyles(widget); |
| 83 | 87 |
| 84 views::View* view = dom_agent_->GetViewFromNodeId(nodeId); | 88 views::View* view = dom_agent_->GetViewFromNodeId(node_id); |
| 85 if (view) | 89 if (view) |
| 86 return BuildStyles(view); | 90 return BuildStyles(view); |
| 87 | 91 |
| 88 NOTREACHED(); | |
| 89 return nullptr; | 92 return nullptr; |
| 90 } | 93 } |
| 91 | 94 |
| 92 } // namespace devtools | 95 } // namespace devtools |
| 93 } // namespace ash | 96 } // namespace ash |
| OLD | NEW |