Commit 372d0df7 authored by Gavin Williams's avatar Gavin Williams Committed by Commit Bot

scanning: Return display name for My Drive & My files

When selected in the select dialog, 'My files' returns the path
"/home/chronos/u-..../MyFiles" and Google Drive 'My Drive' returns the
path "/media/fuse/drivefs-..../root". When either of these two
directories are selected, return the preferred display name to the UI.

Bug: 1059779
Change-Id: Ic67a666d5c8948b0ffa30eef25fad39712d96ea5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2511209Reviewed-by: default avatarJesse Schettler <jschettler@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Gavin Williams <gavinwill@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824569}
parent c5786983
......@@ -2590,6 +2590,8 @@ source_set("chromeos") {
"scanning/scan_service_factory.cc",
"scanning/scan_service_factory.h",
"scanning/scanner_detector.h",
"scanning/scanning_paths_provider_impl.cc",
"scanning/scanning_paths_provider_impl.h",
"scanning/scanning_type_converters.cc",
"scanning/scanning_type_converters.h",
"scanning/zeroconf_scanner_detector.cc",
......@@ -3757,6 +3759,7 @@ source_set("unit_tests") {
"scanning/lorgnette_scanner_manager_unittest.cc",
"scanning/lorgnette_scanner_manager_util_unittest.cc",
"scanning/scan_service_unittest.cc",
"scanning/scanning_paths_provider_impl_unittest.cc",
"scanning/scanning_type_converters_unittest.cc",
"scanning/zeroconf_scanner_detector_unittest.cc",
"scheduler_configuration_manager_unittest.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/scanning/scanning_paths_provider_impl.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
namespace {
constexpr char kRoot[] = "root";
} // namespace
ScanningPathsProviderImpl::ScanningPathsProviderImpl() = default;
ScanningPathsProviderImpl::~ScanningPathsProviderImpl() = default;
std::string ScanningPathsProviderImpl::GetBaseNameFromPath(
content::WebUI* web_ui,
const base::FilePath& path) {
Profile* profile = Profile::FromWebUI(web_ui);
auto* integration_service =
drive::DriveIntegrationServiceFactory::GetForProfile(profile);
bool drive_available = integration_service &&
integration_service->is_enabled() &&
integration_service->IsMounted();
if (drive_available &&
integration_service->GetMountPointPath().Append(kRoot) == path)
return l10n_util::GetStringUTF8(IDS_SCANNING_APP_MY_DRIVE);
if (file_manager::util::GetMyFilesFolderForProfile(profile) == path)
return l10n_util::GetStringUTF8(IDS_SCANNING_APP_MY_FILES_SELECT_OPTION);
return path.BaseName().value();
}
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_SCANNING_SCANNING_PATHS_PROVIDER_IMPL_H_
#define CHROME_BROWSER_CHROMEOS_SCANNING_SCANNING_PATHS_PROVIDER_IMPL_H_
#include <string>
#include "base/files/file_path.h"
#include "chromeos/components/scanning/scanning_paths_provider.h"
namespace content {
class WebUI;
} // namespace content
namespace chromeos {
class ScanningPathsProviderImpl : public ScanningPathsProvider {
public:
ScanningPathsProviderImpl();
~ScanningPathsProviderImpl() override;
ScanningPathsProviderImpl(const ScanningPathsProviderImpl&) = delete;
ScanningPathsProviderImpl& operator=(const ScanningPathsProviderImpl&) =
delete;
// ScanningPathsProvider:
std::string GetBaseNameFromPath(content::WebUI* web_ui,
const base::FilePath& path) override;
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_SCANNING_SCANNING_PATHS_PROVIDER_IMPL_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/scanning/scanning_paths_provider_impl.h"
#include <memory>
#include "base/bind.h"
#include "base/files/file_path.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/drivefs_test_support.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/login/login_state/login_state.h"
#include "components/account_id/account_id.h"
#include "components/drive/drive_pref_names.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace {
constexpr char kRoot[] = "root";
} // namespace
class ScanningPathsProviderImplTest : public testing::Test {
public:
ScanningPathsProviderImplTest()
: task_environment_(content::BrowserTaskEnvironment::REAL_IO_THREAD),
profile_manager_(TestingBrowserProcess::GetGlobal()) {}
~ScanningPathsProviderImplTest() override = default;
void SetUp() override {
chromeos::LoginState::Initialize();
chromeos::DBusThreadManager::Initialize();
if (!network_portal_detector::IsInitialized()) {
network_portal_detector_ = new NetworkPortalDetectorTestImpl();
network_portal_detector::InitializeForTesting(network_portal_detector_);
}
ASSERT_TRUE(profile_manager_.SetUp());
profile_ = profile_manager_.CreateTestingProfile("profile1@gmail.com");
profile_->GetPrefs()->SetBoolean(drive::prefs::kDriveFsPinnedMigrated,
true);
user_manager_.AddUser(
AccountId::FromUserEmail(profile_->GetProfileUserName()));
web_contents_ = content::WebContents::Create(
content::WebContents::CreateParams(profile_));
web_ui_ = std::make_unique<content::TestWebUI>();
web_ui_->set_web_contents(web_contents_.get());
create_drive_integration_service_ = base::Bind(
&ScanningPathsProviderImplTest::CreateDriveIntegrationService,
base::Unretained(this));
service_factory_for_test_ = std::make_unique<
drive::DriveIntegrationServiceFactory::ScopedFactoryForTest>(
&create_drive_integration_service_);
drive::DriveIntegrationService* integration_service =
drive::DriveIntegrationServiceFactory::GetForProfile(profile_);
integration_service->OnMounted(drive_mount_point_);
drive_mount_point_ = integration_service->GetMountPointPath();
}
void TearDown() override {
chromeos::LoginState::Shutdown();
chromeos::DBusThreadManager::Shutdown();
}
protected:
drive::DriveIntegrationService* CreateDriveIntegrationService(
Profile* profile) {
return new drive::DriveIntegrationService(
profile, std::string(), profile->GetPath().Append("drivefs"),
fake_drivefs_helper_->CreateFakeDriveFsListenerFactory());
}
TestingProfile* profile_;
ScanningPathsProviderImpl scanning_paths_provider_;
std::unique_ptr<content::TestWebUI> web_ui_;
base::FilePath drive_mount_point_;
private:
chromeos::FakeChromeUserManager user_manager_;
NetworkPortalDetectorTestImpl* network_portal_detector_;
content::BrowserTaskEnvironment task_environment_;
TestingProfileManager profile_manager_;
std::unique_ptr<content::WebContents> web_contents_;
std::unique_ptr<drive::DriveIntegrationServiceFactory::ScopedFactoryForTest>
service_factory_for_test_;
drive::DriveIntegrationServiceFactory::FactoryCallback
create_drive_integration_service_;
std::unique_ptr<drive::FakeDriveFsHelper> fake_drivefs_helper_;
};
// Validates that sending the Google Drive root filepath returns 'My Drive'.
TEST_F(ScanningPathsProviderImplTest, MyDrivePath) {
EXPECT_EQ("directory", scanning_paths_provider_.GetBaseNameFromPath(
web_ui_.get(), base::FilePath("/test/directory")));
EXPECT_EQ("Sub Folder",
scanning_paths_provider_.GetBaseNameFromPath(
web_ui_.get(),
drive_mount_point_.Append(kRoot).Append("Sub Folder")));
EXPECT_EQ("My Drive", scanning_paths_provider_.GetBaseNameFromPath(
web_ui_.get(), drive_mount_point_.Append(kRoot)));
}
// Validates that sending the MyFiles filepath returns 'My files'.
TEST_F(ScanningPathsProviderImplTest, MyFilesPath) {
base::FilePath my_files_path =
file_manager::util::GetMyFilesFolderForProfile(profile_);
EXPECT_EQ("directory", scanning_paths_provider_.GetBaseNameFromPath(
web_ui_.get(), base::FilePath("/test/directory")));
EXPECT_EQ("Sub Folder",
scanning_paths_provider_.GetBaseNameFromPath(
web_ui_.get(), my_files_path.Append("Sub Folder")));
EXPECT_EQ("My files", scanning_paths_provider_.GetBaseNameFromPath(
web_ui_.get(), my_files_path));
}
} // namespace chromeos.
......@@ -164,6 +164,7 @@
#include "chrome/browser/chromeos/printing/print_management/printing_manager_factory.h"
#include "chrome/browser/chromeos/scanning/scan_service.h"
#include "chrome/browser/chromeos/scanning/scan_service_factory.h"
#include "chrome/browser/chromeos/scanning/scanning_paths_provider_impl.h"
#include "chrome/browser/chromeos/secure_channel/secure_channel_client_provider.h"
#include "chrome/browser/chromeos/web_applications/chrome_camera_app_ui_delegate.h"
#include "chrome/browser/chromeos/web_applications/chrome_help_app_ui_delegate.h"
......@@ -411,7 +412,8 @@ WebUIController* NewWebUI<chromeos::ScanningUI>(WebUI* web_ui,
const GURL& url) {
return new chromeos::ScanningUI(
web_ui, base::BindRepeating(&BindScanService, Profile::FromWebUI(web_ui)),
base::BindRepeating(&CreateChromeSelectFilePolicy));
base::BindRepeating(&CreateChromeSelectFilePolicy),
std::make_unique<chromeos::ScanningPathsProviderImpl>());
}
void BindMultiDeviceSetup(
......
......@@ -519,6 +519,9 @@ Try tapping the mic to ask me anything.
<message name="IDS_SCANNING_APP_SCAN_BUTTON_TEXT" desc="The text displayed for the button that starts a scan.">
Scan
</message>
<message name="IDS_SCANNING_APP_MY_DRIVE" desc="The text displayed in the Scan To dropdown when the user selects to save completed scans to their Google Drive 'My Drive' folder.">
My Drive
</message>
<!-- Diagnostics App -->
<!-- TODO(michaelcheco): Update with finalized copies of the strings -->
......
2b0f6f3e07e076a0c5a6aeab918df74a22a91d61
\ No newline at end of file
......@@ -10,6 +10,7 @@ static_library("scanning") {
sources = [
"scanning_handler.cc",
"scanning_handler.h",
"scanning_paths_provider.h",
"scanning_ui.cc",
"scanning_ui.h",
"url_constants.cc",
......
......@@ -4,7 +4,9 @@
#include "chromeos/components/scanning/scanning_handler.h"
#include "base/strings/string16.h"
#include "base/values.h"
#include "chromeos/components/scanning/scanning_paths_provider.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -16,23 +18,15 @@ namespace {
constexpr char kBaseName[] = "baseName";
constexpr char kFilePath[] = "filePath";
// Uses the full filepath and the base directory (lowest level directory in the
// filepath, used to display in the UI) to create a Value object to return to
// the Scanning UI.
base::Value CreateSelectedPathValue(const base::FilePath& path) {
base::Value selected_path(base::Value::Type::DICTIONARY);
selected_path.SetStringKey(kBaseName, path.BaseName().value());
selected_path.SetStringKey(kFilePath, path.value());
return selected_path;
}
} // namespace
namespace chromeos {
ScanningHandler::ScanningHandler(
const SelectFilePolicyCreator& select_file_policy_creator)
: select_file_policy_creator_(select_file_policy_creator) {}
const SelectFilePolicyCreator& select_file_policy_creator,
std::unique_ptr<ScanningPathsProvider> scanning_paths_provider)
: select_file_policy_creator_(select_file_policy_creator),
scanning_paths_provider_(std::move(scanning_paths_provider)) {}
ScanningHandler::~ScanningHandler() = default;
......@@ -87,6 +81,18 @@ void ScanningHandler::FileSelectionCanceled(void* params) {
}
}
// Uses the full filepath and the base directory (lowest level directory in the
// filepath, used to display in the UI) to create a Value object to return to
// the Scanning UI.
base::Value ScanningHandler::CreateSelectedPathValue(
const base::FilePath& path) {
base::Value selected_path(base::Value::Type::DICTIONARY);
selected_path.SetStringKey(kFilePath, path.value());
selected_path.SetStringKey(
kBaseName, scanning_paths_provider_->GetBaseNameFromPath(web_ui(), path));
return selected_path;
}
void ScanningHandler::SetWebUIForTest(content::WebUI* web_ui) {
set_web_ui(web_ui);
}
......
......@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_refptr.h"
#include "base/values.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_policy.h"
......@@ -25,6 +26,8 @@ class WebContents;
namespace chromeos {
class ScanningPathsProvider;
// ChromeOS Scanning app UI handler.
class ScanningHandler : public content::WebUIMessageHandler,
public ui::SelectFileDialog::Listener {
......@@ -33,8 +36,9 @@ class ScanningHandler : public content::WebUIMessageHandler,
base::RepeatingCallback<std::unique_ptr<ui::SelectFilePolicy>(
content::WebContents*)>;
explicit ScanningHandler(
const SelectFilePolicyCreator& select_file_policy_creator);
ScanningHandler(
const SelectFilePolicyCreator& select_file_policy_creator,
std::unique_ptr<ScanningPathsProvider> scanning_paths_provider);
~ScanningHandler() override;
ScanningHandler(const ScanningHandler&) = delete;
......@@ -49,6 +53,8 @@ class ScanningHandler : public content::WebUIMessageHandler,
void* params) override;
void FileSelectionCanceled(void* params) override;
base::Value CreateSelectedPathValue(const base::FilePath& path);
void SetWebUIForTest(content::WebUI* web_ui);
private:
......@@ -64,6 +70,9 @@ class ScanningHandler : public content::WebUIMessageHandler,
std::string scan_location_callback_id_;
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
// Provides FilePath util for converting a FilePath base name.
std::unique_ptr<ScanningPathsProvider> scanning_paths_provider_;
};
} // namespace chromeos
......
......@@ -11,7 +11,9 @@
#include "base/files/file_path.h"
#include "base/strings/string16.h"
#include "base/values.h"
#include "chromeos/components/scanning/scanning_paths_provider.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -20,12 +22,6 @@
#include "ui/shell_dialogs/select_file_dialog_factory.h"
#include "ui/shell_dialogs/select_file_policy.h"
namespace {
constexpr char kTestDirectory[] = "/this/is/a/test/directory/Base Name";
} // namespace
namespace chromeos {
class TestSelectFilePolicy : public ui::SelectFilePolicy {
......@@ -41,17 +37,17 @@ std::unique_ptr<ui::SelectFilePolicy> CreateTestSelectFilePolicy(
return std::make_unique<TestSelectFilePolicy>();
}
// A fake ui::SelectFileDialog.
class FakeSelectFileDialog : public ui::SelectFileDialog {
// A test ui::SelectFileDialog.
class TestSelectFileDialog : public ui::SelectFileDialog {
public:
FakeSelectFileDialog(Listener* listener,
TestSelectFileDialog(Listener* listener,
std::unique_ptr<ui::SelectFilePolicy> policy,
bool is_cancel)
base::FilePath selected_path)
: ui::SelectFileDialog(listener, std::move(policy)),
is_cancel_(is_cancel) {}
selected_path_(selected_path) {}
FakeSelectFileDialog(const FakeSelectFileDialog&) = delete;
FakeSelectFileDialog& operator=(const FakeSelectFileDialog&) = delete;
TestSelectFileDialog(const TestSelectFileDialog&) = delete;
TestSelectFileDialog& operator=(const TestSelectFileDialog&) = delete;
protected:
void SelectFileImpl(Type type,
......@@ -62,13 +58,13 @@ class FakeSelectFileDialog : public ui::SelectFileDialog {
const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window,
void* params) override {
if (is_cancel_) {
if (selected_path_.empty()) {
listener_->FileSelectionCanceled(params);
return;
}
const base::FilePath file_path(FILE_PATH_LITERAL(kTestDirectory));
listener_->FileSelected(file_path, 0 /* index */, nullptr /* params */);
listener_->FileSelected(selected_path_, 0 /* index */,
nullptr /* params */);
}
bool IsRunning(gfx::NativeWindow owning_window) const override {
......@@ -78,22 +74,23 @@ class FakeSelectFileDialog : public ui::SelectFileDialog {
bool HasMultipleFileTypeChoicesImpl() override { return false; }
private:
~FakeSelectFileDialog() override = default;
~TestSelectFileDialog() override = default;
// Determines if directory is chosen or dialog is canceled.
bool is_cancel_;
// The simulatd file path selected by the user.
base::FilePath selected_path_;
};
// A factory associated with the artificial file picker.
class TestSelectFileDialogFactory : public ui::SelectFileDialogFactory {
public:
explicit TestSelectFileDialogFactory(bool is_cancel)
: is_cancel_(is_cancel) {}
explicit TestSelectFileDialogFactory(base::FilePath selected_path)
: selected_path_(selected_path) {}
ui::SelectFileDialog* Create(
ui::SelectFileDialog::Listener* listener,
std::unique_ptr<ui::SelectFilePolicy> policy) override {
return new FakeSelectFileDialog(listener, std::move(policy), is_cancel_);
return new TestSelectFileDialog(listener, std::move(policy),
selected_path_);
}
TestSelectFileDialogFactory(const TestSelectFileDialogFactory&) = delete;
......@@ -101,8 +98,23 @@ class TestSelectFileDialogFactory : public ui::SelectFileDialogFactory {
delete;
private:
// Determines if directory is chosen or dialog is canceled.
bool is_cancel_;
// The simulated file path selected by the user.
base::FilePath selected_path_;
};
// A test impl of ScanningPathsProvider.
class TestScanningPathsProvider : public ScanningPathsProvider {
public:
TestScanningPathsProvider() = default;
TestScanningPathsProvider(const TestScanningPathsProvider&) = delete;
TestScanningPathsProvider& operator=(const TestScanningPathsProvider&) =
delete;
std::string GetBaseNameFromPath(content::WebUI* web_ui,
const base::FilePath& path) override {
return path.BaseName().value();
}
};
class ScanningHandlerTest : public testing::Test {
......@@ -115,7 +127,8 @@ class ScanningHandlerTest : public testing::Test {
void SetUp() override {
scanning_handler_ = std::make_unique<ScanningHandler>(
base::BindRepeating(&CreateTestSelectFilePolicy));
base::BindRepeating(&CreateTestSelectFilePolicy),
std::make_unique<chromeos::TestScanningPathsProvider>());
scanning_handler_->SetWebUIForTest(&web_ui_);
scanning_handler_->RegisterMessages();
......@@ -139,8 +152,9 @@ class ScanningHandlerTest : public testing::Test {
// select dialog, and if a directory is chosen, returns the selected file path
// and base name.
TEST_F(ScanningHandlerTest, SelectDirectory) {
const base::FilePath base_file_path("/this/is/a/test/directory/Base Name");
ui::SelectFileDialog::SetFactory(
new TestSelectFileDialogFactory(false /* is_cancel */));
new TestSelectFileDialogFactory(base_file_path));
const size_t call_data_count_before_call = web_ui_.call_data().size();
base::ListValue args;
......@@ -156,7 +170,8 @@ TEST_F(ScanningHandlerTest, SelectDirectory) {
const base::DictionaryValue* selected_path_dict;
EXPECT_TRUE(call_data.arg3()->GetAsDictionary(&selected_path_dict));
EXPECT_EQ(kTestDirectory, *selected_path_dict->FindStringPath("filePath"));
EXPECT_EQ(base_file_path.value(),
*selected_path_dict->FindStringPath("filePath"));
EXPECT_EQ("Base Name", *selected_path_dict->FindStringPath("baseName"));
}
......@@ -165,7 +180,7 @@ TEST_F(ScanningHandlerTest, SelectDirectory) {
// base name.
TEST_F(ScanningHandlerTest, CancelDialog) {
ui::SelectFileDialog::SetFactory(
new TestSelectFileDialogFactory(true /* is_cancel */));
new TestSelectFileDialogFactory(base::FilePath()));
const size_t call_data_count_before_call = web_ui_.call_data().size();
base::ListValue args;
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_COMPONENTS_SCANNING_SCANNING_PATHS_PROVIDER_H_
#define CHROMEOS_COMPONENTS_SCANNING_SCANNING_PATHS_PROVIDER_H_
#include <string>
#include "base/files/file_path.h"
namespace content {
class WebUI;
} // namespace content
namespace chromeos {
// An interface that provides the Scanning app with FilePath utils.
class ScanningPathsProvider {
public:
virtual ~ScanningPathsProvider() = default;
// Gets the display name to use in the Scan To dropdown. Checks if |path| is
// either the Google Drive root or MyFiles directory and converts it to the
// desired display name.
virtual std::string GetBaseNameFromPath(content::WebUI* web_ui,
const base::FilePath& path) = 0;
};
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_SCANNING_SCANNING_PATHS_PROVIDER_H_
......@@ -6,10 +6,12 @@
#include <memory>
#include <string>
#include <utility>
#include "base/containers/span.h"
#include "base/memory/ptr_util.h"
#include "chromeos/components/scanning/mojom/scanning.mojom.h"
#include "chromeos/components/scanning/scanning_paths_provider.h"
#include "chromeos/components/scanning/url_constants.h"
#include "chromeos/grit/chromeos_scanning_app_resources.h"
#include "chromeos/grit/chromeos_scanning_app_resources_map.h"
......@@ -79,7 +81,8 @@ void AddScanningAppStrings(content::WebUIDataSource* html_source) {
ScanningUI::ScanningUI(
content::WebUI* web_ui,
BindScanServiceCallback callback,
const ScanningHandler::SelectFilePolicyCreator& select_file_policy_creator)
const ScanningHandler::SelectFilePolicyCreator& select_file_policy_creator,
std::unique_ptr<ScanningPathsProvider> scanning_paths_provider)
: ui::MojoWebUIController(web_ui, true /* enable_chrome_send */),
bind_pending_receiver_callback_(std::move(callback)) {
auto html_source = base::WrapUnique(
......@@ -101,8 +104,8 @@ ScanningUI::ScanningUI(
AddScanningAppStrings(html_source.get());
web_ui->AddMessageHandler(
std::make_unique<ScanningHandler>(select_file_policy_creator));
web_ui->AddMessageHandler(std::make_unique<ScanningHandler>(
select_file_policy_creator, std::move(scanning_paths_provider)));
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
html_source.release());
}
......
......@@ -5,6 +5,8 @@
#ifndef CHROMEOS_COMPONENTS_SCANNING_SCANNING_UI_H_
#define CHROMEOS_COMPONENTS_SCANNING_SCANNING_UI_H_
#include <memory>
#include "base/callback.h"
#include "chromeos/components/scanning/mojom/scanning.mojom-forward.h"
#include "chromeos/components/scanning/scanning_handler.h"
......@@ -17,6 +19,8 @@ class WebUI;
namespace chromeos {
class ScanningPathsProvider;
// The WebUI for chrome://scanning.
class ScanningUI : public ui::MojoWebUIController {
public:
......@@ -28,7 +32,8 @@ class ScanningUI : public ui::MojoWebUIController {
ScanningUI(content::WebUI* web_ui,
BindScanServiceCallback callback,
const ScanningHandler::SelectFilePolicyCreator&
select_file_policy_creator);
select_file_policy_creator,
std::unique_ptr<ScanningPathsProvider> scanning_paths_provider);
~ScanningUI() override;
ScanningUI(const ScanningUI&) = delete;
......
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