 Chromium Code Reviews
 Chromium Code Reviews Issue 8202011:
  Notify users about certain changes in installed extensions.  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk
    
  
    Issue 8202011:
  Notify users about certain changes in installed extensions.  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk| Index: chrome/browser/extensions/extension_service.cc | 
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc | 
| index fc0935be23244ee1e4b780a16762b0465c7ad75e..f24748f9aa43c4099d9b1ef787b11a8f0c5c3aac 100644 | 
| --- a/chrome/browser/extensions/extension_service.cc | 
| +++ b/chrome/browser/extensions/extension_service.cc | 
| @@ -9,6 +9,7 @@ | 
| #include "base/basictypes.h" | 
| #include "base/command_line.h" | 
| +#include "base/callback.h" | 
| #include "base/file_util.h" | 
| #include "base/logging.h" | 
| #include "base/metrics/histogram.h" | 
| @@ -34,6 +35,7 @@ | 
| #include "chrome/browser/extensions/extension_data_deleter.h" | 
| #include "chrome/browser/extensions/extension_downloads_api.h" | 
| #include "chrome/browser/extensions/extension_error_reporter.h" | 
| +#include "chrome/browser/extensions/extension_global_error.h" | 
| #include "chrome/browser/extensions/extension_history_api.h" | 
| #include "chrome/browser/extensions/extension_host.h" | 
| #include "chrome/browser/extensions/extension_input_ime_api.h" | 
| @@ -58,6 +60,9 @@ | 
| #include "chrome/browser/sync/api/sync_change.h" | 
| #include "chrome/browser/themes/theme_service.h" | 
| #include "chrome/browser/themes/theme_service_factory.h" | 
| +#include "chrome/browser/ui/browser.h" | 
| +#include "chrome/browser/ui/global_error_service.h" | 
| +#include "chrome/browser/ui/global_error_service_factory.h" | 
| #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 
| #include "chrome/browser/ui/webui/favicon_source.h" | 
| #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h" | 
| @@ -2138,6 +2143,90 @@ void ExtensionService::OnExternalProviderReady() { | 
| if (Extension::IsExternalLocation(info->extension_location)) | 
| CheckExternalUninstall(info->extension_id); | 
| } | 
| + | 
| +#if false | 
| + // TODO(miket): enable upon completion of feature. | 
| + IdentifyAlertableExtensions(); | 
| 
asargent_no_longer_on_chrome
2011/10/07 21:25:34
Here's a thought for you to consider - I think it
 
miket_OOO
2011/10/07 22:38:22
Agreed. I have a bad bug that's related, as descri
 | 
| +#endif | 
| +} | 
| + | 
| +void ExtensionService::IdentifyAlertableExtensions() { | 
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| + | 
| + // Build up the lists of extensions that require acknowledgment. | 
| + // If this is the first time, grandfather extensions that would have | 
| + // caused notification. | 
| + scoped_ptr<ExtensionGlobalError> global_error( | 
| + new ExtensionGlobalError(this)); | 
| + bool needs_alert = false; | 
| + for (ExtensionList::const_iterator iter = extensions_.begin(); | 
| + iter != extensions_.end(); ++iter) { | 
| + const Extension* e = *iter; | 
| + if (!IsExtensionEnabled(e->id())) { | 
| + continue; | 
| + } | 
| + if (Extension::IsExternalLocation(e->location())) { | 
| + if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) { | 
| + global_error->AddExternalExtension(e->id()); | 
| + needs_alert = true; | 
| + } | 
| + } | 
| + if (extension_prefs_->IsExtensionBlacklisted(e->id())) { | 
| + if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) { | 
| + global_error->AddBlacklistedExtension(e->id()); | 
| + needs_alert = true; | 
| + } | 
| + } | 
| + if (extension_prefs_->IsExtensionOrphaned(e->id())) { | 
| + if (!extension_prefs_->IsOrphanedExtensionAcknowledged(e->id())) { | 
| + global_error->AddOrphanedExtension(e->id()); | 
| + needs_alert = true; | 
| + } | 
| + } | 
| + } | 
| + | 
| + if (needs_alert) { | 
| + if (extension_prefs_->IsNotificationSystemInitialized()) { | 
| + global_error->set_accept_callback( | 
| + base::Bind(&ExtensionService::HandleNotificationAlertAccept, | 
| + base::Unretained(this))); | 
| + global_error->set_cancel_callback( | 
| + base::Bind(&ExtensionService::HandleNotificationAlertDetails, | 
| + base::Unretained(this))); | 
| + GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | 
| + global_error.release()); | 
| + } else { | 
| + // First run. Just acknowledge all the extensions, silently, by | 
| + // shortcutting the display of the UI and going straight to the | 
| + // callback for pressing the Accept button. | 
| + HandleNotificationAlertAccept(*global_error.get()); | 
| + } | 
| + } | 
| +} | 
| + | 
| +void ExtensionService::HandleNotificationAlertAccept( | 
| + const ExtensionGlobalError& global_error) { | 
| + const ExtensionIdSet *extension_ids = | 
| + global_error.get_external_extension_ids(); | 
| + for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); | 
| + iter != extension_ids->end(); ++iter) { | 
| + extension_prefs_->AcknowledgeExternalExtension(*iter); | 
| + } | 
| + extension_ids = global_error.get_blacklisted_extension_ids(); | 
| + for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); | 
| + iter != extension_ids->end(); ++iter) { | 
| + extension_prefs_->AcknowledgeBlacklistedExtension(*iter); | 
| + } | 
| + extension_ids = global_error.get_orphaned_extension_ids(); | 
| + for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); | 
| + iter != extension_ids->end(); ++iter) { | 
| + extension_prefs_->AcknowledgeOrphanedExtension(*iter); | 
| + } | 
| +} | 
| + | 
| +void ExtensionService::HandleNotificationAlertDetails( | 
| + const ExtensionGlobalError& global_error) { | 
| + Browser::OpenExtensionsWindow(profile_); | 
| } | 
| void ExtensionService::UnloadExtension( |