| 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/public/cpp/shelf_application_menu_item.h" | 9 #include "ash/public/cpp/shelf_application_menu_item.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Ideally we come here only once. After that ShellLauncherItemController | 101 // Ideally we come here only once. After that ShellLauncherItemController |
| 102 // will take over when the shell window gets opened. However there are apps | 102 // will take over when the shell window gets opened. However there are apps |
| 103 // which take a lot of time for pre-processing (like the files app) before | 103 // which take a lot of time for pre-processing (like the files app) before |
| 104 // they open a window. Since there is currently no other way to detect if an | 104 // they open a window. Since there is currently no other way to detect if an |
| 105 // app was started we suppress any further clicks within a special time out. | 105 // app was started we suppress any further clicks within a special time out. |
| 106 if (IsV2App() && !AllowNextLaunchAttempt()) | 106 if (IsV2App() && !AllowNextLaunchAttempt()) |
| 107 return kNoAction; | 107 return kNoAction; |
| 108 | 108 |
| 109 // Launching some items replaces this item controller instance, which | 109 // Launching some items replaces this item controller instance, which |
| 110 // destroys the app and launch id strings; making copies avoid crashes. | 110 // destroys the app and launch id strings; making copies avoid crashes. |
| 111 launcher_controller()->LaunchApp( | 111 launcher_controller()->LaunchApp(ash::AppLauncherId(app_id(), launch_id()), |
| 112 ash::launcher::AppLauncherId(app_id(), launch_id()), source, | 112 source, ui::EF_NONE); |
| 113 ui::EF_NONE); | |
| 114 return kNewWindowCreated; | 113 return kNewWindowCreated; |
| 115 } | 114 } |
| 116 return ActivateContent(content); | 115 return ActivateContent(content); |
| 117 } | 116 } |
| 118 | 117 |
| 119 ash::ShelfItemDelegate::PerformedAction | 118 ash::ShelfItemDelegate::PerformedAction |
| 120 AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) { | 119 AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) { |
| 121 // In case of a keyboard event, we were called by a hotkey. In that case we | 120 // In case of a keyboard event, we were called by a hotkey. In that case we |
| 122 // activate the next item in line if an item of our list is already active. | 121 // activate the next item in line if an item of our list is already active. |
| 123 if (event.type() == ui::ET_KEY_RELEASED && AdvanceToNextApp()) | 122 if (event.type() == ui::ET_KEY_RELEASED && AdvanceToNextApp()) |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 325 |
| 327 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { | 326 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { |
| 328 if (last_launch_attempt_.is_null() || | 327 if (last_launch_attempt_.is_null() || |
| 329 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( | 328 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( |
| 330 kClickSuppressionInMS) < base::Time::Now()) { | 329 kClickSuppressionInMS) < base::Time::Now()) { |
| 331 last_launch_attempt_ = base::Time::Now(); | 330 last_launch_attempt_ = base::Time::Now(); |
| 332 return true; | 331 return true; |
| 333 } | 332 } |
| 334 return false; | 333 return false; |
| 335 } | 334 } |
| OLD | NEW |