| OLD | NEW |
| 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_disabled_ui.h" | 5 #include "chrome/browser/extensions/extension_disabled_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 extension_(extension), | 181 extension_(extension), |
| 182 user_response_(IGNORED), | 182 user_response_(IGNORED), |
| 183 menu_command_id_(GetMenuCommandID()) { | 183 menu_command_id_(GetMenuCommandID()) { |
| 184 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 184 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 185 content::Source<Profile>(service->profile())); | 185 content::Source<Profile>(service->profile())); |
| 186 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 186 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 187 content::Source<Profile>(service->profile())); | 187 content::Source<Profile>(service->profile())); |
| 188 } | 188 } |
| 189 | 189 |
| 190 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { | 190 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { |
| 191 ReleaseMenuCommandID(menu_command_id_); |
| 191 HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse", | 192 HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse", |
| 192 user_response_, EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); | 193 user_response_, EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); |
| 193 } | 194 } |
| 194 | 195 |
| 195 bool ExtensionDisabledGlobalError::HasBadge() { | 196 bool ExtensionDisabledGlobalError::HasBadge() { |
| 196 return true; | 197 return true; |
| 197 } | 198 } |
| 198 | 199 |
| 199 bool ExtensionDisabledGlobalError::HasMenuItem() { | 200 bool ExtensionDisabledGlobalError::HasMenuItem() { |
| 200 return true; | 201 return true; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 extension = content::Details<const Extension>(details).ptr(); | 277 extension = content::Details<const Extension>(details).ptr(); |
| 277 } else { | 278 } else { |
| 278 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type); | 279 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type); |
| 279 UnloadedExtensionInfo* info = | 280 UnloadedExtensionInfo* info = |
| 280 content::Details<UnloadedExtensionInfo>(details).ptr(); | 281 content::Details<UnloadedExtensionInfo>(details).ptr(); |
| 281 extension = info->extension; | 282 extension = info->extension; |
| 282 } | 283 } |
| 283 if (extension == extension_) { | 284 if (extension == extension_) { |
| 284 GlobalErrorServiceFactory::GetForProfile(service_->profile())-> | 285 GlobalErrorServiceFactory::GetForProfile(service_->profile())-> |
| 285 RemoveGlobalError(this); | 286 RemoveGlobalError(this); |
| 286 ReleaseMenuCommandID(menu_command_id_); | |
| 287 | 287 |
| 288 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) | 288 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) |
| 289 user_response_ = REENABLE; | 289 user_response_ = REENABLE; |
| 290 else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) | 290 else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) |
| 291 user_response_ = UNINSTALL; | 291 user_response_ = UNINSTALL; |
| 292 delete this; | 292 delete this; |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Globals -------------------------------------------------------------------- | 296 // Globals -------------------------------------------------------------------- |
| 297 | 297 |
| 298 namespace extensions { | 298 namespace extensions { |
| 299 | 299 |
| 300 void AddExtensionDisabledError(ExtensionService* service, | 300 void AddExtensionDisabledError(ExtensionService* service, |
| 301 const Extension* extension) { | 301 const Extension* extension) { |
| 302 GlobalErrorServiceFactory::GetForProfile(service->profile())-> | 302 GlobalErrorServiceFactory::GetForProfile(service->profile())-> |
| 303 AddGlobalError(new ExtensionDisabledGlobalError(service, extension)); | 303 AddGlobalError(new ExtensionDisabledGlobalError(service, extension)); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, | 306 void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, |
| 307 const Extension* extension) { | 307 const Extension* extension) { |
| 308 // This object manages its own lifetime. | 308 // This object manages its own lifetime. |
| 309 new ExtensionDisabledDialogDelegate(profile, service, extension); | 309 new ExtensionDisabledDialogDelegate(profile, service, extension); |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace extensions | 312 } // namespace extensions |
| OLD | NEW |