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

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: Add comment 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 8f2571e6972054c6cc5c64b678dfeb141d8a2a9d..44f8d372e22a9437283e85f34e462bc45ef1214e 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);
sky 2012/06/13 21:20:53 Are we picking up the type right for these when th
DaveMoore 2012/06/13 22:30:16 I believe so. We only persist shortcuts, not the a
+
+ 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