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

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

Issue 2290603002: Enhance chrome.app.window API for shelf integration with pinning support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: LauncherItemController Unit Tests Fix after Rebase Created 4 years, 3 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_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 347 }
348 348
349 void ChromeLauncherControllerImpl::CloseLauncherItem(ash::ShelfID id) { 349 void ChromeLauncherControllerImpl::CloseLauncherItem(ash::ShelfID id) {
350 CHECK(id); 350 CHECK(id);
351 if (IsPinned(id)) { 351 if (IsPinned(id)) {
352 // Create a new shortcut controller. 352 // Create a new shortcut controller.
353 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); 353 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id);
354 CHECK(iter != id_to_item_controller_map_.end()); 354 CHECK(iter != id_to_item_controller_map_.end());
355 SetItemStatus(id, ash::STATUS_CLOSED); 355 SetItemStatus(id, ash::STATUS_CLOSED);
356 std::string app_id = iter->second->app_id(); 356 std::string app_id = iter->second->app_id();
357 iter->second = AppShortcutLauncherItemController::Create(app_id, this); 357 std::string launch_id = iter->second->launch_id();
358 iter->second =
359 AppShortcutLauncherItemController::Create(app_id, launch_id, this);
358 iter->second->set_shelf_id(id); 360 iter->second->set_shelf_id(id);
359 // Existing controller is destroyed and replaced by registering again. 361 // Existing controller is destroyed and replaced by registering again.
360 SetShelfItemDelegate(id, iter->second); 362 SetShelfItemDelegate(id, iter->second);
361 } else { 363 } else {
362 LauncherItemClosed(id); 364 LauncherItemClosed(id);
363 } 365 }
364 } 366 }
365 367
366 void ChromeLauncherControllerImpl::Pin(ash::ShelfID id) { 368 void ChromeLauncherControllerImpl::Pin(ash::ShelfID id) {
367 DCHECK(HasShelfIDToAppIDMapping(id)); 369 DCHECK(HasShelfIDToAppIDMapping(id));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 ash::ShelfID id = GetShelfIDForAppID(app_id); 501 ash::ShelfID id = GetShelfIDForAppID(app_id);
500 if (id) { 502 if (id) {
501 LauncherItemController* controller = GetLauncherItemController(id); 503 LauncherItemController* controller = GetLauncherItemController(id);
502 controller->Activate(source); 504 controller->Activate(source);
503 return; 505 return;
504 } 506 }
505 507
506 // Create a temporary application launcher item and use it to see if there are 508 // Create a temporary application launcher item and use it to see if there are
507 // running instances. 509 // running instances.
508 std::unique_ptr<AppShortcutLauncherItemController> app_controller( 510 std::unique_ptr<AppShortcutLauncherItemController> app_controller(
509 AppShortcutLauncherItemController::Create(app_id, this)); 511 AppShortcutLauncherItemController::Create(app_id, "", this));
510 if (!app_controller->GetRunningApplications().empty()) 512 if (!app_controller->GetRunningApplications().empty())
511 app_controller->Activate(source); 513 app_controller->Activate(source);
512 else 514 else
513 LaunchApp(app_id, source, event_flags); 515 LaunchApp(app_id, source, event_flags);
514 } 516 }
515 517
516 extensions::LaunchType ChromeLauncherControllerImpl::GetLaunchType( 518 extensions::LaunchType ChromeLauncherControllerImpl::GetLaunchType(
517 ash::ShelfID id) { 519 ash::ShelfID id) {
518 const Extension* extension = 520 const Extension* extension =
519 GetExtensionForAppID(GetAppIDForShelfID(id), profile_); 521 GetExtensionForAppID(GetAppIDForShelfID(id), profile_);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } 896 }
895 897
896 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged( 898 void ChromeLauncherControllerImpl::OnShelfAutoHideStateChanged(
897 ash::WmShelf* shelf) {} 899 ash::WmShelf* shelf) {}
898 900
899 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged( 901 void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged(
900 ash::WmShelf* shelf) {} 902 ash::WmShelf* shelf) {}
901 903
902 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID( 904 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID(
903 const std::string& app_id) { 905 const std::string& app_id) {
904 for (IDToItemControllerMap::const_iterator i = 906 // Get shelf id for app_id and empty launch_id.
905 id_to_item_controller_map_.begin(); 907 return GetShelfIDForAppIDAndLaunchID(app_id, "");
906 i != id_to_item_controller_map_.end(); ++i) { 908 }
907 if (i->second->type() == LauncherItemController::TYPE_APP_PANEL) 909
910 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppIDAndLaunchID(
911 const std::string& app_id,
912 const std::string& launch_id) {
913 for (const auto& id_to_item_controller_pair : id_to_item_controller_map_) {
914 if (id_to_item_controller_pair.second->type() ==
915 LauncherItemController::TYPE_APP_PANEL)
908 continue; // Don't include panels 916 continue; // Don't include panels
909 if (i->second->app_id() == app_id) 917 if (id_to_item_controller_pair.second->app_id() == app_id &&
910 return i->first; 918 id_to_item_controller_pair.second->launch_id() == launch_id) {
919 return id_to_item_controller_pair.first;
920 }
911 } 921 }
912 return 0; 922 return 0;
913 } 923 }
914 924
915 bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping( 925 bool ChromeLauncherControllerImpl::HasShelfIDToAppIDMapping(
916 ash::ShelfID id) const { 926 ash::ShelfID id) const {
917 return id_to_item_controller_map_.find(id) != 927 return id_to_item_controller_map_.find(id) !=
918 id_to_item_controller_map_.end(); 928 id_to_item_controller_map_.end();
919 } 929 }
920 930
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } 1074 }
1065 } 1075 }
1066 } 1076 }
1067 1077
1068 ash::ShelfID 1078 ash::ShelfID
1069 ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType( 1079 ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType(
1070 const std::string& app_id, 1080 const std::string& app_id,
1071 int index, 1081 int index,
1072 ash::ShelfItemType shelf_item_type) { 1082 ash::ShelfItemType shelf_item_type) {
1073 AppShortcutLauncherItemController* controller = 1083 AppShortcutLauncherItemController* controller =
1074 AppShortcutLauncherItemController::Create(app_id, this); 1084 AppShortcutLauncherItemController::Create(app_id, "", this);
1075 ash::ShelfID shelf_id = InsertAppLauncherItem( 1085 ash::ShelfID shelf_id = InsertAppLauncherItem(
1076 controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type); 1086 controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type);
1077 return shelf_id; 1087 return shelf_id;
1078 } 1088 }
1079 1089
1080 void ChromeLauncherControllerImpl::LauncherItemClosed(ash::ShelfID id) { 1090 void ChromeLauncherControllerImpl::LauncherItemClosed(ash::ShelfID id) {
1081 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); 1091 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id);
1082 CHECK(iter != id_to_item_controller_map_.end()); 1092 CHECK(iter != id_to_item_controller_map_.end());
1083 CHECK(iter->second); 1093 CHECK(iter->second);
1084 const std::string& app_id = iter->second->app_id(); 1094 const std::string& app_id = iter->second->app_id();
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 if (index == -1) 1708 if (index == -1)
1699 continue; 1709 continue;
1700 ash::ShelfItem item = model_->items()[index]; 1710 ash::ShelfItem item = model_->items()[index];
1701 item.image = image; 1711 item.image = image;
1702 if (arc_deferred_launcher_) 1712 if (arc_deferred_launcher_)
1703 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1713 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1704 model_->Set(index, item); 1714 model_->Set(index, item);
1705 // It's possible we're waiting on more than one item, so don't break. 1715 // It's possible we're waiting on more than one item, so don't break.
1706 } 1716 }
1707 } 1717 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698