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 "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" | 5 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 int index = tab_strip->GetIndexOfWebContents(content[i]); | 149 int index = tab_strip->GetIndexOfWebContents(content[i]); |
150 DCHECK(index != TabStripModel::kNoTab); | 150 DCHECK(index != TabStripModel::kNoTab); |
151 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_NONE); | 151 tab_strip->CloseWebContentsAt(index, TabStripModel::CLOSE_NONE); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 ChromeLauncherAppMenuItems | 155 ChromeLauncherAppMenuItems |
156 AppShortcutLauncherItemController::GetApplicationList(int event_flags) { | 156 AppShortcutLauncherItemController::GetApplicationList(int event_flags) { |
157 ChromeLauncherAppMenuItems items; | 157 ChromeLauncherAppMenuItems items; |
158 // Add the application name to the menu. | 158 // Add the application name to the menu. |
| 159 base::string16 app_title = LauncherControllerHelper::GetAppTitle( |
| 160 launcher_controller()->profile(), app_id()); |
159 items.push_back( | 161 items.push_back( |
160 base::MakeUnique<ChromeLauncherAppMenuItem>(GetTitle(), nullptr, false)); | 162 base::MakeUnique<ChromeLauncherAppMenuItem>(app_title, nullptr, false)); |
161 | 163 |
162 std::vector<content::WebContents*> content_list = GetRunningApplications(); | 164 std::vector<content::WebContents*> content_list = GetRunningApplications(); |
163 | 165 |
164 for (size_t i = 0; i < content_list.size(); i++) { | 166 for (size_t i = 0; i < content_list.size(); i++) { |
165 content::WebContents* web_contents = content_list[i]; | 167 content::WebContents* web_contents = content_list[i]; |
166 // Get the icon. | 168 // Get the icon. |
167 gfx::Image app_icon = launcher_controller()->GetAppListIcon(web_contents); | 169 gfx::Image app_icon = launcher_controller()->GetAppListIcon(web_contents); |
168 base::string16 title = launcher_controller()->GetAppListTitle(web_contents); | 170 base::string16 title = launcher_controller()->GetAppListTitle(web_contents); |
169 items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemTab>( | 171 items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemTab>( |
170 title, &app_icon, web_contents, i == 0)); | 172 title, &app_icon, web_contents, i == 0)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) { | 211 AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) { |
210 // In case of a keyboard event, we were called by a hotkey. In that case we | 212 // In case of a keyboard event, we were called by a hotkey. In that case we |
211 // activate the next item in line if an item of our list is already active. | 213 // activate the next item in line if an item of our list is already active. |
212 if (event.type() == ui::ET_KEY_RELEASED) { | 214 if (event.type() == ui::ET_KEY_RELEASED) { |
213 if (AdvanceToNextApp()) | 215 if (AdvanceToNextApp()) |
214 return kExistingWindowActivated; | 216 return kExistingWindowActivated; |
215 } | 217 } |
216 return Activate(ash::LAUNCH_FROM_UNKNOWN); | 218 return Activate(ash::LAUNCH_FROM_UNKNOWN); |
217 } | 219 } |
218 | 220 |
219 base::string16 AppShortcutLauncherItemController::GetTitle() { | |
220 return LauncherControllerHelper::GetAppTitle(launcher_controller()->profile(), | |
221 app_id()); | |
222 } | |
223 | |
224 ash::ShelfMenuModel* AppShortcutLauncherItemController::CreateApplicationMenu( | 221 ash::ShelfMenuModel* AppShortcutLauncherItemController::CreateApplicationMenu( |
225 int event_flags) { | 222 int event_flags) { |
226 return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags)); | 223 return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags)); |
227 } | 224 } |
228 | 225 |
229 content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() { | 226 content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() { |
230 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); | 227 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); |
231 refocus_pattern.SetMatchAllURLs(true); | 228 refocus_pattern.SetMatchAllURLs(true); |
232 | 229 |
233 if (!refocus_url_.is_empty()) { | 230 if (!refocus_url_.is_empty()) { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 362 |
366 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { | 363 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { |
367 if (last_launch_attempt_.is_null() || | 364 if (last_launch_attempt_.is_null() || |
368 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( | 365 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( |
369 kClickSuppressionInMS) < base::Time::Now()) { | 366 kClickSuppressionInMS) < base::Time::Now()) { |
370 last_launch_attempt_ = base::Time::Now(); | 367 last_launch_attempt_ = base::Time::Now(); |
371 return true; | 368 return true; |
372 } | 369 } |
373 return false; | 370 return false; |
374 } | 371 } |
OLD | NEW |