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 "chrome/browser/chromeos/arc/arc_support_host.h" | 10 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 for (size_t i = 0; i < content.size(); i++) { | 102 for (size_t i = 0; i < content.size(); i++) { |
103 Browser* browser = chrome::FindBrowserWithWebContents(content[i]); | 103 Browser* browser = chrome::FindBrowserWithWebContents(content[i]); |
104 if (browser && browser->window()->GetNativeWindow()->IsVisible()) | 104 if (browser && browser->window()->GetNativeWindow()->IsVisible()) |
105 return true; | 105 return true; |
106 } | 106 } |
107 return false; | 107 return false; |
108 } | 108 } |
109 | 109 |
110 void AppShortcutLauncherItemController::Launch(ash::LaunchSource source, | 110 void AppShortcutLauncherItemController::Launch(ash::LaunchSource source, |
111 int event_flags) { | 111 int event_flags) { |
112 launcher_controller()->LaunchAppWithLaunchId(app_id(), launch_id(), source, | 112 // Launching an app replaces shortcut item controller to app controller. As |
113 event_flags); | 113 // result app_id_, launch_id_ are deleted during this call. Use local copies |
| 114 // to prevent crash condition. |
| 115 launcher_controller()->LaunchAppWithLaunchId( |
| 116 std::string(app_id()), std::string(launch_id()), source, event_flags); |
114 } | 117 } |
115 | 118 |
116 ash::ShelfItemDelegate::PerformedAction | 119 ash::ShelfItemDelegate::PerformedAction |
117 AppShortcutLauncherItemController::Activate(ash::LaunchSource source) { | 120 AppShortcutLauncherItemController::Activate(ash::LaunchSource source) { |
118 content::WebContents* content = GetLRUApplication(); | 121 content::WebContents* content = GetLRUApplication(); |
119 if (!content) { | 122 if (!content) { |
120 if (IsV2App()) { | 123 if (IsV2App()) { |
121 // Ideally we come here only once. After that ShellLauncherItemController | 124 // Ideally we come here only once. After that ShellLauncherItemController |
122 // will take over when the shell window gets opened. However there are | 125 // will take over when the shell window gets opened. However there are |
123 // apps which take a lot of time for pre-processing (like the files app) | 126 // apps which take a lot of time for pre-processing (like the files app) |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 368 |
366 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { | 369 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { |
367 if (last_launch_attempt_.is_null() || | 370 if (last_launch_attempt_.is_null() || |
368 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( | 371 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( |
369 kClickSuppressionInMS) < base::Time::Now()) { | 372 kClickSuppressionInMS) < base::Time::Now()) { |
370 last_launch_attempt_ = base::Time::Now(); | 373 last_launch_attempt_ = base::Time::Now(); |
371 return true; | 374 return true; |
372 } | 375 } |
373 return false; | 376 return false; |
374 } | 377 } |
OLD | NEW |