Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: ui/oak/oak_tree_model.cc

Issue 9662022: Basic skeleton of a window/layer/view inspector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 "ui/oak/oak_tree_model.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "ui/aura/root_window.h"
9 #include "ui/aura/window.h"
10 #include "ui/base/models/tree_node_model.h"
11
12 namespace oak {
13 namespace internal {
14
15 string16 GetNodeTitleForWindow(aura::Window* window) {
16 std::string window_name = window->name();
17 if (window_name.empty())
18 window_name.append("Unnamed window");
19 return ASCIIToUTF16(window_name);
20 }
21
22 void AddChildWindows(aura::Window* parent_window, WindowNode* parent_node) {
23 aura::Window::Windows::const_iterator it = parent_window->children().begin();
24 for (; it != parent_window->children().end(); ++it) {
25 WindowNode* child_node = new WindowNode(GetNodeTitleForWindow(*it), *it);
26 parent_node->Add(child_node, parent_node->child_count());
27 AddChildWindows(*it, child_node);
28 }
29 }
30
31 TreeOfWindows* GenerateModel(aura::Window* root) {
32 WindowNode* root_node = new WindowNode(GetNodeTitleForWindow(root), root);
33 TreeOfWindows* tree = new TreeOfWindows(root_node);
34 AddChildWindows(root, root_node);
35 return tree;
36 }
37
38 } // namespace internal
39 } // namespace oak
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698