| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/launcher/launcher_util.h" | 5 #include "ash/launcher/launcher_util.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher_model.h" | 7 #include "ash/launcher/launcher_model.h" |
| 8 #include "ash/launcher/launcher_types.h" | 8 #include "ash/launcher/launcher_types.h" |
| 9 #include "ash/shell.h" | |
| 10 #include "ui/aura/client/window_types.h" | |
| 11 #include "ui/aura/window.h" | |
| 12 #include "ui/views/view.h" | |
| 13 #include "ui/views/widget/widget.h" | |
| 14 | 9 |
| 15 namespace ash { | 10 namespace ash { |
| 16 namespace launcher { | 11 namespace launcher { |
| 17 | 12 |
| 18 int GetBrowserItemIndex(const LauncherModel& launcher_model) { | 13 int GetBrowserItemIndex(const LauncherModel& launcher_model) { |
| 19 for (size_t i = 0; i < launcher_model.items().size(); i++) { | 14 for (size_t i = 0; i < launcher_model.items().size(); i++) { |
| 20 if (launcher_model.items()[i].type == ash::TYPE_BROWSER_SHORTCUT) | 15 if (launcher_model.items()[i].type == ash::TYPE_BROWSER_SHORTCUT) |
| 21 return i; | 16 return i; |
| 22 } | 17 } |
| 23 return -1; | 18 return -1; |
| 24 } | 19 } |
| 25 | 20 |
| 26 void MoveToEventRootIfPanel(aura::Window* maybe_panel, | |
| 27 const ui::Event& event) { | |
| 28 if (maybe_panel->type() != aura::client::WINDOW_TYPE_PANEL) | |
| 29 return; | |
| 30 views::View* target = static_cast<views::View*>(event.target()); | |
| 31 aura::RootWindow* target_root = | |
| 32 target ? target->GetWidget()->GetNativeView()->GetRootWindow() : NULL; | |
| 33 if (target_root && target_root != maybe_panel->GetRootWindow()) { | |
| 34 aura::Window* panel_container = | |
| 35 ash::Shell::GetContainer(target_root, maybe_panel->parent()->id()); | |
| 36 // Move the panel to the target launcher. | |
| 37 panel_container->AddChild(maybe_panel); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 } // namespace launcher | 21 } // namespace launcher |
| 42 } // namespace ash | 22 } // namespace ash |
| OLD | NEW |