| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const std::string& app_id, | 79 const std::string& app_id, |
| 80 const std::string& launch_id, | 80 const std::string& launch_id, |
| 81 ChromeLauncherController* controller) | 81 ChromeLauncherController* controller) |
| 82 : LauncherItemController(TYPE_SHORTCUT, app_id, launch_id, controller), | 82 : LauncherItemController(TYPE_SHORTCUT, app_id, launch_id, controller), |
| 83 chrome_launcher_controller_(controller), | 83 chrome_launcher_controller_(controller), |
| 84 app_id_(app_id), | 84 app_id_(app_id), |
| 85 launch_id_(launch_id) { | 85 launch_id_(launch_id) { |
| 86 // To detect V1 applications we use their domain and match them against the | 86 // To detect V1 applications we use their domain and match them against the |
| 87 // used URL. This will also work with applications like Google Drive. | 87 // used URL. This will also work with applications like Google Drive. |
| 88 const Extension* extension = | 88 const Extension* extension = |
| 89 GetExtensionForAppID(app_id, controller->GetProfile()); | 89 GetExtensionForAppID(app_id, controller->profile()); |
| 90 // Some unit tests have no real extension. | 90 // Some unit tests have no real extension. |
| 91 if (extension) { | 91 if (extension) { |
| 92 set_refocus_url(GURL( | 92 set_refocus_url(GURL( |
| 93 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*")); | 93 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*")); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 AppShortcutLauncherItemController::~AppShortcutLauncherItemController() { | 97 AppShortcutLauncherItemController::~AppShortcutLauncherItemController() { |
| 98 } | 98 } |
| 99 | 99 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); | 180 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); |
| 181 refocus_pattern.SetMatchAllURLs(true); | 181 refocus_pattern.SetMatchAllURLs(true); |
| 182 | 182 |
| 183 if (!refocus_url_.is_empty()) { | 183 if (!refocus_url_.is_empty()) { |
| 184 refocus_pattern.SetMatchAllURLs(false); | 184 refocus_pattern.SetMatchAllURLs(false); |
| 185 refocus_pattern.Parse(refocus_url_.spec()); | 185 refocus_pattern.Parse(refocus_url_.spec()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 const Extension* extension = | 188 const Extension* extension = |
| 189 GetExtensionForAppID(app_id(), launcher_controller()->GetProfile()); | 189 GetExtensionForAppID(app_id(), launcher_controller()->profile()); |
| 190 | 190 |
| 191 // It is possible to come here While an extension gets loaded. | 191 // It is possible to come here While an extension gets loaded. |
| 192 if (!extension) | 192 if (!extension) |
| 193 return items; | 193 return items; |
| 194 | 194 |
| 195 for (auto* browser : *BrowserList::GetInstance()) { | 195 for (auto* browser : *BrowserList::GetInstance()) { |
| 196 if (!IsBrowserFromActiveUser(browser)) | 196 if (!IsBrowserFromActiveUser(browser)) |
| 197 continue; | 197 continue; |
| 198 TabStripModel* tab_strip = browser->tab_strip_model(); | 198 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 199 for (int index = 0; index < tab_strip->count(); index++) { | 199 for (int index = 0; index < tab_strip->count(); index++) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 211 // In case of a keyboard event, we were called by a hotkey. In that case we | 211 // In case of a keyboard event, we were called by a hotkey. In that case we |
| 212 // activate the next item in line if an item of our list is already active. | 212 // activate the next item in line if an item of our list is already active. |
| 213 if (event.type() == ui::ET_KEY_RELEASED) { | 213 if (event.type() == ui::ET_KEY_RELEASED) { |
| 214 if (AdvanceToNextApp()) | 214 if (AdvanceToNextApp()) |
| 215 return kExistingWindowActivated; | 215 return kExistingWindowActivated; |
| 216 } | 216 } |
| 217 return Activate(ash::LAUNCH_FROM_UNKNOWN); | 217 return Activate(ash::LAUNCH_FROM_UNKNOWN); |
| 218 } | 218 } |
| 219 | 219 |
| 220 base::string16 AppShortcutLauncherItemController::GetTitle() { | 220 base::string16 AppShortcutLauncherItemController::GetTitle() { |
| 221 return LauncherControllerHelper::GetAppTitle( | 221 return LauncherControllerHelper::GetAppTitle(launcher_controller()->profile(), |
| 222 launcher_controller()->GetProfile(), app_id()); | 222 app_id()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 ash::ShelfMenuModel* AppShortcutLauncherItemController::CreateApplicationMenu( | 225 ash::ShelfMenuModel* AppShortcutLauncherItemController::CreateApplicationMenu( |
| 226 int event_flags) { | 226 int event_flags) { |
| 227 return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags)); | 227 return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 bool AppShortcutLauncherItemController::IsDraggable() { | 230 bool AppShortcutLauncherItemController::IsDraggable() { |
| 231 return true; | 231 return true; |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool AppShortcutLauncherItemController::CanPin() const { | 234 bool AppShortcutLauncherItemController::CanPin() const { |
| 235 return GetPinnableForAppID(app_id(), launcher_controller()->GetProfile()) == | 235 return GetPinnableForAppID(app_id(), launcher_controller()->profile()) == |
| 236 AppListControllerDelegate::PIN_EDITABLE; | 236 AppListControllerDelegate::PIN_EDITABLE; |
| 237 } | 237 } |
| 238 | 238 |
| 239 bool AppShortcutLauncherItemController::ShouldShowTooltip() { | 239 bool AppShortcutLauncherItemController::ShouldShowTooltip() { |
| 240 return true; | 240 return true; |
| 241 } | 241 } |
| 242 | 242 |
| 243 content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() { | 243 content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() { |
| 244 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); | 244 URLPattern refocus_pattern(URLPattern::SCHEME_ALL); |
| 245 refocus_pattern.SetMatchAllURLs(true); | 245 refocus_pattern.SetMatchAllURLs(true); |
| 246 | 246 |
| 247 if (!refocus_url_.is_empty()) { | 247 if (!refocus_url_.is_empty()) { |
| 248 refocus_pattern.SetMatchAllURLs(false); | 248 refocus_pattern.SetMatchAllURLs(false); |
| 249 refocus_pattern.Parse(refocus_url_.spec()); | 249 refocus_pattern.Parse(refocus_url_.spec()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 const Extension* extension = | 252 const Extension* extension = |
| 253 GetExtensionForAppID(app_id(), launcher_controller()->GetProfile()); | 253 GetExtensionForAppID(app_id(), launcher_controller()->profile()); |
| 254 | 254 |
| 255 // We may get here while the extension is loading (and NULL). | 255 // We may get here while the extension is loading (and NULL). |
| 256 if (!extension) | 256 if (!extension) |
| 257 return NULL; | 257 return NULL; |
| 258 | 258 |
| 259 const BrowserList* browser_list = BrowserList::GetInstance(); | 259 const BrowserList* browser_list = BrowserList::GetInstance(); |
| 260 for (BrowserList::const_reverse_iterator it = | 260 for (BrowserList::const_reverse_iterator it = |
| 261 browser_list->begin_last_active(); | 261 browser_list->begin_last_active(); |
| 262 it != browser_list->end_last_active(); ++it) { | 262 it != browser_list->end_last_active(); ++it) { |
| 263 Browser* browser = *it; | 263 Browser* browser = *it; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 366 } |
| 367 return true; | 367 return true; |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 return false; | 371 return false; |
| 372 } | 372 } |
| 373 | 373 |
| 374 bool AppShortcutLauncherItemController::IsV2App() { | 374 bool AppShortcutLauncherItemController::IsV2App() { |
| 375 const Extension* extension = | 375 const Extension* extension = |
| 376 GetExtensionForAppID(app_id(), launcher_controller()->GetProfile()); | 376 GetExtensionForAppID(app_id(), launcher_controller()->profile()); |
| 377 return extension && extension->is_platform_app(); | 377 return extension && extension->is_platform_app(); |
| 378 } | 378 } |
| 379 | 379 |
| 380 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { | 380 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { |
| 381 if (last_launch_attempt_.is_null() || | 381 if (last_launch_attempt_.is_null() || |
| 382 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( | 382 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( |
| 383 kClickSuppressionInMS) < base::Time::Now()) { | 383 kClickSuppressionInMS) < base::Time::Now()) { |
| 384 last_launch_attempt_ = base::Time::Now(); | 384 last_launch_attempt_ = base::Time::Now(); |
| 385 return true; | 385 return true; |
| 386 } | 386 } |
| 387 return false; | 387 return false; |
| 388 } | 388 } |
| OLD | NEW |