| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 12 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 12 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| 13 #include "ui/aura/client/aura_constants.h" | 13 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/base/base_window.h" | 15 #include "ui/base/base_window.h" |
| 16 #include "ui/wm/core/window_animations.h" | 16 #include "ui/wm/core/window_animations.h" |
| 17 | 17 |
| 18 AppWindowLauncherItemController::AppWindowLauncherItemController( | 18 AppWindowLauncherItemController::AppWindowLauncherItemController( |
| 19 const ash::AppLaunchId& app_launch_id, | 19 const ash::AppLaunchId& app_launch_id) |
| 20 ChromeLauncherController* controller) | 20 : ash::ShelfItemDelegate(app_launch_id), observed_windows_(this) {} |
| 21 : LauncherItemController(app_launch_id, controller), | |
| 22 observed_windows_(this) {} | |
| 23 | 21 |
| 24 AppWindowLauncherItemController::~AppWindowLauncherItemController() {} | 22 AppWindowLauncherItemController::~AppWindowLauncherItemController() {} |
| 25 | 23 |
| 26 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) { | 24 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) { |
| 27 windows_.push_front(app_window); | 25 windows_.push_front(app_window); |
| 28 aura::Window* window = app_window->GetNativeWindow(); | 26 aura::Window* window = app_window->GetNativeWindow(); |
| 29 if (window) | 27 if (window) |
| 30 observed_windows_.Add(window); | 28 observed_windows_.Add(window); |
| 31 } | 29 } |
| 32 | 30 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 intptr_t old) { | 123 intptr_t old) { |
| 126 if (key == aura::client::kDrawAttentionKey) { | 124 if (key == aura::client::kDrawAttentionKey) { |
| 127 ash::ShelfItemStatus status; | 125 ash::ShelfItemStatus status; |
| 128 if (ash::wm::IsActiveWindow(window)) { | 126 if (ash::wm::IsActiveWindow(window)) { |
| 129 status = ash::STATUS_ACTIVE; | 127 status = ash::STATUS_ACTIVE; |
| 130 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { | 128 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { |
| 131 status = ash::STATUS_ATTENTION; | 129 status = ash::STATUS_ATTENTION; |
| 132 } else { | 130 } else { |
| 133 status = ash::STATUS_RUNNING; | 131 status = ash::STATUS_RUNNING; |
| 134 } | 132 } |
| 135 launcher_controller()->SetItemStatus(shelf_id(), status); | 133 ChromeLauncherController::instance()->SetItemStatus(shelf_id(), status); |
| 136 } | 134 } |
| 137 } | 135 } |
| 138 | 136 |
| 139 ash::ShelfAction AppWindowLauncherItemController::ShowAndActivateOrMinimize( | 137 ash::ShelfAction AppWindowLauncherItemController::ShowAndActivateOrMinimize( |
| 140 ui::BaseWindow* app_window) { | 138 ui::BaseWindow* app_window) { |
| 141 // Either show or minimize windows when shown from the launcher. | 139 // Either show or minimize windows when shown from the launcher. |
| 142 return launcher_controller()->ActivateWindowOrMinimizeIfActive( | 140 return ChromeLauncherController::instance()->ActivateWindowOrMinimizeIfActive( |
| 143 app_window, GetAppMenuItems(ui::EF_NONE).size() == 1); | 141 app_window, GetAppMenuItems(ui::EF_NONE).size() == 1); |
| 144 } | 142 } |
| 145 | 143 |
| 146 ash::ShelfAction | 144 ash::ShelfAction |
| 147 AppWindowLauncherItemController::ActivateOrAdvanceToNextAppWindow( | 145 AppWindowLauncherItemController::ActivateOrAdvanceToNextAppWindow( |
| 148 ui::BaseWindow* window_to_show) { | 146 ui::BaseWindow* window_to_show) { |
| 149 WindowList::iterator i( | 147 WindowList::iterator i( |
| 150 std::find(windows_.begin(), windows_.end(), window_to_show)); | 148 std::find(windows_.begin(), windows_.end(), window_to_show)); |
| 151 if (i != windows_.end()) { | 149 if (i != windows_.end()) { |
| 152 if (++i != windows_.end()) | 150 if (++i != windows_.end()) |
| 153 window_to_show = *i; | 151 window_to_show = *i; |
| 154 else | 152 else |
| 155 window_to_show = windows_.front(); | 153 window_to_show = windows_.front(); |
| 156 } | 154 } |
| 157 if (window_to_show->IsActive()) { | 155 if (window_to_show->IsActive()) { |
| 158 // Coming here, only a single window is active. For keyboard activations | 156 // Coming here, only a single window is active. For keyboard activations |
| 159 // the window gets animated. | 157 // the window gets animated. |
| 160 AnimateWindow(window_to_show->GetNativeWindow(), | 158 AnimateWindow(window_to_show->GetNativeWindow(), |
| 161 wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 159 wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| 162 } else { | 160 } else { |
| 163 return ShowAndActivateOrMinimize(window_to_show); | 161 return ShowAndActivateOrMinimize(window_to_show); |
| 164 } | 162 } |
| 165 return ash::SHELF_ACTION_NONE; | 163 return ash::SHELF_ACTION_NONE; |
| 166 } | 164 } |
| OLD | NEW |