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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Some unit tests have no real extension. | 89 // Some unit tests have no real extension. |
90 if (extension) { | 90 if (extension) { |
91 set_refocus_url(GURL( | 91 set_refocus_url(GURL( |
92 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*")); | 92 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*")); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 AppShortcutLauncherItemController::~AppShortcutLauncherItemController() { | 96 AppShortcutLauncherItemController::~AppShortcutLauncherItemController() { |
97 } | 97 } |
98 | 98 |
99 bool AppShortcutLauncherItemController::IsVisible() const { | |
100 // Return true if any browser window associated with the app is visible. | |
101 std::vector<content::WebContents*> content = | |
102 chrome_launcher_controller_->GetV1ApplicationsFromAppId(app_id()); | |
103 for (size_t i = 0; i < content.size(); i++) { | |
104 Browser* browser = chrome::FindBrowserWithWebContents(content[i]); | |
105 if (browser && browser->window()->GetNativeWindow()->IsVisible()) | |
106 return true; | |
107 } | |
108 return false; | |
109 } | |
110 | |
111 void AppShortcutLauncherItemController::Launch(ash::LaunchSource source, | 99 void AppShortcutLauncherItemController::Launch(ash::LaunchSource source, |
112 int event_flags) { | 100 int event_flags) { |
113 // Launching an app replaces shortcut item controller to app controller. As | 101 // Launching an app replaces shortcut item controller to app controller. As |
114 // result app_id_, launch_id_ are deleted during this call. Use local copies | 102 // result app_id_, launch_id_ are deleted during this call. Use local copies |
115 // to prevent crash condition. | 103 // to prevent crash condition. |
116 launcher_controller()->LaunchAppWithLaunchId( | 104 launcher_controller()->LaunchAppWithLaunchId( |
117 std::string(app_id()), std::string(launch_id()), source, event_flags); | 105 std::string(app_id()), std::string(launch_id()), source, event_flags); |
118 } | 106 } |
119 | 107 |
120 ash::ShelfItemDelegate::PerformedAction | 108 ash::ShelfItemDelegate::PerformedAction |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 350 |
363 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { | 351 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { |
364 if (last_launch_attempt_.is_null() || | 352 if (last_launch_attempt_.is_null() || |
365 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( | 353 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( |
366 kClickSuppressionInMS) < base::Time::Now()) { | 354 kClickSuppressionInMS) < base::Time::Now()) { |
367 last_launch_attempt_ = base::Time::Now(); | 355 last_launch_attempt_ = base::Time::Now(); |
368 return true; | 356 return true; |
369 } | 357 } |
370 return false; | 358 return false; |
371 } | 359 } |
OLD | NEW |