| 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 <bitset> | 7 #include <bitset> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | |
| 19 #include "chrome/browser/extensions/extension_install_prompt.h" | 18 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 20 #include "chrome/browser/extensions/extension_install_ui.h" | 19 #include "chrome/browser/extensions/extension_install_ui.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 21 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 23 #include "chrome/browser/extensions/extension_util.h" | 22 #include "chrome/browser/extensions/extension_util.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
| 27 #include "chrome/browser/ui/global_error/global_error.h" | 26 #include "chrome/browser/ui/global_error/global_error.h" |
| 28 #include "chrome/browser/ui/global_error/global_error_service.h" | 27 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 29 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 28 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 29 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 31 #include "content/public/browser/notification_details.h" | 30 #include "content/public/browser/notification_details.h" |
| 32 #include "content/public/browser/notification_observer.h" | 31 #include "content/public/browser/notification_observer.h" |
| 33 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
| 34 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
| 35 #include "extensions/browser/extension_util.h" | 34 #include "extensions/browser/extension_util.h" |
| 36 #include "extensions/browser/image_loader.h" | 35 #include "extensions/browser/image_loader.h" |
| 36 #include "extensions/browser/notification_types.h" |
| 37 #include "extensions/browser/uninstall_reason.h" | 37 #include "extensions/browser/uninstall_reason.h" |
| 38 #include "extensions/common/constants.h" | 38 #include "extensions/common/constants.h" |
| 39 #include "extensions/common/extension.h" | 39 #include "extensions/common/extension.h" |
| 40 #include "extensions/common/extension_icon_set.h" | 40 #include "extensions/common/extension_icon_set.h" |
| 41 #include "extensions/common/manifest_handlers/icons_handler.h" | 41 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 42 #include "extensions/common/permissions/permission_message_provider.h" | 42 #include "extensions/common/permissions/permission_message_provider.h" |
| 43 #include "extensions/common/permissions/permission_set.h" | 43 #include "extensions/common/permissions/permission_set.h" |
| 44 #include "extensions/common/permissions/permissions_data.h" | 44 #include "extensions/common/permissions/permissions_data.h" |
| 45 #include "grit/chromium_strings.h" | 45 #include "grit/chromium_strings.h" |
| 46 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 if (icon_.IsEmpty()) { | 216 if (icon_.IsEmpty()) { |
| 217 icon_ = gfx::Image( | 217 icon_ = gfx::Image( |
| 218 gfx::ImageSkiaOperations::CreateResizedImage( | 218 gfx::ImageSkiaOperations::CreateResizedImage( |
| 219 extension_->is_app() ? | 219 extension_->is_app() ? |
| 220 extensions::util::GetDefaultAppIcon() : | 220 extensions::util::GetDefaultAppIcon() : |
| 221 extensions::util::GetDefaultExtensionIcon(), | 221 extensions::util::GetDefaultExtensionIcon(), |
| 222 skia::ImageOperations::RESIZE_BEST, | 222 skia::ImageOperations::RESIZE_BEST, |
| 223 gfx::Size(kIconSize, kIconSize))); | 223 gfx::Size(kIconSize, kIconSize))); |
| 224 } | 224 } |
| 225 registrar_.Add(this, | 225 registrar_.Add(this, |
| 226 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 226 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 227 content::Source<Profile>(service->profile())); | 227 content::Source<Profile>(service->profile())); |
| 228 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_REMOVED, | 228 registrar_.Add(this, |
| 229 extensions::NOTIFICATION_EXTENSION_REMOVED, |
| 229 content::Source<Profile>(service->profile())); | 230 content::Source<Profile>(service->profile())); |
| 230 } | 231 } |
| 231 | 232 |
| 232 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { | 233 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { |
| 233 ReleaseMenuCommandID(menu_command_id_); | 234 ReleaseMenuCommandID(menu_command_id_); |
| 234 if (is_remote_install_) { | 235 if (is_remote_install_) { |
| 235 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponseRemoteInstall", | 236 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponseRemoteInstall", |
| 236 user_response_, | 237 user_response_, |
| 237 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); | 238 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); |
| 238 } else { | 239 } else { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 376 |
| 376 void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() { | 377 void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() { |
| 377 // Nothing happens, and the error is still there. | 378 // Nothing happens, and the error is still there. |
| 378 } | 379 } |
| 379 | 380 |
| 380 void ExtensionDisabledGlobalError::Observe( | 381 void ExtensionDisabledGlobalError::Observe( |
| 381 int type, | 382 int type, |
| 382 const content::NotificationSource& source, | 383 const content::NotificationSource& source, |
| 383 const content::NotificationDetails& details) { | 384 const content::NotificationDetails& details) { |
| 384 // The error is invalidated if the extension has been loaded or removed. | 385 // The error is invalidated if the extension has been loaded or removed. |
| 385 DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED || | 386 DCHECK(type == extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED || |
| 386 type == chrome::NOTIFICATION_EXTENSION_REMOVED); | 387 type == extensions::NOTIFICATION_EXTENSION_REMOVED); |
| 387 const Extension* extension = content::Details<const Extension>(details).ptr(); | 388 const Extension* extension = content::Details<const Extension>(details).ptr(); |
| 388 if (extension != extension_) | 389 if (extension != extension_) |
| 389 return; | 390 return; |
| 390 GlobalErrorServiceFactory::GetForProfile(service_->profile())-> | 391 GlobalErrorServiceFactory::GetForProfile(service_->profile())-> |
| 391 RemoveGlobalError(this); | 392 RemoveGlobalError(this); |
| 392 | 393 |
| 393 if (type == chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED) | 394 if (type == extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED) |
| 394 user_response_ = REENABLE; | 395 user_response_ = REENABLE; |
| 395 else if (type == chrome::NOTIFICATION_EXTENSION_REMOVED) | 396 else if (type == extensions::NOTIFICATION_EXTENSION_REMOVED) |
| 396 user_response_ = UNINSTALL; | 397 user_response_ = UNINSTALL; |
| 397 delete this; | 398 delete this; |
| 398 } | 399 } |
| 399 | 400 |
| 400 // Globals -------------------------------------------------------------------- | 401 // Globals -------------------------------------------------------------------- |
| 401 | 402 |
| 402 namespace extensions { | 403 namespace extensions { |
| 403 | 404 |
| 404 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, | 405 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, |
| 405 const std::string& extension_id, | 406 const std::string& extension_id, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 void ShowExtensionDisabledDialog(ExtensionService* service, | 440 void ShowExtensionDisabledDialog(ExtensionService* service, |
| 440 content::WebContents* web_contents, | 441 content::WebContents* web_contents, |
| 441 const Extension* extension) { | 442 const Extension* extension) { |
| 442 scoped_ptr<ExtensionInstallPrompt> install_ui( | 443 scoped_ptr<ExtensionInstallPrompt> install_ui( |
| 443 new ExtensionInstallPrompt(web_contents)); | 444 new ExtensionInstallPrompt(web_contents)); |
| 444 // This object manages its own lifetime. | 445 // This object manages its own lifetime. |
| 445 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); | 446 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); |
| 446 } | 447 } |
| 447 | 448 |
| 448 } // namespace extensions | 449 } // namespace extensions |
| OLD | NEW |