Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Unified Diff: chrome/browser/ui/webui/extensions/extension_settings_handler.cc

Issue 10407105: Improve error messaging of webRequest API in case of conflicts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix windows compilation Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 32e6243f5c2462be9fa809636a8e3d418036a0ea..dce4ed5d780e8eb9d1619b00481ee56911085b18 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -67,6 +67,7 @@ using content::RenderViewHost;
using content::WebContents;
using extensions::Extension;
using extensions::ExtensionUpdater;
+using extensions::ExtensionWarning;
using extensions::ManagementPolicy;
///////////////////////////////////////////////////////////////////////////////
@@ -90,6 +91,13 @@ ExtensionSettingsHandler::~ExtensionSettingsHandler() {
load_extension_dialog_->ListenerDestroyed();
registrar_.RemoveAll();
+
+ if (registered_for_notifications_) {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ extensions::ExtensionWarningService* warning_service =
+ extensions::ExtensionSystem::Get(profile)->warning_service();
+ warning_service->RemoveObserver(this);
+ }
}
ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service,
@@ -111,7 +119,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);
@@ -183,19 +191,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(), &warnings);
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);
}
@@ -419,7 +423,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:
case chrome::NOTIFICATION_PREF_CHANGED:
MaybeUpdateAfterNotification();
@@ -461,6 +464,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;
@@ -480,10 +487,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();
@@ -523,10 +533,10 @@ 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);
+
+ bool developer_mode =
+ profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
+ results.SetBoolean("developerMode", developer_mode);
}
bool load_unpacked_disabled =
@@ -787,8 +797,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,
@@ -809,6 +817,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());

Powered by Google App Engine
This is Rietveld 408576698