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" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 if (index >= windows_.size()) | 103 if (index >= windows_.size()) |
104 return; | 104 return; |
105 auto it = windows_.begin(); | 105 auto it = windows_.begin(); |
106 std::advance(it, index); | 106 std::advance(it, index); |
107 ShowAndActivateOrMinimize(*it); | 107 ShowAndActivateOrMinimize(*it); |
108 } | 108 } |
109 | 109 |
110 ChromeLauncherAppMenuItems AppWindowLauncherItemController::GetApplicationList( | 110 ChromeLauncherAppMenuItems AppWindowLauncherItemController::GetApplicationList( |
111 int event_flags) { | 111 int event_flags) { |
112 ChromeLauncherAppMenuItems items; | 112 ChromeLauncherAppMenuItems items; |
| 113 // Add the application name to the menu. |
| 114 base::string16 app_title = LauncherControllerHelper::GetAppTitle( |
| 115 launcher_controller()->profile(), app_id()); |
113 items.push_back( | 116 items.push_back( |
114 base::MakeUnique<ChromeLauncherAppMenuItem>(GetTitle(), nullptr, false)); | 117 base::MakeUnique<ChromeLauncherAppMenuItem>(app_title, nullptr, false)); |
115 return items; | 118 return items; |
116 } | 119 } |
117 | 120 |
118 ash::ShelfItemDelegate::PerformedAction | 121 ash::ShelfItemDelegate::PerformedAction |
119 AppWindowLauncherItemController::ItemSelected(const ui::Event& event) { | 122 AppWindowLauncherItemController::ItemSelected(const ui::Event& event) { |
120 if (windows_.empty()) | 123 if (windows_.empty()) |
121 return kNoAction; | 124 return kNoAction; |
122 | 125 |
123 ui::BaseWindow* window_to_show = | 126 ui::BaseWindow* window_to_show = |
124 last_active_window_ ? last_active_window_ : windows_.front(); | 127 last_active_window_ ? last_active_window_ : windows_.front(); |
125 // If the event was triggered by a keystroke, we try to advance to the next | 128 // If the event was triggered by a keystroke, we try to advance to the next |
126 // item if the window we are trying to activate is already active. | 129 // item if the window we are trying to activate is already active. |
127 if (windows_.size() >= 1 && window_to_show->IsActive() && | 130 if (windows_.size() >= 1 && window_to_show->IsActive() && |
128 event.type() == ui::ET_KEY_RELEASED) { | 131 event.type() == ui::ET_KEY_RELEASED) { |
129 return ActivateOrAdvanceToNextAppWindow(window_to_show); | 132 return ActivateOrAdvanceToNextAppWindow(window_to_show); |
130 } else { | 133 } else { |
131 return ShowAndActivateOrMinimize(window_to_show); | 134 return ShowAndActivateOrMinimize(window_to_show); |
132 } | 135 } |
133 } | 136 } |
134 | 137 |
135 base::string16 AppWindowLauncherItemController::GetTitle() { | |
136 return LauncherControllerHelper::GetAppTitle(launcher_controller()->profile(), | |
137 app_id()); | |
138 } | |
139 | |
140 void AppWindowLauncherItemController::OnWindowPropertyChanged( | 138 void AppWindowLauncherItemController::OnWindowPropertyChanged( |
141 aura::Window* window, | 139 aura::Window* window, |
142 const void* key, | 140 const void* key, |
143 intptr_t old) { | 141 intptr_t old) { |
144 if (key == aura::client::kDrawAttentionKey) { | 142 if (key == aura::client::kDrawAttentionKey) { |
145 ash::ShelfItemStatus status; | 143 ash::ShelfItemStatus status; |
146 if (ash::wm::IsActiveWindow(window)) { | 144 if (ash::wm::IsActiveWindow(window)) { |
147 status = ash::STATUS_ACTIVE; | 145 status = ash::STATUS_ACTIVE; |
148 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { | 146 } else if (window->GetProperty(aura::client::kDrawAttentionKey)) { |
149 status = ash::STATUS_ATTENTION; | 147 status = ash::STATUS_ATTENTION; |
(...skipping 26 matching lines...) Expand all Loading... |
176 if (window_to_show->IsActive()) { | 174 if (window_to_show->IsActive()) { |
177 // Coming here, only a single window is active. For keyboard activations | 175 // Coming here, only a single window is active. For keyboard activations |
178 // the window gets animated. | 176 // the window gets animated. |
179 AnimateWindow(window_to_show->GetNativeWindow(), | 177 AnimateWindow(window_to_show->GetNativeWindow(), |
180 wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 178 wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
181 } else { | 179 } else { |
182 return ShowAndActivateOrMinimize(window_to_show); | 180 return ShowAndActivateOrMinimize(window_to_show); |
183 } | 181 } |
184 return kNoAction; | 182 return kNoAction; |
185 } | 183 } |
OLD | NEW |