Chromium Code Reviews| Index: chrome/browser/ui/webui/extensions/extension_loader_handler.cc |
| diff --git a/chrome/browser/ui/webui/extensions/extension_loader_handler.cc b/chrome/browser/ui/webui/extensions/extension_loader_handler.cc |
| index 6e43177a4a3abd3fe57b684c2c362b5012a36f9b..dda416e136e762afa0da4f00974c25fa7943d54a 100644 |
| --- a/chrome/browser/ui/webui/extensions/extension_loader_handler.cc |
| +++ b/chrome/browser/ui/webui/extensions/extension_loader_handler.cc |
| @@ -131,8 +131,11 @@ void ExtensionLoaderHandler::FileHelper::MultiFilesSelected( |
| ExtensionLoaderHandler::ExtensionLoaderHandler(Profile* profile) |
| : profile_(profile), |
| file_helper_(new FileHelper(this)), |
| + extension_error_reporter_observer_(this), |
| + display_ready_(false), |
| weak_ptr_factory_(this) { |
| DCHECK(profile_); |
| + extension_error_reporter_observer_.Add(ExtensionErrorReporter::GetInstance()); |
| } |
| ExtensionLoaderHandler::~ExtensionLoaderHandler() { |
| @@ -166,6 +169,14 @@ void ExtensionLoaderHandler::RegisterMessages() { |
| "extensionLoaderRetry", |
| base::Bind(&ExtensionLoaderHandler::HandleRetry, |
| weak_ptr_factory_.GetWeakPtr())); |
| + web_ui()->RegisterMessageCallback( |
| + "extensionLoaderSetDisplayLoading", |
| + base::Bind(&ExtensionLoaderHandler::HandleSetDisplayLoading, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + web_ui()->RegisterMessageCallback( |
| + "extensionLoaderDisplayFailures", |
| + base::Bind(&ExtensionLoaderHandler::HandleDisplayFailures, |
| + weak_ptr_factory_.GetWeakPtr())); |
| } |
| void ExtensionLoaderHandler::HandleLoadUnpacked(const base::ListValue* args) { |
| @@ -178,13 +189,43 @@ void ExtensionLoaderHandler::HandleRetry(const base::ListValue* args) { |
| LoadUnpackedExtensionImpl(failed_path_); |
| } |
| +void ExtensionLoaderHandler::HandleSetDisplayLoading( |
| + const base::ListValue* args) { |
| + DCHECK(args->empty()); |
| + display_ready_ = false; |
| +} |
| + |
| +void ExtensionLoaderHandler::HandleDisplayFailures( |
| + const base::ListValue* args) { |
| + DCHECK(args->empty()); |
| + display_ready_ = true; |
| + |
| + if (failures_.empty()) |
| + return; |
| + |
| + FailureData* failure = failures_[0]; |
| + NotifyFrontendOfFailure(failure->file_path, |
| + failure->error, |
| + failure->line_number, |
| + failure->manifest); |
| + |
| + base::string16 list = base::UTF8ToUTF16("Additional failures:"); |
|
gpdavis
2014/06/30 19:42:52
Is this what you meant by internationalization?
Devlin
2014/06/30 21:06:42
Not quite. This changes the string from UTF8 to U
gpdavis
2014/06/30 21:41:19
Wait-- I thought you had said this needed to be i1
Devlin
2014/06/30 22:32:36
Yeah, our libraries are funky. i18n and l10n are
gpdavis
2014/06/30 23:35:11
Ah, okay, that makes sense. But since we're outso
Devlin
2014/07/01 17:02:55
_almost_ anything that's user facing. There are a
|
| + for (size_t i = 1; i < failures_.size(); ++i) { |
| + FailureData *failure = failures_[i]; |
|
Devlin
2014/06/30 21:06:42
nit: FailureData* failure - note the asterisk posi
gpdavis
2014/06/30 21:41:19
Done.
|
| + list.append(base::UTF8ToUTF16("\n")); |
| + list.append(failure->file_path.LossyDisplayName()); |
| + } |
| + failures_.clear(); |
| + base::StringValue list_value(list); |
| + web_ui()->CallJavascriptFunction( |
| + "extensions.ExtensionLoader.notifyAdditional", |
|
gpdavis
2014/06/30 19:42:52
I've been thinking about how to go about condensin
Devlin
2014/06/30 21:06:42
For this, at least as a starting point, I wouldn't
gpdavis
2014/06/30 21:41:19
Oops-- thought I responded to that.
Currently, mu
Devlin
2014/06/30 22:32:36
Good point that it'd be somewhat strange for a use
gpdavis
2014/06/30 23:35:11
Yeah, you're right, that is quite an edge case. I
Devlin
2014/07/01 17:02:55
I would envision something similar, though with mo
gpdavis
2014/07/01 20:58:55
I was already mostly done with this last night bef
|
| + list_value); |
|
Devlin
2014/06/30 21:06:42
nit: inline the string value construction here.
gpdavis
2014/06/30 21:41:19
Done.
|
| +} |
| + |
| void ExtensionLoaderHandler::LoadUnpackedExtensionImpl( |
| const base::FilePath& file_path) { |
| scoped_refptr<UnpackedInstaller> installer = UnpackedInstaller::Create( |
| ExtensionSystem::Get(profile_)->extension_service()); |
| - installer->set_on_failure_callback( |
| - base::Bind(&ExtensionLoaderHandler::OnLoadFailure, |
| - weak_ptr_factory_.GetWeakPtr())); |
| // We do our own error handling, so we don't want a load failure to trigger |
| // a dialog. |
| @@ -227,6 +268,16 @@ void ExtensionLoaderHandler::NotifyFrontendOfFailure( |
| const std::string& error, |
| size_t line_number, |
| const std::string& manifest) { |
| + // If the extensions page is not loaded, delay frontend notification. |
| + if (!display_ready_) { |
| + FailureData* failure = new FailureData(file_path, |
| + error, |
| + line_number, |
| + manifest); |
| + failures_.push_back(failure); |
|
Devlin
2014/06/30 21:06:42
nit: inline the failuredata construction here.
gpdavis
2014/06/30 21:41:19
Done.
|
| + return; |
| + } |
| + |
| base::StringValue file_value(file_path.LossyDisplayName()); |
| base::StringValue error_value(base::UTF8ToUTF16(error)); |