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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
index 6315a201e8cccbbbbcb3d26a717f93fd5371281e..bd928062a6e53fa35f01f99f5401876fec331e21 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
@@ -354,7 +354,9 @@ void ChromeLauncherControllerImpl::CloseLauncherItem(ash::ShelfID id) {
CHECK(iter != id_to_item_controller_map_.end());
SetItemStatus(id, ash::STATUS_CLOSED);
std::string app_id = iter->second->app_id();
- iter->second = AppShortcutLauncherItemController::Create(app_id, this);
+ std::string launch_id = iter->second->launch_id();
+ iter->second =
+ AppShortcutLauncherItemController::Create(app_id, launch_id, this);
iter->second->set_shelf_id(id);
// Existing controller is destroyed and replaced by registering again.
SetShelfItemDelegate(id, iter->second);
@@ -506,7 +508,7 @@ void ChromeLauncherControllerImpl::ActivateApp(const std::string& app_id,
// Create a temporary application launcher item and use it to see if there are
// running instances.
std::unique_ptr<AppShortcutLauncherItemController> app_controller(
- AppShortcutLauncherItemController::Create(app_id, this));
+ AppShortcutLauncherItemController::Create(app_id, "", this));
if (!app_controller->GetRunningApplications().empty())
app_controller->Activate(source);
else
@@ -901,13 +903,21 @@ void ChromeLauncherControllerImpl::OnShelfVisibilityStateChanged(
ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppID(
const std::string& app_id) {
- for (IDToItemControllerMap::const_iterator i =
- id_to_item_controller_map_.begin();
- i != id_to_item_controller_map_.end(); ++i) {
- if (i->second->type() == LauncherItemController::TYPE_APP_PANEL)
+ // Get shelf id for app_id and empty launch_id.
+ return GetShelfIDForAppIDAndLaunchID(app_id, "");
+}
+
+ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppIDAndLaunchID(
+ const std::string& app_id,
+ const std::string& launch_id) {
+ for (const auto& id_to_item_controller_pair : id_to_item_controller_map_) {
+ if (id_to_item_controller_pair.second->type() ==
+ LauncherItemController::TYPE_APP_PANEL)
continue; // Don't include panels
- if (i->second->app_id() == app_id)
- return i->first;
+ if (id_to_item_controller_pair.second->app_id() == app_id &&
+ id_to_item_controller_pair.second->launch_id() == launch_id) {
+ return id_to_item_controller_pair.first;
+ }
}
return 0;
}
@@ -1071,7 +1081,7 @@ ChromeLauncherControllerImpl::CreateAppShortcutLauncherItemWithType(
int index,
ash::ShelfItemType shelf_item_type) {
AppShortcutLauncherItemController* controller =
- AppShortcutLauncherItemController::Create(app_id, this);
+ AppShortcutLauncherItemController::Create(app_id, "", this);
ash::ShelfID shelf_id = InsertAppLauncherItem(
controller, app_id, ash::STATUS_CLOSED, index, shelf_item_type);
return shelf_id;

Powered by Google App Engine
This is Rietveld 408576698