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

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

Issue 10170029: Apps shouldn't disappear from pinned list after update (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/ash/launcher/chrome_launcher_delegate.h" 5 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h"
6 6
7 #include "ash/launcher/launcher_model.h" 7 #include "ash/launcher/launcher_model.h"
8 #include "ash/launcher/launcher_types.h" 8 #include "ash/launcher/launcher_types.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 instance_ = this; 99 instance_ = this;
100 model_->AddObserver(this); 100 model_->AddObserver(this);
101 app_icon_loader_.reset(new LauncherAppIconLoader(profile_, this)); 101 app_icon_loader_.reset(new LauncherAppIconLoader(profile_, this));
102 102
103 registrar_.Add(this, 103 registrar_.Add(this,
104 chrome::NOTIFICATION_EXTENSION_LOADED, 104 chrome::NOTIFICATION_EXTENSION_LOADED,
105 content::Source<Profile>(profile_)); 105 content::Source<Profile>(profile_));
106 registrar_.Add(this, 106 registrar_.Add(this,
107 chrome::NOTIFICATION_EXTENSION_UNLOADED, 107 chrome::NOTIFICATION_EXTENSION_UNLOADED,
108 content::Source<Profile>(profile_)); 108 content::Source<Profile>(profile_));
109 registrar_.Add(this,
110 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
111 content::Source<Profile>(profile_));
109 } 112 }
110 113
111 ChromeLauncherDelegate::~ChromeLauncherDelegate() { 114 ChromeLauncherDelegate::~ChromeLauncherDelegate() {
112 model_->RemoveObserver(this); 115 model_->RemoveObserver(this);
113 for (IDToItemMap::iterator i = id_to_item_map_.begin(); 116 for (IDToItemMap::iterator i = id_to_item_map_.begin();
114 i != id_to_item_map_.end(); ++i) { 117 i != id_to_item_map_.end(); ++i) {
115 model_->RemoveItemAt(model_->ItemIndexByID(i->first)); 118 model_->RemoveItemAt(model_->ItemIndexByID(i->first));
116 } 119 }
117 if (instance_ == this) 120 if (instance_ == this)
118 instance_ = NULL; 121 instance_ = NULL;
(...skipping 29 matching lines...) Expand all
148 DictionaryValue* app = NULL; 151 DictionaryValue* app = NULL;
149 if (pinned_apps->GetDictionary(i, &app)) { 152 if (pinned_apps->GetDictionary(i, &app)) {
150 std::string app_id; 153 std::string app_id;
151 if (app->GetString(kAppIDPath, &app_id)) { 154 if (app->GetString(kAppIDPath, &app_id)) {
152 if (app_icon_loader_->IsValidID(app_id)) { 155 if (app_icon_loader_->IsValidID(app_id)) {
153 CreateAppLauncherItem(NULL, app_id, ash::STATUS_CLOSED); 156 CreateAppLauncherItem(NULL, app_id, ash::STATUS_CLOSED);
154 } else { 157 } else {
155 Item pending_item; 158 Item pending_item;
156 pending_item.item_type = TYPE_APP; 159 pending_item.item_type = TYPE_APP;
157 pending_item.app_id = app_id; 160 pending_item.app_id = app_id;
158 pending_pinned_apps_.push(pending_item); 161 pending_pinned_apps_.push_back(pending_item);
159 } 162 }
160 } 163 }
161 } 164 }
162 } 165 }
163 // TODO(sky): update unit test so that this test isn't necessary. 166 // TODO(sky): update unit test so that this test isn't necessary.
164 if (ash::Shell::HasInstance()) { 167 if (ash::Shell::HasInstance()) {
165 std::string behavior_value( 168 std::string behavior_value(
166 profile_->GetPrefs()->GetString(prefs::kShelfAutoHideBehavior)); 169 profile_->GetPrefs()->GetString(prefs::kShelfAutoHideBehavior));
167 ash::ShelfAutoHideBehavior behavior = 170 ash::ShelfAutoHideBehavior behavior =
168 ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT; 171 ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 const content::NotificationSource& source, 537 const content::NotificationSource& source,
535 const content::NotificationDetails& details) { 538 const content::NotificationDetails& details) {
536 switch (type) { 539 switch (type) {
537 case chrome::NOTIFICATION_EXTENSION_LOADED: { 540 case chrome::NOTIFICATION_EXTENSION_LOADED: {
538 ProcessPendingPinnedApps(); 541 ProcessPendingPinnedApps();
539 break; 542 break;
540 } 543 }
541 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 544 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
542 const Extension* extension = 545 const Extension* extension =
543 content::Details<UnloadedExtensionInfo>(details)->extension; 546 content::Details<UnloadedExtensionInfo>(details)->extension;
547 if (IsAppPinned(extension->id())) {
548 // TODO(dpolukhin): also we need to remember index of the app to show
549 // it on the same place when it gets loaded again.
550 Item pending_item;
551 pending_item.item_type = TYPE_APP;
552 pending_item.app_id = extension->id();
553 pending_pinned_apps_.push_back(pending_item);
554 }
544 UnpinAppsWithID(extension->id()); 555 UnpinAppsWithID(extension->id());
xiyuan 2012/04/27 15:53:18 nit: We could move this into the above "if" since
Dmitry Polukhin 2012/04/27 18:17:04 Done.
545 break; 556 break;
546 } 557 }
558 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
559 std::string id = *content::Details<const std::string>(details).ptr();
560 for (std::deque<Item>::iterator it = pending_pinned_apps_.begin();
561 it != pending_pinned_apps_.end(); ++it) {
562 if (it->app_id == id) {
563 pending_pinned_apps_.erase(it);
564 break;
565 }
566 }
567 break;
568 }
547 default: 569 default:
548 NOTREACHED() << "Unexpected notification type=" << type; 570 NOTREACHED() << "Unexpected notification type=" << type;
549 } 571 }
550 } 572 }
551 573
552 void ChromeLauncherDelegate::PersistPinnedState() { 574 void ChromeLauncherDelegate::PersistPinnedState() {
553 // Set kUseDefaultPinnedApps to false and use pinned apps list from prefs 575 // Set kUseDefaultPinnedApps to false and use pinned apps list from prefs
554 // from now on. 576 // from now on.
555 profile_->GetPrefs()->SetBoolean(prefs::kUseDefaultPinnedApps, false); 577 profile_->GetPrefs()->SetBoolean(prefs::kUseDefaultPinnedApps, false);
556 578
(...skipping 22 matching lines...) Expand all
579 } 601 }
580 602
581 void ChromeLauncherDelegate::ProcessPendingPinnedApps() { 603 void ChromeLauncherDelegate::ProcessPendingPinnedApps() {
582 while (!pending_pinned_apps_.empty()) { 604 while (!pending_pinned_apps_.empty()) {
583 const Item& item = pending_pinned_apps_.front(); 605 const Item& item = pending_pinned_apps_.front();
584 606
585 if (!app_icon_loader_->IsValidID(item.app_id)) 607 if (!app_icon_loader_->IsValidID(item.app_id))
586 return; 608 return;
587 609
588 PinAppWithID(item.app_id); 610 PinAppWithID(item.app_id);
589 pending_pinned_apps_.pop(); 611 pending_pinned_apps_.pop_front();
590 } 612 }
591 } 613 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698