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

Side by Side Diff: chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.cc

Issue 2545923004: Remove LauncherItemController::type; use ShelfItems::type. (Closed)
Patch Set: Rebase; remove new LauncherItemController::TYPE_APP check. Created 4 years 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
OLDNEW
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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 10 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.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 Type type,
20 const std::string& app_id, 19 const std::string& app_id,
21 const std::string& launch_id, 20 const std::string& launch_id,
22 ChromeLauncherController* controller) 21 ChromeLauncherController* controller)
23 : LauncherItemController(type, app_id, launch_id, controller), 22 : LauncherItemController(app_id, launch_id, controller),
24 observed_windows_(this) {} 23 observed_windows_(this) {}
25 24
26 AppWindowLauncherItemController::~AppWindowLauncherItemController() {} 25 AppWindowLauncherItemController::~AppWindowLauncherItemController() {}
27 26
28 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) { 27 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) {
29 windows_.push_front(app_window); 28 windows_.push_front(app_window);
30 aura::Window* window = app_window->GetNativeWindow(); 29 aura::Window* window = app_window->GetNativeWindow();
31 if (window) 30 if (window)
32 observed_windows_.Add(window); 31 observed_windows_.Add(window);
33 } 32 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ChromeLauncherAppMenuItems items; 112 ChromeLauncherAppMenuItems items;
114 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); 113 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false));
115 return items; 114 return items;
116 } 115 }
117 116
118 ash::ShelfItemDelegate::PerformedAction 117 ash::ShelfItemDelegate::PerformedAction
119 AppWindowLauncherItemController::ItemSelected(const ui::Event& event) { 118 AppWindowLauncherItemController::ItemSelected(const ui::Event& event) {
120 if (windows_.empty()) 119 if (windows_.empty())
121 return kNoAction; 120 return kNoAction;
122 121
123 DCHECK_EQ(TYPE_APP, type());
124 ui::BaseWindow* window_to_show = 122 ui::BaseWindow* window_to_show =
125 last_active_window_ ? last_active_window_ : windows_.front(); 123 last_active_window_ ? last_active_window_ : windows_.front();
126 // If the event was triggered by a keystroke, we try to advance to the next 124 // If the event was triggered by a keystroke, we try to advance to the next
127 // item if the window we are trying to activate is already active. 125 // item if the window we are trying to activate is already active.
128 if (windows_.size() >= 1 && window_to_show->IsActive() && 126 if (windows_.size() >= 1 && window_to_show->IsActive() &&
129 event.type() == ui::ET_KEY_RELEASED) { 127 event.type() == ui::ET_KEY_RELEASED) {
130 return ActivateOrAdvanceToNextAppWindow(window_to_show); 128 return ActivateOrAdvanceToNextAppWindow(window_to_show);
131 } else { 129 } else {
132 return ShowAndActivateOrMinimize(window_to_show); 130 return ShowAndActivateOrMinimize(window_to_show);
133 } 131 }
134 } 132 }
135 133
136 base::string16 AppWindowLauncherItemController::GetTitle() { 134 base::string16 AppWindowLauncherItemController::GetTitle() {
137 return LauncherControllerHelper::GetAppTitle(launcher_controller()->profile(), 135 return LauncherControllerHelper::GetAppTitle(launcher_controller()->profile(),
138 app_id()); 136 app_id());
139 } 137 }
140 138
141 bool AppWindowLauncherItemController::IsDraggable() { 139 bool AppWindowLauncherItemController::IsDraggable() {
142 DCHECK_EQ(TYPE_APP, type());
143 return true; 140 return true;
144 } 141 }
145 142
146 bool AppWindowLauncherItemController::CanPin() const { 143 bool AppWindowLauncherItemController::CanPin() const {
147 return GetPinnableForAppID(app_id(), launcher_controller()->profile()) == 144 return GetPinnableForAppID(app_id(), launcher_controller()->profile()) ==
148 AppListControllerDelegate::PIN_EDITABLE; 145 AppListControllerDelegate::PIN_EDITABLE;
149 } 146 }
150 147
151 bool AppWindowLauncherItemController::ShouldShowTooltip() { 148 bool AppWindowLauncherItemController::ShouldShowTooltip() {
152 DCHECK_EQ(TYPE_APP, type());
153 return true; 149 return true;
154 } 150 }
155 151
156 void AppWindowLauncherItemController::OnWindowPropertyChanged( 152 void AppWindowLauncherItemController::OnWindowPropertyChanged(
157 aura::Window* window, 153 aura::Window* window,
158 const void* key, 154 const void* key,
159 intptr_t old) { 155 intptr_t old) {
160 if (key == aura::client::kDrawAttentionKey) { 156 if (key == aura::client::kDrawAttentionKey) {
161 ash::ShelfItemStatus status; 157 ash::ShelfItemStatus status;
162 if (ash::wm::IsActiveWindow(window)) { 158 if (ash::wm::IsActiveWindow(window)) {
(...skipping 29 matching lines...) Expand all
192 if (window_to_show->IsActive()) { 188 if (window_to_show->IsActive()) {
193 // Coming here, only a single window is active. For keyboard activations 189 // Coming here, only a single window is active. For keyboard activations
194 // the window gets animated. 190 // the window gets animated.
195 AnimateWindow(window_to_show->GetNativeWindow(), 191 AnimateWindow(window_to_show->GetNativeWindow(),
196 wm::WINDOW_ANIMATION_TYPE_BOUNCE); 192 wm::WINDOW_ANIMATION_TYPE_BOUNCE);
197 } else { 193 } else {
198 return ShowAndActivateOrMinimize(window_to_show); 194 return ShowAndActivateOrMinimize(window_to_show);
199 } 195 }
200 return kNoAction; 196 return kNoAction;
201 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698