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

Unified Diff: chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc

Issue 10534142: Add support for pinning platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed review issue. Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc
diff --git a/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc
index 436c217e4564d7eabf7307472af6f2a47ad3832e..1f960d34b6d11e8c87951bcd5a0fc3557d0f308e 100644
--- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc
@@ -191,29 +191,60 @@ void ChromeLauncherController::LauncherItemClosed(ash::LauncherID id) {
void ChromeLauncherController::Unpin(ash::LauncherID id) {
DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end());
DCHECK(!id_to_item_map_[id].controller);
- LauncherItemClosed(id);
+
+ if (ShellWindowRegistry::Get(profile_)->GetShellWindowsForApp(
+ id_to_item_map_[id].app_id).size() > 0) {
+ int index = model_->ItemIndexByID(id);
+ ash::LauncherItem item = model_->items()[index];
+ item.type = ash::TYPE_PLATFORM_APP;
+ model_->Set(index, item);
+ } else {
+ LauncherItemClosed(id);
+ }
if (CanPin())
PersistPinnedState();
}
-bool ChromeLauncherController::IsPinned(ash::LauncherID id) {
+void ChromeLauncherController::Pin(ash::LauncherID id) {
DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end());
- return id_to_item_map_[id].is_pinned();
+ DCHECK(!id_to_item_map_[id].controller);
+
+ int index = model_->ItemIndexByID(id);
+ ash::LauncherItem item = model_->items()[index];
+
+ if (item.type != ash::TYPE_PLATFORM_APP)
+ return;
+
+ item.type = ash::TYPE_APP_SHORTCUT;
+ model_->Set(index, item);
+
+ if (CanPin())
+ PersistPinnedState();
+}
+
+bool ChromeLauncherController::IsPinned(ash::LauncherID id) {
+ int index = model_->ItemIndexByID(id);
+ ash::LauncherItemType type = model_->items()[index].type;
+ return type == ash::TYPE_APP_SHORTCUT;
}
void ChromeLauncherController::TogglePinned(ash::LauncherID id) {
if (id_to_item_map_.find(id) == id_to_item_map_.end())
return; // May happen if item closed with menu open.
- // Only currently support unpinning.
if (IsPinned(id))
Unpin(id);
+ else
+ Pin(id);
}
bool ChromeLauncherController::IsPinnable(ash::LauncherID id) const {
int index = model_->ItemIndexByID(id);
- return (index != -1 &&
- model_->items()[index].type == ash::TYPE_APP_SHORTCUT &&
+ if (index == -1)
+ return false;
+
+ ash::LauncherItemType type = model_->items()[index].type;
+ return ((type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_PLATFORM_APP) &&
CanPin());
}

Powered by Google App Engine
This is Rietveld 408576698