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

Side by Side Diff: chrome/browser/extensions/extension_shelf_model.cc

Issue 147026: Fix case where install puts two copies of the extension toolbar on the shelf. (Closed)
Patch Set: Created 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions/extension_shelf_model.h" 5 #include "chrome/browser/extensions/extension_shelf_model.h"
6 6
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/profile.h" 8 #include "chrome/browser/profile.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_process_manager.h" 10 #include "chrome/browser/extensions/extension_process_manager.h"
11 #include "chrome/browser/extensions/extensions_service.h" 11 #include "chrome/browser/extensions/extensions_service.h"
12 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/notification_service.h" 13 #include "chrome/common/notification_service.h"
14 14
15 ///////////////////////////// 15 /////////////////////////////
16 16
17 ExtensionShelfModel::ExtensionShelfModel(Browser* browser) 17 ExtensionShelfModel::ExtensionShelfModel(Browser* browser)
18 : browser_(browser), ready_(false) { 18 : browser_(browser), ready_(false) {
19 // Watch extensions loaded and unloaded notifications. 19 // Watch extensions loaded and unloaded notifications.
20 registrar_.Add(this, NotificationType::EXTENSION_INSTALLED,
21 NotificationService::AllSources());
22 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 20 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
23 NotificationService::AllSources()); 21 NotificationService::AllSources());
24 registrar_.Add(this, NotificationType::EXTENSIONS_LOADED, 22 registrar_.Add(this, NotificationType::EXTENSIONS_LOADED,
25 NotificationService::AllSources()); 23 NotificationService::AllSources());
26 registrar_.Add(this, NotificationType::EXTENSIONS_READY, 24 registrar_.Add(this, NotificationType::EXTENSIONS_READY,
27 NotificationService::AllSources()); 25 NotificationService::AllSources());
28 26
29 // Add any already-loaded extensions now, since we missed the notification for 27 // Add any already-loaded extensions now, since we missed the notification for
30 // those. 28 // those.
31 ExtensionsService* service = browser_->profile()->GetExtensionsService(); 29 ExtensionsService* service = browser_->profile()->GetExtensionsService();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 101 }
104 102
105 ExtensionHost* ExtensionShelfModel::ToolstripAt(int index) { 103 ExtensionHost* ExtensionShelfModel::ToolstripAt(int index) {
106 return toolstrips_[index]; 104 return toolstrips_[index];
107 } 105 }
108 106
109 void ExtensionShelfModel::Observe(NotificationType type, 107 void ExtensionShelfModel::Observe(NotificationType type,
110 const NotificationSource& source, 108 const NotificationSource& source,
111 const NotificationDetails& details) { 109 const NotificationDetails& details) {
112 switch (type.value) { 110 switch (type.value) {
113 case NotificationType::EXTENSION_INSTALLED:
114 if (ready_) {
115 AddExtension(Details<Extension>(details).ptr());
116 UpdatePrefs();
117 }
118 break;
119 case NotificationType::EXTENSIONS_LOADED: 111 case NotificationType::EXTENSIONS_LOADED:
120 if (ready_) 112 if (ready_)
121 AddExtensions(Details<ExtensionList>(details).ptr()); 113 AddExtensions(Details<ExtensionList>(details).ptr());
122 break; 114 break;
123 case NotificationType::EXTENSION_UNLOADED: 115 case NotificationType::EXTENSION_UNLOADED:
124 RemoveExtension(Details<Extension>(details).ptr()); 116 RemoveExtension(Details<Extension>(details).ptr());
125 break; 117 break;
126 case NotificationType::EXTENSIONS_READY: 118 case NotificationType::EXTENSIONS_READY:
127 AddExtensions(browser_->profile()->GetExtensionsService()->extensions()); 119 AddExtensions(browser_->profile()->GetExtensionsService()->extensions());
128 SortToolstrips(); 120 SortToolstrips();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // Any toolstrips remaining in |copy| were somehow missing from the prefs, 215 // Any toolstrips remaining in |copy| were somehow missing from the prefs,
224 // so just append them to the end. 216 // so just append them to the end.
225 for (ExtensionToolstrips::iterator toolstrip = copy.begin(); 217 for (ExtensionToolstrips::iterator toolstrip = copy.begin();
226 toolstrip != copy.end(); ++toolstrip) { 218 toolstrip != copy.end(); ++toolstrip) {
227 toolstrips_.push_back(*toolstrip); 219 toolstrips_.push_back(*toolstrip);
228 } 220 }
229 221
230 FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_, 222 FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
231 ShelfModelReloaded()); 223 ShelfModelReloaded());
232 } 224 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698