Commit 3551fecc authored by Allen Vicencio's avatar Allen Vicencio Committed by Commit Bot

Add credential parameters to Mount

Adds credential parameters to Mount in SmbProviderClient

Bug: chromium:757625
Change-Id: Ie5a2abcb6cb7fd90711d6ccabed53bf7de973f6a
Reviewed-on: https://chromium-review.googlesource.com/1020415Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: Allen Vicencio <allenvic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553996}
parent fb0734bb
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/chromeos/smb_client/smb_file_system_id.h" #include "chrome/browser/chromeos/smb_client/smb_file_system_id.h"
#include "chrome/browser/chromeos/smb_client/smb_provider.h" #include "chrome/browser/chromeos/smb_client/smb_provider.h"
#include "chrome/browser/chromeos/smb_client/smb_service_factory.h" #include "chrome/browser/chromeos/smb_client/smb_service_factory.h"
#include "chrome/browser/chromeos/smb_client/temp_file_manager.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/smb_provider_client.h" #include "chromeos/dbus/smb_provider_client.h"
...@@ -39,9 +40,13 @@ SmbService* SmbService::Get(content::BrowserContext* context) { ...@@ -39,9 +40,13 @@ SmbService* SmbService::Get(content::BrowserContext* context) {
void SmbService::Mount(const file_system_provider::MountOptions& options, void SmbService::Mount(const file_system_provider::MountOptions& options,
const base::FilePath& share_path, const base::FilePath& share_path,
MountResponse callback) { MountResponse callback) {
// TODO(allenvic): Implement passing of credentials. This currently passes
// empty credentials to SmbProvider.
GetSmbProviderClient()->Mount( GetSmbProviderClient()->Mount(
share_path, base::BindOnce(&SmbService::OnMountResponse, AsWeakPtr(), share_path, "" /* workgroup */, "" /* username */,
base::Passed(&callback), options, share_path)); temp_file_manager_.CreatePasswordFile("" /* password */),
base::BindOnce(&SmbService::OnMountResponse, AsWeakPtr(),
base::Passed(&callback), options, share_path));
} }
void SmbService::OnMountResponse( void SmbService::OnMountResponse(
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h" #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
#include "chrome/browser/chromeos/file_system_provider/provider_interface.h" #include "chrome/browser/chromeos/file_system_provider/provider_interface.h"
#include "chrome/browser/chromeos/file_system_provider/service.h" #include "chrome/browser/chromeos/file_system_provider/service.h"
#include "chrome/browser/chromeos/smb_client/temp_file_manager.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chromeos/dbus/smb_provider_client.h" #include "chromeos/dbus/smb_provider_client.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
...@@ -84,6 +85,7 @@ class SmbService : public KeyedService, ...@@ -84,6 +85,7 @@ class SmbService : public KeyedService,
const ProviderId provider_id_; const ProviderId provider_id_;
Profile* profile_; Profile* profile_;
TempFileManager temp_file_manager_;
DISALLOW_COPY_AND_ASSIGN(SmbService); DISALLOW_COPY_AND_ASSIGN(SmbService);
}; };
......
...@@ -19,6 +19,9 @@ FakeSmbProviderClient::~FakeSmbProviderClient() {} ...@@ -19,6 +19,9 @@ FakeSmbProviderClient::~FakeSmbProviderClient() {}
void FakeSmbProviderClient::Init(dbus::Bus* bus) {} void FakeSmbProviderClient::Init(dbus::Bus* bus) {}
void FakeSmbProviderClient::Mount(const base::FilePath& share_path, void FakeSmbProviderClient::Mount(const base::FilePath& share_path,
const std::string& workgroup,
const std::string& username,
base::ScopedFD password_fd,
MountCallback callback) { MountCallback callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), smbprovider::ERROR_OK, 1)); FROM_HERE, base::BindOnce(std::move(callback), smbprovider::ERROR_OK, 1));
......
...@@ -19,7 +19,12 @@ class CHROMEOS_EXPORT FakeSmbProviderClient : public SmbProviderClient { ...@@ -19,7 +19,12 @@ class CHROMEOS_EXPORT FakeSmbProviderClient : public SmbProviderClient {
void Init(dbus::Bus* bus) override; void Init(dbus::Bus* bus) override;
// SmbProviderClient override. // SmbProviderClient override.
void Mount(const base::FilePath& share_path, MountCallback callback) override; void Mount(const base::FilePath& share_path,
const std::string& workgroup,
const std::string& username,
base::ScopedFD password_fd,
MountCallback callback) override;
void Remount(const base::FilePath& share_path, void Remount(const base::FilePath& share_path,
int32_t mount_id, int32_t mount_id,
StatusCallback callback) override; StatusCallback callback) override;
......
...@@ -63,11 +63,22 @@ class SmbProviderClientImpl : public SmbProviderClient { ...@@ -63,11 +63,22 @@ class SmbProviderClientImpl : public SmbProviderClient {
~SmbProviderClientImpl() override {} ~SmbProviderClientImpl() override {}
void Mount(const base::FilePath& share_path, void Mount(const base::FilePath& share_path,
const std::string& workgroup,
const std::string& username,
base::ScopedFD password_fd,
MountCallback callback) override { MountCallback callback) override {
smbprovider::MountOptionsProto options; smbprovider::MountOptionsProto options;
options.set_path(share_path.value()); options.set_path(share_path.value());
CallMethod(smbprovider::kMountMethod, options, options.set_workgroup(workgroup);
&SmbProviderClientImpl::HandleMountCallback, &callback); options.set_username(username);
dbus::MethodCall method_call(smbprovider::kSmbProviderInterface,
smbprovider::kMountMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendProtoAsArrayOfBytes(options);
writer.AppendFileDescriptor(password_fd.release());
CallMethod(&method_call, &SmbProviderClientImpl::HandleMountCallback,
&callback);
} }
void Remount(const base::FilePath& share_path, void Remount(const base::FilePath& share_path,
......
...@@ -48,9 +48,13 @@ class CHROMEOS_EXPORT SmbProviderClient ...@@ -48,9 +48,13 @@ class CHROMEOS_EXPORT SmbProviderClient
static SmbProviderClient* Create(); static SmbProviderClient* Create();
// Calls Mount. It runs OpenDirectory() on |share_path| to check that it is a // Calls Mount. It runs OpenDirectory() on |share_path| to check that it is a
// valid share. |callback| is called after getting (or failing to get) D-BUS // valid share. |workgroup|, |username|, and |password_fd| will be used as
// response. // credentials to access the mount. |callback| is called after getting (or
// failing to get) D-BUS response.
virtual void Mount(const base::FilePath& share_path, virtual void Mount(const base::FilePath& share_path,
const std::string& workgroup,
const std::string& username,
base::ScopedFD password_fd,
MountCallback callback) = 0; MountCallback callback) = 0;
// Calls Remount. This attempts to remount the share at |share_path| with its // Calls Remount. This attempts to remount the share at |share_path| with its
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment