Chromium Code Reviews| Index: chrome/browser/ui/webui/extensions/extension_settings_handler.cc |
| diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc |
| index 9a2b6eaa380d7f161c32248c73c07122308e5840..084cc41e7d815c7c9dd7d6d67fb92289f896c7a3 100644 |
| --- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc |
| +++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc |
| @@ -68,6 +68,7 @@ using content::RenderViewHost; |
| using content::WebContents; |
| using extensions::Extension; |
| using extensions::ExtensionUpdater; |
| +using extensions::ExtensionWarning; |
| using extensions::ManagementPolicy; |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -91,6 +92,13 @@ ExtensionSettingsHandler::~ExtensionSettingsHandler() { |
| load_extension_dialog_->ListenerDestroyed(); |
| registrar_.RemoveAll(); |
|
Evan Stade
2012/11/13 20:21:54
I don't think this is necessary
battre
2012/11/14 12:30:54
You are right.
Done.
|
| + |
| + if (registered_for_notifications_) { |
|
Evan Stade
2012/11/13 20:21:54
might be nice if there were a scoped object to han
battre
2012/11/14 12:30:54
Done.
|
| + Profile* profile = Profile::FromWebUI(web_ui()); |
| + extensions::ExtensionWarningService* warning_service = |
| + extensions::ExtensionSystem::Get(profile)->warning_service(); |
| + warning_service->RemoveObserver(this); |
| + } |
| } |
| ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service, |
| @@ -112,7 +120,7 @@ void ExtensionSettingsHandler::RegisterUserPrefs(PrefService* prefs) { |
| DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( |
| const Extension* extension, |
| const std::vector<ExtensionPage>& pages, |
| - const ExtensionWarningSet* warnings_set) { |
| + const extensions::ExtensionWarningService* warning_service) { |
| DictionaryValue* extension_data = new DictionaryValue(); |
| bool enabled = extension_service_->IsExtensionEnabled(extension->id()); |
| extension->GetBasicInfo(enabled, extension_data); |
| @@ -204,19 +212,15 @@ DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( |
| extension_action_manager->GetPageAction(*extension)); |
| // Add warnings. |
| - if (warnings_set) { |
| - std::set<ExtensionWarningSet::WarningType> warnings; |
| - warnings_set->GetWarningsAffectingExtension(extension->id(), &warnings); |
| + if (warning_service) { |
| + std::vector<std::string> warnings = |
| + warning_service->GetWarningMessagesForExtension(extension->id()); |
| if (!warnings.empty()) { |
| ListValue* warnings_list = new ListValue; |
| - for (std::set<ExtensionWarningSet::WarningType>::const_iterator iter = |
| - warnings.begin(); |
| - iter != warnings.end(); |
| - ++iter) { |
| - string16 warning_string( |
| - ExtensionWarningSet::GetLocalizedWarning(*iter)); |
| - warnings_list->Append(Value::CreateStringValue(warning_string)); |
| + for (std::vector<std::string>::const_iterator iter = warnings.begin(); |
| + iter != warnings.end(); ++iter) { |
| + warnings_list->Append(Value::CreateStringValue(*iter)); |
| } |
| extension_data->Set("warnings", warnings_list); |
| } |
| @@ -442,7 +446,6 @@ void ExtensionSettingsHandler::Observe( |
| case chrome::NOTIFICATION_EXTENSION_LOADED: |
| case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| - case chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED: |
| case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
| MaybeUpdateAfterNotification(); |
| break; |
| @@ -489,6 +492,10 @@ void ExtensionSettingsHandler::ExtensionUninstallCanceled() { |
| extension_id_prompting_ = ""; |
| } |
| +void ExtensionSettingsHandler::ExtensionWarningsChanged() { |
| + MaybeUpdateAfterNotification(); |
| +} |
| + |
| void ExtensionSettingsHandler::ReloadUnpackedExtensions() { |
| const ExtensionSet* extensions = extension_service_->extensions(); |
| std::vector<const Extension*> unpacked_extensions; |
| @@ -508,10 +515,13 @@ void ExtensionSettingsHandler::HandleRequestExtensionsData( |
| const ListValue* args) { |
| DictionaryValue results; |
| + Profile* profile = Profile::FromWebUI(web_ui()); |
| + |
| // Add the extensions to the results structure. |
| ListValue *extensions_list = new ListValue(); |
| - ExtensionWarningSet* warnings = extension_service_->extension_warnings(); |
| + extensions::ExtensionWarningService* warnings = |
| + extensions::ExtensionSystem::Get(profile)->warning_service(); |
| const ExtensionSet* extensions = extension_service_->extensions(); |
| for (ExtensionSet::const_iterator extension = extensions->begin(); |
| @@ -551,14 +561,13 @@ void ExtensionSettingsHandler::HandleRequestExtensionsData( |
| results.SetBoolean("developerMode", false); |
| } else { |
| results.SetBoolean("managedMode", false); |
| - Profile* profile = Profile::FromWebUI(web_ui()); |
| + |
| bool developer_mode = |
| profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
| results.SetBoolean("developerMode", developer_mode); |
| } |
| // Check to see if we have any wiped out extensions. |
| - Profile* profile = Profile::FromWebUI(web_ui()); |
| ExtensionService* extension_service = |
| extensions::ExtensionSystem::Get(profile)->extension_service(); |
| scoped_ptr<const ExtensionSet> wiped_out( |
| @@ -824,8 +833,6 @@ void ExtensionSettingsHandler::MaybeRegisterForNotifications() { |
| content::Source<Profile>(profile)); |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| content::Source<Profile>(profile)); |
| - registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED, |
| - content::Source<Profile>(profile)); |
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| content::NotificationService::AllBrowserContextsAndSources()); |
| registrar_.Add(this, |
| @@ -846,6 +853,10 @@ void ExtensionSettingsHandler::MaybeRegisterForNotifications() { |
| content::Source<extensions::ExtensionPrefs>( |
| profile->GetExtensionService()->extension_prefs())); |
| + extensions::ExtensionWarningService* warning_service = |
| + extensions::ExtensionSystem::Get(profile)->warning_service(); |
| + warning_service->AddObserver(this); |
| + |
| pref_registrar_.Init(profile->GetPrefs()); |
| pref_registrar_.Add(prefs::kExtensionInstallDenyList, this); |
| local_state_pref_registrar_.Init(g_browser_process->local_state()); |