Get foreground tab on Android
[chromium-blink-merge.git] / ui / oak / oak_tree_model.cc
blob375c3c0fcbd20dd6764e71562f06029f34a4b850
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.
5 #include "ui/oak/oak_tree_model.h"
7 #include "base/strings/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"
12 namespace oak {
13 namespace internal {
15 base::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);
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);
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;
38 } // namespace internal
39 } // namespace oak