Apps shouldn't disappear from pinned list after update

If pinned app is unloaded, put it to pending_pinned_apps_ list and pin it again when it is loaded again.

BUG=123293
TEST=manual


Review URL: http://codereview.chromium.org/10170029

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134788 0039d316-1c4b-4281-b951-d872f2087c98
parent cd838056
...@@ -106,6 +106,9 @@ ChromeLauncherDelegate::ChromeLauncherDelegate(Profile* profile, ...@@ -106,6 +106,9 @@ ChromeLauncherDelegate::ChromeLauncherDelegate(Profile* profile,
registrar_.Add(this, registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_UNLOADED, chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(profile_)); content::Source<Profile>(profile_));
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
content::Source<Profile>(profile_));
} }
ChromeLauncherDelegate::~ChromeLauncherDelegate() { ChromeLauncherDelegate::~ChromeLauncherDelegate() {
...@@ -155,7 +158,7 @@ void ChromeLauncherDelegate::Init() { ...@@ -155,7 +158,7 @@ void ChromeLauncherDelegate::Init() {
Item pending_item; Item pending_item;
pending_item.item_type = TYPE_APP; pending_item.item_type = TYPE_APP;
pending_item.app_id = app_id; pending_item.app_id = app_id;
pending_pinned_apps_.push(pending_item); pending_pinned_apps_.push_back(pending_item);
} }
} }
} }
...@@ -541,7 +544,26 @@ void ChromeLauncherDelegate::Observe( ...@@ -541,7 +544,26 @@ void ChromeLauncherDelegate::Observe(
case chrome::NOTIFICATION_EXTENSION_UNLOADED: { case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
const Extension* extension = const Extension* extension =
content::Details<UnloadedExtensionInfo>(details)->extension; content::Details<UnloadedExtensionInfo>(details)->extension;
UnpinAppsWithID(extension->id()); if (IsAppPinned(extension->id())) {
// TODO(dpolukhin): also we need to remember index of the app to show
// it on the same place when it gets loaded again.
Item pending_item;
pending_item.item_type = TYPE_APP;
pending_item.app_id = extension->id();
pending_pinned_apps_.push_back(pending_item);
UnpinAppsWithID(extension->id());
}
break;
}
case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
std::string id = *content::Details<const std::string>(details).ptr();
for (std::deque<Item>::iterator it = pending_pinned_apps_.begin();
it != pending_pinned_apps_.end(); ++it) {
if (it->app_id == id) {
pending_pinned_apps_.erase(it);
break;
}
}
break; break;
} }
default: default:
...@@ -586,6 +608,6 @@ void ChromeLauncherDelegate::ProcessPendingPinnedApps() { ...@@ -586,6 +608,6 @@ void ChromeLauncherDelegate::ProcessPendingPinnedApps() {
return; return;
PinAppWithID(item.app_id); PinAppWithID(item.app_id);
pending_pinned_apps_.pop(); pending_pinned_apps_.pop_front();
} }
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#pragma once #pragma once
#include <map> #include <map>
#include <queue> #include <deque>
#include <string> #include <string>
#include "ash/launcher/launcher_delegate.h" #include "ash/launcher/launcher_delegate.h"
...@@ -237,7 +237,7 @@ class ChromeLauncherDelegate : public ash::LauncherDelegate, ...@@ -237,7 +237,7 @@ class ChromeLauncherDelegate : public ash::LauncherDelegate,
// not ready. Keep them in this list and create pinned item when the apps // not ready. Keep them in this list and create pinned item when the apps
// are installed (via sync or external extension provider.) The order of the // are installed (via sync or external extension provider.) The order of the
// list reflects the original order in pinned app list. // list reflects the original order in pinned app list.
std::queue<Item> pending_pinned_apps_; std::deque<Item> pending_pinned_apps_;
content::NotificationRegistrar registrar_; content::NotificationRegistrar registrar_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment