| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include "ash/multi_profile_uma.h" | 7 #include "ash/multi_profile_uma.h" |
| 8 #include "ash/public/cpp/shelf_item.h" | 8 #include "ash/public/cpp/shelf_item.h" |
| 9 #include "ash/public/interfaces/constants.mojom.h" | 9 #include "ash/public/interfaces/constants.mojom.h" |
| 10 #include "ash/resources/grit/ash_resources.h" | 10 #include "ash/resources/grit/ash_resources.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 RemoveShelfItem(id); | 361 RemoveShelfItem(id); |
| 362 else | 362 else |
| 363 SetItemStatus(id, status); | 363 SetItemStatus(id, status); |
| 364 } else if (status != ash::STATUS_CLOSED && !app_id.empty()) { | 364 } else if (status != ash::STATUS_CLOSED && !app_id.empty()) { |
| 365 InsertAppLauncherItem( | 365 InsertAppLauncherItem( |
| 366 AppShortcutLauncherItemController::Create(ash::ShelfID(app_id)), status, | 366 AppShortcutLauncherItemController::Create(ash::ShelfID(app_id)), status, |
| 367 model_->item_count(), ash::TYPE_APP); | 367 model_->item_count(), ash::TYPE_APP); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 void ChromeLauncherController::Launch(const ash::ShelfID& id, int event_flags) { | |
| 372 LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, event_flags); | |
| 373 } | |
| 374 | |
| 375 void ChromeLauncherController::Close(const ash::ShelfID& id) { | 371 void ChromeLauncherController::Close(const ash::ShelfID& id) { |
| 376 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); | 372 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); |
| 377 if (!delegate) | 373 if (!delegate) |
| 378 return; // May happen if menu closed. | 374 return; // May happen if menu closed. |
| 379 delegate->Close(); | 375 delegate->Close(); |
| 380 } | 376 } |
| 381 | 377 |
| 382 bool ChromeLauncherController::IsOpen(const ash::ShelfID& id) { | 378 bool ChromeLauncherController::IsOpen(const ash::ShelfID& id) { |
| 383 const ash::ShelfItem* item = GetItem(id); | 379 const ash::ShelfItem* item = GetItem(id); |
| 384 return item && item->status != ash::STATUS_CLOSED; | 380 return item && item->status != ash::STATUS_CLOSED; |
| 385 } | 381 } |
| 386 | 382 |
| 387 bool ChromeLauncherController::IsPlatformApp(const ash::ShelfID& id) { | 383 bool ChromeLauncherController::IsPlatformApp(const ash::ShelfID& id) { |
| 388 const extensions::Extension* extension = | 384 const extensions::Extension* extension = |
| 389 GetExtensionForAppID(id.app_id, profile()); | 385 GetExtensionForAppID(id.app_id, profile()); |
| 390 // An extension can be synced / updated at any time and therefore not be | 386 // An extension can be synced / updated at any time and therefore not be |
| 391 // available. | 387 // available. |
| 392 return extension ? extension->is_platform_app() : false; | 388 return extension ? extension->is_platform_app() : false; |
| 393 } | 389 } |
| 394 | 390 |
| 395 void ChromeLauncherController::LaunchApp(const ash::ShelfID& id, | 391 void ChromeLauncherController::LaunchApp(const ash::ShelfID& id, |
| 396 ash::ShelfLaunchSource source, | 392 ash::ShelfLaunchSource source, |
| 397 int event_flags) { | 393 int event_flags, |
| 398 launcher_controller_helper_->LaunchApp(id, source, event_flags); | 394 int64_t display_id) { |
| 395 launcher_controller_helper_->LaunchApp(id, source, event_flags, display_id); |
| 399 } | 396 } |
| 400 | 397 |
| 401 void ChromeLauncherController::ActivateApp(const std::string& app_id, | 398 void ChromeLauncherController::ActivateApp(const std::string& app_id, |
| 402 ash::ShelfLaunchSource source, | 399 ash::ShelfLaunchSource source, |
| 403 int event_flags) { | 400 int event_flags) { |
| 404 // If there is an existing delegate for this app, select it. | 401 // If there is an existing delegate for this app, select it. |
| 405 const ash::ShelfID shelf_id(app_id); | 402 const ash::ShelfID shelf_id(app_id); |
| 406 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(shelf_id); | 403 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(shelf_id); |
| 407 if (delegate) { | 404 if (delegate) { |
| 408 SelectItemWithSource(delegate, source); | 405 SelectItemWithSource(delegate, source); |
| 409 return; | 406 return; |
| 410 } | 407 } |
| 411 | 408 |
| 412 // Create a temporary delegate to see if there are running app instances. | 409 // Create a temporary delegate to see if there are running app instances. |
| 413 std::unique_ptr<AppShortcutLauncherItemController> item_delegate = | 410 std::unique_ptr<AppShortcutLauncherItemController> item_delegate = |
| 414 AppShortcutLauncherItemController::Create(shelf_id); | 411 AppShortcutLauncherItemController::Create(shelf_id); |
| 415 if (!item_delegate->GetRunningApplications().empty()) | 412 if (!item_delegate->GetRunningApplications().empty()) |
| 416 SelectItemWithSource(item_delegate.get(), source); | 413 SelectItemWithSource(item_delegate.get(), source); |
| 417 else | 414 else |
| 418 LaunchApp(shelf_id, source, event_flags); | 415 LaunchApp(shelf_id, source, event_flags, display::kInvalidDisplayId); |
| 419 } | 416 } |
| 420 | 417 |
| 421 void ChromeLauncherController::SetLauncherItemImage( | 418 void ChromeLauncherController::SetLauncherItemImage( |
| 422 const ash::ShelfID& shelf_id, | 419 const ash::ShelfID& shelf_id, |
| 423 const gfx::ImageSkia& image) { | 420 const gfx::ImageSkia& image) { |
| 424 const ash::ShelfItem* item = GetItem(shelf_id); | 421 const ash::ShelfItem* item = GetItem(shelf_id); |
| 425 if (item) { | 422 if (item) { |
| 426 ash::ShelfItem new_item = *item; | 423 ash::ShelfItem new_item = *item; |
| 427 new_item.image = image; | 424 new_item.image = image; |
| 428 model_->Set(model_->ItemIndexByID(shelf_id), new_item); | 425 model_->Set(model_->ItemIndexByID(shelf_id), new_item); |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); | 1372 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); |
| 1376 | 1373 |
| 1377 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); | 1374 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); |
| 1378 DCHECK_GE(app_list_index, 0); | 1375 DCHECK_GE(app_list_index, 0); |
| 1379 ash::ShelfItem item = model_->items()[app_list_index]; | 1376 ash::ShelfItem item = model_->items()[app_list_index]; |
| 1380 if (item.title != title) { | 1377 if (item.title != title) { |
| 1381 item.title = title; | 1378 item.title = title; |
| 1382 model_->Set(app_list_index, item); | 1379 model_->Set(app_list_index, item); |
| 1383 } | 1380 } |
| 1384 } | 1381 } |
| OLD | NEW |