| 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/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" | 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" |
| 12 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 13 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
| 13 #include "ui/aura/client/aura_constants.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/base/base_window.h" | 16 #include "ui/base/base_window.h" |
| 16 #include "ui/wm/core/window_animations.h" | 17 #include "ui/wm/core/window_animations.h" |
| 17 | 18 |
| 18 AppWindowLauncherItemController::AppWindowLauncherItemController( | 19 AppWindowLauncherItemController::AppWindowLauncherItemController( |
| 19 Type type, | 20 Type type, |
| 20 const std::string& app_id, | 21 const std::string& app_id, |
| 21 const std::string& launch_id, | 22 const std::string& launch_id, |
| 23 const std::string& title, |
| 22 ChromeLauncherController* controller) | 24 ChromeLauncherController* controller) |
| 23 : LauncherItemController(type, app_id, launch_id, controller), | 25 : LauncherItemController(type, app_id, launch_id, title, controller), |
| 24 app_id_(app_id), | 26 app_id_(app_id), |
| 25 launch_id_(launch_id), | 27 launch_id_(launch_id), |
| 28 title_(title), |
| 26 observed_windows_(this) {} | 29 observed_windows_(this) {} |
| 27 | 30 |
| 28 AppWindowLauncherItemController::~AppWindowLauncherItemController() {} | 31 AppWindowLauncherItemController::~AppWindowLauncherItemController() {} |
| 29 | 32 |
| 30 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) { | 33 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) { |
| 31 windows_.push_front(app_window); | 34 windows_.push_front(app_window); |
| 32 aura::Window* window = app_window->GetNativeWindow(); | 35 aura::Window* window = app_window->GetNativeWindow(); |
| 33 if (window) | 36 if (window) |
| 34 observed_windows_.Add(window); | 37 observed_windows_.Add(window); |
| 35 } | 38 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // item if the window we are trying to activate is already active. | 136 // item if the window we are trying to activate is already active. |
| 134 if (windows_.size() >= 1 && window_to_show->IsActive() && | 137 if (windows_.size() >= 1 && window_to_show->IsActive() && |
| 135 event.type() == ui::ET_KEY_RELEASED) { | 138 event.type() == ui::ET_KEY_RELEASED) { |
| 136 return ActivateOrAdvanceToNextAppWindow(window_to_show); | 139 return ActivateOrAdvanceToNextAppWindow(window_to_show); |
| 137 } else { | 140 } else { |
| 138 return ShowAndActivateOrMinimize(window_to_show); | 141 return ShowAndActivateOrMinimize(window_to_show); |
| 139 } | 142 } |
| 140 } | 143 } |
| 141 | 144 |
| 142 base::string16 AppWindowLauncherItemController::GetTitle() { | 145 base::string16 AppWindowLauncherItemController::GetTitle() { |
| 143 return LauncherControllerHelper::GetAppTitle(launcher_controller()->profile(), | 146 if (!title().empty()) |
| 144 app_id()); | 147 return base::UTF8ToUTF16(title()); |
| 148 else |
| 149 return LauncherControllerHelper::GetAppTitle( |
| 150 launcher_controller()->profile(), app_id()); |
| 145 } | 151 } |
| 146 | 152 |
| 147 bool AppWindowLauncherItemController::IsDraggable() { | 153 bool AppWindowLauncherItemController::IsDraggable() { |
| 148 DCHECK_EQ(TYPE_APP, type()); | 154 DCHECK_EQ(TYPE_APP, type()); |
| 149 return true; | 155 return true; |
| 150 } | 156 } |
| 151 | 157 |
| 152 bool AppWindowLauncherItemController::CanPin() const { | 158 bool AppWindowLauncherItemController::CanPin() const { |
| 153 return GetPinnableForAppID(app_id(), launcher_controller()->profile()) == | 159 return GetPinnableForAppID(app_id(), launcher_controller()->profile()) == |
| 154 AppListControllerDelegate::PIN_EDITABLE; | 160 AppListControllerDelegate::PIN_EDITABLE; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 if (window_to_show->IsActive()) { | 204 if (window_to_show->IsActive()) { |
| 199 // Coming here, only a single window is active. For keyboard activations | 205 // Coming here, only a single window is active. For keyboard activations |
| 200 // the window gets animated. | 206 // the window gets animated. |
| 201 AnimateWindow(window_to_show->GetNativeWindow(), | 207 AnimateWindow(window_to_show->GetNativeWindow(), |
| 202 wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 208 wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| 203 } else { | 209 } else { |
| 204 return ShowAndActivateOrMinimize(window_to_show); | 210 return ShowAndActivateOrMinimize(window_to_show); |
| 205 } | 211 } |
| 206 return kNoAction; | 212 return kNoAction; |
| 207 } | 213 } |
| OLD | NEW |