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

Unified Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 979453002: [Extensions] Make chrome://extensions use developerPrivate for unpacked loading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 years, 10 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/extensions/api/developer_private/developer_private_api.cc
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index f2e9ac6ffc95436deb9a29f80f9a6c904bc2bb8b..9470e7821be80f10b1f9df841071588ddfea849e 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -756,7 +756,9 @@ ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() {
if (!extension)
return RespondNow(Error(kNoSuchExtensionError));
- bool fail_quietly = params->options && params->options->fail_quietly;
+ bool fail_quietly = params->options &&
+ params->options->fail_quietly &&
+ *params->options->fail_quietly;
ExtensionService* service = GetExtensionService(browser_context());
if (fail_quietly)
@@ -871,7 +873,15 @@ bool DeveloperPrivateInspectFunction::RunSync() {
DeveloperPrivateInspectFunction::~DeveloperPrivateInspectFunction() {}
+DeveloperPrivateLoadUnpackedFunction::DeveloperPrivateLoadUnpackedFunction()
+ : fail_quietly_(false) {
+}
+
ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() {
+ scoped_ptr<developer_private::LoadUnpacked::Params> params(
+ developer_private::LoadUnpacked::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params);
+
if (!ShowPicker(
ui::SelectFileDialog::SELECT_FOLDER,
l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY),
@@ -880,16 +890,25 @@ ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() {
return RespondNow(Error(kCouldNotShowSelectFileDialogError));
}
+ fail_quietly_ = params->options &&
+ params->options->fail_quietly &&
+ *params->options->fail_quietly;
+
AddRef(); // Balanced in FileSelected / FileSelectionCanceled.
return RespondLater();
}
void DeveloperPrivateLoadUnpackedFunction::FileSelected(
const base::FilePath& path) {
- UnpackedInstaller::Create(GetExtensionService(browser_context()))->Load(path);
+ scoped_refptr<UnpackedInstaller> installer(
+ UnpackedInstaller::Create(GetExtensionService(browser_context())));
+ installer->set_be_noisy_on_failure(!fail_quietly_);
+ installer->set_completion_callback(
+ base::Bind(&DeveloperPrivateLoadUnpackedFunction::OnLoadComplete, this));
+ installer->Load(path);
+
DeveloperPrivateAPI::Get(browser_context())->SetLastUnpackedDirectory(path);
- // TODO(devlin): Shouldn't we wait until the extension is loaded?
- Respond(NoArguments());
+
Release(); // Balanced in Run().
}
@@ -900,6 +919,13 @@ void DeveloperPrivateLoadUnpackedFunction::FileSelectionCanceled() {
Release(); // Balanced in Run().
}
+void DeveloperPrivateLoadUnpackedFunction::OnLoadComplete(
+ const Extension* extension,
+ const base::FilePath& file_path,
+ const std::string& error) {
+ Respond(extension ? NoArguments() : Error(error));
+}
+
bool DeveloperPrivateChooseEntryFunction::ShowPicker(
ui::SelectFileDialog::Type picker_type,
const base::string16& select_title,

Powered by Google App Engine
This is Rietveld 408576698