| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 icon_ = gfx::Image( | 204 icon_ = gfx::Image( |
| 205 gfx::ImageSkiaOperations::CreateResizedImage( | 205 gfx::ImageSkiaOperations::CreateResizedImage( |
| 206 extension_->is_app() ? | 206 extension_->is_app() ? |
| 207 extensions::IconsInfo::GetDefaultAppIcon() : | 207 extensions::IconsInfo::GetDefaultAppIcon() : |
| 208 extensions::IconsInfo::GetDefaultExtensionIcon(), | 208 extensions::IconsInfo::GetDefaultExtensionIcon(), |
| 209 skia::ImageOperations::RESIZE_BEST, | 209 skia::ImageOperations::RESIZE_BEST, |
| 210 gfx::Size(kIconSize, kIconSize))); | 210 gfx::Size(kIconSize, kIconSize))); |
| 211 } | 211 } |
| 212 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 212 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 213 content::Source<Profile>(service->profile())); | 213 content::Source<Profile>(service->profile())); |
| 214 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 214 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_REMOVED, |
| 215 content::Source<Profile>(service->profile())); | 215 content::Source<Profile>(service->profile())); |
| 216 } | 216 } |
| 217 | 217 |
| 218 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { | 218 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { |
| 219 ReleaseMenuCommandID(menu_command_id_); | 219 ReleaseMenuCommandID(menu_command_id_); |
| 220 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse", | 220 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse", |
| 221 user_response_, | 221 user_response_, |
| 222 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); | 222 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); |
| 223 } | 223 } |
| 224 | 224 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 | 312 |
| 313 void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() { | 313 void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() { |
| 314 // Nothing happens, and the error is still there. | 314 // Nothing happens, and the error is still there. |
| 315 } | 315 } |
| 316 | 316 |
| 317 void ExtensionDisabledGlobalError::Observe( | 317 void ExtensionDisabledGlobalError::Observe( |
| 318 int type, | 318 int type, |
| 319 const content::NotificationSource& source, | 319 const content::NotificationSource& source, |
| 320 const content::NotificationDetails& details) { | 320 const content::NotificationDetails& details) { |
| 321 const Extension* extension = NULL; | 321 // The error is invalidated if the extension has been loaded |
| 322 // The error is invalidated if the extension has been reloaded | 322 // or removed. |
| 323 // or unloaded. | 323 DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED || |
| 324 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { | 324 type == chrome::NOTIFICATION_EXTENSION_REMOVED); |
| 325 extension = content::Details<const Extension>(details).ptr(); | 325 const Extension* extension = content::Details<const Extension>(details).ptr(); |
| 326 } else { | 326 if (extension != extension_) |
| 327 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type); | 327 return; |
| 328 extensions::UnloadedExtensionInfo* info = | 328 GlobalErrorServiceFactory::GetForProfile(service_->profile())-> |
| 329 content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); | 329 RemoveGlobalError(this); |
| 330 extension = info->extension; | |
| 331 } | |
| 332 if (extension == extension_) { | |
| 333 GlobalErrorServiceFactory::GetForProfile(service_->profile())-> | |
| 334 RemoveGlobalError(this); | |
| 335 | 330 |
| 336 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) | 331 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) |
| 337 user_response_ = REENABLE; | 332 user_response_ = REENABLE; |
| 338 else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) | 333 else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) |
| 339 user_response_ = UNINSTALL; | 334 user_response_ = UNINSTALL; |
| 340 delete this; | 335 delete this; |
| 341 } | |
| 342 } | 336 } |
| 343 | 337 |
| 344 // Globals -------------------------------------------------------------------- | 338 // Globals -------------------------------------------------------------------- |
| 345 | 339 |
| 346 namespace extensions { | 340 namespace extensions { |
| 347 | 341 |
| 348 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, | 342 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, |
| 349 const std::string& extension_id, | 343 const std::string& extension_id, |
| 350 const gfx::Image& icon) { | 344 const gfx::Image& icon) { |
| 351 if (!service.get()) | 345 if (!service.get()) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 372 void ShowExtensionDisabledDialog(ExtensionService* service, | 366 void ShowExtensionDisabledDialog(ExtensionService* service, |
| 373 content::WebContents* web_contents, | 367 content::WebContents* web_contents, |
| 374 const Extension* extension) { | 368 const Extension* extension) { |
| 375 scoped_ptr<ExtensionInstallPrompt> install_ui( | 369 scoped_ptr<ExtensionInstallPrompt> install_ui( |
| 376 new ExtensionInstallPrompt(web_contents)); | 370 new ExtensionInstallPrompt(web_contents)); |
| 377 // This object manages its own lifetime. | 371 // This object manages its own lifetime. |
| 378 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); | 372 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); |
| 379 } | 373 } |
| 380 | 374 |
| 381 } // namespace extensions | 375 } // namespace extensions |
| OLD | NEW |