blob: ec955f1bc05bd75b6aac3b0cd0a7dc6241cd5ce9 [file] [log] [blame]
Kristyn Hamasaki06170c052019-07-09 23:53:331// 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
10namespace ui_devtools {
11
12PageAgent::PageAgent(DOMAgent* dom_agent) : dom_agent_(dom_agent) {}
13
14PageAgent::~PageAgent() {}
15
16void 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
25protocol::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