Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(740)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc

Issue 2894743002: Make launching apps from shelf more intuitive (Closed)
Patch Set: Affected by new revision, gclient sync and re-upload. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 RemoveShelfItem(id); 360 RemoveShelfItem(id);
361 else 361 else
362 SetItemStatus(id, status); 362 SetItemStatus(id, status);
363 } else if (status != ash::STATUS_CLOSED && !app_id.empty()) { 363 } else if (status != ash::STATUS_CLOSED && !app_id.empty()) {
364 InsertAppLauncherItem( 364 InsertAppLauncherItem(
365 AppShortcutLauncherItemController::Create(ash::ShelfID(app_id)), status, 365 AppShortcutLauncherItemController::Create(ash::ShelfID(app_id)), status,
366 model_->item_count(), ash::TYPE_APP); 366 model_->item_count(), ash::TYPE_APP);
367 } 367 }
368 } 368 }
369 369
370 void ChromeLauncherController::Launch(const ash::ShelfID& id, int event_flags) {
371 LaunchApp(id, ash::LAUNCH_FROM_UNKNOWN, event_flags);
372 }
373
374 void ChromeLauncherController::Close(const ash::ShelfID& id) { 370 void ChromeLauncherController::Close(const ash::ShelfID& id) {
375 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); 371 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id);
376 if (!delegate) 372 if (!delegate)
377 return; // May happen if menu closed. 373 return; // May happen if menu closed.
378 delegate->Close(); 374 delegate->Close();
379 } 375 }
380 376
381 bool ChromeLauncherController::IsOpen(const ash::ShelfID& id) { 377 bool ChromeLauncherController::IsOpen(const ash::ShelfID& id) {
382 const ash::ShelfItem* item = GetItem(id); 378 const ash::ShelfItem* item = GetItem(id);
383 return item && item->status != ash::STATUS_CLOSED; 379 return item && item->status != ash::STATUS_CLOSED;
384 } 380 }
385 381
386 bool ChromeLauncherController::IsPlatformApp(const ash::ShelfID& id) { 382 bool ChromeLauncherController::IsPlatformApp(const ash::ShelfID& id) {
387 const extensions::Extension* extension = 383 const extensions::Extension* extension =
388 GetExtensionForAppID(id.app_id, profile()); 384 GetExtensionForAppID(id.app_id, profile());
389 // An extension can be synced / updated at any time and therefore not be 385 // An extension can be synced / updated at any time and therefore not be
390 // available. 386 // available.
391 return extension ? extension->is_platform_app() : false; 387 return extension ? extension->is_platform_app() : false;
392 } 388 }
393 389
394 void ChromeLauncherController::LaunchApp(const ash::ShelfID& id, 390 void ChromeLauncherController::LaunchApp(const ash::ShelfID& id,
395 ash::ShelfLaunchSource source, 391 ash::ShelfLaunchSource source,
396 int event_flags) { 392 int event_flags,
397 launcher_controller_helper_->LaunchApp(id, source, event_flags); 393 int64_t display_id) {
394 launcher_controller_helper_->LaunchApp(id, source, event_flags, display_id);
398 } 395 }
399 396
400 void ChromeLauncherController::ActivateApp(const std::string& app_id, 397 void ChromeLauncherController::ActivateApp(const std::string& app_id,
401 ash::ShelfLaunchSource source, 398 ash::ShelfLaunchSource source,
402 int event_flags) { 399 int event_flags) {
403 // If there is an existing delegate for this app, select it. 400 // If there is an existing delegate for this app, select it.
404 const ash::ShelfID shelf_id(app_id); 401 const ash::ShelfID shelf_id(app_id);
405 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(shelf_id); 402 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(shelf_id);
406 if (delegate) { 403 if (delegate) {
407 SelectItemWithSource(delegate, source); 404 SelectItemWithSource(delegate, source);
408 return; 405 return;
409 } 406 }
410 407
411 // Create a temporary delegate to see if there are running app instances. 408 // Create a temporary delegate to see if there are running app instances.
412 std::unique_ptr<AppShortcutLauncherItemController> item_delegate = 409 std::unique_ptr<AppShortcutLauncherItemController> item_delegate =
413 AppShortcutLauncherItemController::Create(shelf_id); 410 AppShortcutLauncherItemController::Create(shelf_id);
414 if (!item_delegate->GetRunningApplications().empty()) 411 if (!item_delegate->GetRunningApplications().empty())
415 SelectItemWithSource(item_delegate.get(), source); 412 SelectItemWithSource(item_delegate.get(), source);
416 else 413 else
417 LaunchApp(shelf_id, source, event_flags); 414 LaunchApp(shelf_id, source, event_flags, display::kInvalidDisplayId);
418 } 415 }
419 416
420 void ChromeLauncherController::SetLauncherItemImage( 417 void ChromeLauncherController::SetLauncherItemImage(
421 const ash::ShelfID& shelf_id, 418 const ash::ShelfID& shelf_id,
422 const gfx::ImageSkia& image) { 419 const gfx::ImageSkia& image) {
423 const ash::ShelfItem* item = GetItem(shelf_id); 420 const ash::ShelfItem* item = GetItem(shelf_id);
424 if (item) { 421 if (item) {
425 ash::ShelfItem new_item = *item; 422 ash::ShelfItem new_item = *item;
426 new_item.image = image; 423 new_item.image = image;
427 model_->Set(model_->ItemIndexByID(shelf_id), new_item); 424 model_->Set(model_->ItemIndexByID(shelf_id), new_item);
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); 1370 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE);
1374 1371
1375 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); 1372 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST);
1376 DCHECK_GE(app_list_index, 0); 1373 DCHECK_GE(app_list_index, 0);
1377 ash::ShelfItem item = model_->items()[app_list_index]; 1374 ash::ShelfItem item = model_->items()[app_list_index];
1378 if (item.title != title) { 1375 if (item.title != title) {
1379 item.title = title; 1376 item.title = title;
1380 model_->Set(app_list_index, item); 1377 model_->Set(app_list_index, item);
1381 } 1378 }
1382 } 1379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698