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

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: Addressed Evan's comments Created 8 years, 1 month 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 9a2b6eaa380d7f161c32248c73c07122308e5840..d57c6e2d53459e8ff56f882ed56861f607dd3de3 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;
///////////////////////////////////////////////////////////////////////////////
@@ -81,7 +82,8 @@ ExtensionSettingsHandler::ExtensionSettingsHandler()
management_policy_(NULL),
ignore_notifications_(false),
deleting_rvh_(NULL),
- registered_for_notifications_(false) {
+ registered_for_notifications_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(warning_service_observer_(this)) {
}
ExtensionSettingsHandler::~ExtensionSettingsHandler() {
@@ -89,8 +91,6 @@ ExtensionSettingsHandler::~ExtensionSettingsHandler() {
// away so they don't try and call back to us.
if (load_extension_dialog_)
load_extension_dialog_->ListenerDestroyed();
-
- registrar_.RemoveAll();
}
ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service,
@@ -99,7 +99,8 @@ ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service,
management_policy_(policy),
ignore_notifications_(false),
deleting_rvh_(NULL),
- registered_for_notifications_(false) {
+ registered_for_notifications_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(warning_service_observer_(this)) {
}
// static
@@ -112,7 +113,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 +205,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 +439,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 +485,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 +508,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 +554,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 +826,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 +846,9 @@ void ExtensionSettingsHandler::MaybeRegisterForNotifications() {
content::Source<extensions::ExtensionPrefs>(
profile->GetExtensionService()->extension_prefs()));
+ warning_service_observer_.Add(
+ extensions::ExtensionSystem::Get(profile)->warning_service());
+
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