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..de61368eeb230e3fe4e3e9bc10770a69c584d0c9 100644 |
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
@@ -45,6 +45,7 @@ |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/site_instance.h" |
#include "content/public/browser/storage_partition.h" |
+#include "content/public/browser/user_metrics.h" |
#include "content/public/browser/web_contents.h" |
#include "extensions/browser/api/device_permissions_manager.h" |
#include "extensions/browser/app_window/app_window.h" |
@@ -756,7 +757,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 +874,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 +891,29 @@ ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() { |
return RespondNow(Error(kCouldNotShowSelectFileDialogError)); |
} |
+ // If this call came from the web ui, we record it. |
not at google - send to devlin
2015/03/03 22:22:10
Why only from the web UI?
- if it's because we're
Devlin
2015/03/04 17:29:12
Was gonna ask about this. Happy to remove.
|
+ if (!extension()) |
+ content::RecordComputedAction("Options_LoadUnpackedExtension"); |
+ |
+ 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 +924,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, |