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

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

Issue 204703002: Rename NOTIFICATION_EXTENSION_UNLOADED to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: maybe upload wont do something bizarre this time Created 6 years, 9 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
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/extensions/extension_toolbar_model.h" 5 #include "chrome/browser/extensions/extension_toolbar_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_base.h" 10 #include "base/metrics/histogram_base.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 ExtensionToolbarModel::ExtensionToolbarModel( 44 ExtensionToolbarModel::ExtensionToolbarModel(
45 Profile* profile, 45 Profile* profile,
46 extensions::ExtensionPrefs* extension_prefs) 46 extensions::ExtensionPrefs* extension_prefs)
47 : profile_(profile), 47 : profile_(profile),
48 extension_prefs_(extension_prefs), 48 extension_prefs_(extension_prefs),
49 prefs_(profile_->GetPrefs()), 49 prefs_(profile_->GetPrefs()),
50 extensions_initialized_(false), 50 extensions_initialized_(false),
51 weak_ptr_factory_(this) { 51 weak_ptr_factory_(this) {
52 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 52 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
53 content::Source<Profile>(profile_)); 53 content::Source<Profile>(profile_));
54 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 54 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
55 content::Source<Profile>(profile_)); 55 content::Source<Profile>(profile_));
56 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, 56 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
57 content::Source<Profile>(profile_)); 57 content::Source<Profile>(profile_));
58 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 58 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
59 content::Source<Profile>(profile_)); 59 content::Source<Profile>(profile_));
60 registrar_.Add( 60 registrar_.Add(
61 this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, 61 this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED,
62 content::Source<extensions::ExtensionPrefs>(extension_prefs_)); 62 content::Source<extensions::ExtensionPrefs>(extension_prefs_));
63 63
64 visible_icon_count_ = prefs_->GetInteger( 64 visible_icon_count_ = prefs_->GetInteger(
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 extensions::ExtensionSystem::Get(profile_)->extension_service(); 182 extensions::ExtensionSystem::Get(profile_)->extension_service();
183 if (!extension_service || !extension_service->is_ready()) 183 if (!extension_service || !extension_service->is_ready())
184 return; 184 return;
185 185
186 if (type == chrome::NOTIFICATION_EXTENSIONS_READY) { 186 if (type == chrome::NOTIFICATION_EXTENSIONS_READY) {
187 InitializeExtensionList(extension_service); 187 InitializeExtensionList(extension_service);
188 return; 188 return;
189 } 189 }
190 190
191 const Extension* extension = NULL; 191 const Extension* extension = NULL;
192 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { 192 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) {
193 extension = content::Details<extensions::UnloadedExtensionInfo>( 193 extension = content::Details<extensions::UnloadedExtensionInfo>(
194 details)->extension; 194 details)->extension;
195 } else if (type == 195 } else if (type ==
196 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED) { 196 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED) {
197 extension = extension_service->GetExtensionById( 197 extension = extension_service->GetExtensionById(
198 *content::Details<const std::string>(details).ptr(), true); 198 *content::Details<const std::string>(details).ptr(), true);
199 } else { 199 } else {
200 extension = content::Details<const Extension>(details).ptr(); 200 extension = content::Details<const Extension>(details).ptr();
201 } 201 }
202 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { 202 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
203 // We don't want to add the same extension twice. It may have already been 203 // We don't want to add the same extension twice. It may have already been
204 // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user 204 // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user
205 // hides the browser action and then disables and enables the extension. 205 // hides the browser action and then disables and enables the extension.
206 for (size_t i = 0; i < toolbar_items_.size(); i++) { 206 for (size_t i = 0; i < toolbar_items_.size(); i++) {
207 if (toolbar_items_[i].get() == extension) 207 if (toolbar_items_[i].get() == extension)
208 return; // Already exists. 208 return; // Already exists.
209 } 209 }
210 if (extensions::ExtensionActionAPI::GetBrowserActionVisibility( 210 if (extensions::ExtensionActionAPI::GetBrowserActionVisibility(
211 extension_prefs_, extension->id())) { 211 extension_prefs_, extension->id())) {
212 AddExtension(extension); 212 AddExtension(extension);
213 } 213 }
214 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { 214 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) {
215 RemoveExtension(extension); 215 RemoveExtension(extension);
216 } else if (type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED) { 216 } else if (type == chrome::NOTIFICATION_EXTENSION_UNINSTALLED) {
217 UninstalledExtension(extension); 217 UninstalledExtension(extension);
218 } else if (type == 218 } else if (type ==
219 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED) { 219 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED) {
220 if (extensions::ExtensionActionAPI::GetBrowserActionVisibility( 220 if (extensions::ExtensionActionAPI::GetBrowserActionVisibility(
221 extension_prefs_, extension->id())) { 221 extension_prefs_, extension->id())) {
222 AddExtension(extension); 222 AddExtension(extension);
223 } else { 223 } else {
224 RemoveExtension(extension); 224 RemoveExtension(extension);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 for (ExtensionList::const_iterator extension = toolbar_items_.begin(); 513 for (ExtensionList::const_iterator extension = toolbar_items_.begin();
514 extension != toolbar_items_.end(); ++extension) { 514 extension != toolbar_items_.end(); ++extension) {
515 if ((*extension)->id() == (*it)) { 515 if ((*extension)->id() == (*it)) {
516 if (extension - toolbar_items_.begin() >= visible_icon_count_) 516 if (extension - toolbar_items_.begin() >= visible_icon_count_)
517 MoveBrowserAction(*extension, 0); 517 MoveBrowserAction(*extension, 0);
518 break; 518 break;
519 } 519 }
520 } 520 }
521 } 521 }
522 } 522 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/extensions/extension_warning_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698