Add a centralized error reporter to the
extensions sytem. This can be called from any
component on any thread. The hope is that this
will encourage more thorough error handling.
Review URL: http://codereview.chromium.org/27165
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10611 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 4c1a40f..9fc0040 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -14,6 +14,7 @@
#include "base/values.h"
#include "net/base/file_stream.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/common/json_value_serializer.h"
@@ -22,7 +23,6 @@
#if defined(OS_WIN)
#include "base/registry.h"
-#include "chrome/common/win_util.h"
#endif
// ExtensionsService
@@ -170,31 +170,6 @@
delete new_extensions;
}
-void ExtensionsService::OnExtensionLoadError(bool alert_on_error,
- const std::string& error) {
- // TODO(aa): Print the error message out somewhere better. I think we are
- // going to need some sort of 'extension inspector'.
- LOG(WARNING) << error;
- if (alert_on_error) {
-#if defined(OS_WIN)
- win_util::MessageBox(NULL, UTF8ToWide(error),
- L"Extension load error", MB_OK | MB_SETFOREGROUND);
-#endif
- }
-}
-
-void ExtensionsService::OnExtensionInstallError(bool alert_on_error,
- const std::string& error) {
- // TODO(erikkay): Print the error message out somewhere better.
- LOG(WARNING) << error;
- if (alert_on_error) {
-#if defined(OS_WIN)
- win_util::MessageBox(NULL, UTF8ToWide(error),
- L"Extension load error", MB_OK | MB_SETFOREGROUND);
-#endif
- }
-}
-
void ExtensionsService::OnExtensionInstalled(FilePath path, bool update) {
NotificationService::current()->Notify(
NotificationType::EXTENSION_INSTALLED,
@@ -339,14 +314,11 @@
void ExtensionsServiceBackend::ReportExtensionLoadError(
const std::string &error) {
-
// TODO(port): note that this isn't guaranteed to work properly on Linux.
std::string path_str = WideToASCII(extension_path_.ToWStringHack());
std::string message = StringPrintf("Could not load extension from '%s'. %s",
path_str.c_str(), error.c_str());
- frontend_->GetMessageLoop()->PostTask(FROM_HERE, NewRunnableMethod(
- frontend_, &ExtensionsServiceFrontendInterface::OnExtensionLoadError,
- alert_on_error_, message));
+ ExtensionErrorReporter::GetInstance()->ReportError(message, alert_on_error_);
}
void ExtensionsServiceBackend::ReportExtensionsLoaded(
@@ -702,9 +674,7 @@
std::string message =
StringPrintf("Could not install extension from '%s'. %s",
path_str.c_str(), error.c_str());
- frontend_->GetMessageLoop()->PostTask(FROM_HERE, NewRunnableMethod(
- frontend_, &ExtensionsServiceFrontendInterface::OnExtensionInstallError,
- alert_on_error_, message));
+ ExtensionErrorReporter::GetInstance()->ReportError(message, alert_on_error_);
}
void ExtensionsServiceBackend::ReportExtensionInstalled(