Kristyn Hamasaki | 06170c05 | 2019-07-09 23:53:33 | [diff] [blame] | 1 | // Copyright 2019 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 | #include "components/ui_devtools/page_agent.h" |
| 6 | |
| 7 | #include "base/command_line.h" |
| 8 | #include "components/ui_devtools/ui_element.h" |
| 9 | |
| 10 | namespace ui_devtools { |
| 11 | |
| 12 | PageAgent::PageAgent(DOMAgent* dom_agent) : dom_agent_(dom_agent) {} |
| 13 | |
| 14 | PageAgent::~PageAgent() {} |
| 15 | |
| 16 | void PaintRectVector(std::vector<UIElement*> child_elements) { |
| 17 | for (auto* element : child_elements) { |
| 18 | if (element->type() == UIElementType::VIEW) { |
| 19 | element->PaintRect(); |
| 20 | } |
| 21 | PaintRectVector(element->children()); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | protocol::Response PageAgent::reload() { |
| 26 | if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 27 | "draw-view-bounds-rects")) { |
| 28 | base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 29 | "draw-view-bounds-rects"); |
| 30 | } else { |
| 31 | base::CommandLine::ForCurrentProcess()->InitFromArgv( |
| 32 | base::CommandLine::ForCurrentProcess()->argv()); |
| 33 | } |
| 34 | PaintRectVector(dom_agent_->element_root()->children()); |
| 35 | return protocol::Response::OK(); |
| 36 | } |
| 37 | |
| 38 | } // namespace ui_devtools |