Commit e319e79f authored by James Cook's avatar James Cook Committed by Commit Bot

Rename SelectFileLacros to SelectFileAsh

Also move it and AshChromeServiceImpl into namespace crosapi.

This is consistent with our plan for interface names from
go/lacros-main-dd.

Bug: none
Change-Id: Ice369bd8da4ebdc9de4de2a69ce7a457ed13968a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2349888
Commit-Queue: James Cook <jamescook@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Auto-Submit: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796960}
parent 4421e3c9
...@@ -927,8 +927,8 @@ source_set("chromeos") { ...@@ -927,8 +927,8 @@ source_set("chromeos") {
"crosapi/browser_util.h", "crosapi/browser_util.h",
"crosapi/screen_manager_crosapi.cc", "crosapi/screen_manager_crosapi.cc",
"crosapi/screen_manager_crosapi.h", "crosapi/screen_manager_crosapi.h",
"crosapi/select_file_crosapi.cc", "crosapi/select_file_ash.cc",
"crosapi/select_file_crosapi.h", "crosapi/select_file_ash.h",
"crostini/ansible/ansible_management_service.cc", "crostini/ansible/ansible_management_service.cc",
"crostini/ansible/ansible_management_service.h", "crostini/ansible/ansible_management_service.h",
"crostini/ansible/ansible_management_service_factory.cc", "crostini/ansible/ansible_management_service_factory.cc",
......
...@@ -3,7 +3,7 @@ specific_include_rules = { ...@@ -3,7 +3,7 @@ specific_include_rules = {
# For window parenting. # For window parenting.
"+ash/shell.h", "+ash/shell.h",
], ],
"select_file_crosapi\.cc": [ "select_file_ash\.cc": [
# For window parenting. # For window parenting.
"+ash/shell.h", "+ash/shell.h",
"+ash/wm/desks/desks_util.h", "+ash/wm/desks/desks_util.h",
......
...@@ -8,12 +8,14 @@ ...@@ -8,12 +8,14 @@
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/chromeos/crosapi/screen_manager_crosapi.h" #include "chrome/browser/chromeos/crosapi/screen_manager_crosapi.h"
#include "chrome/browser/chromeos/crosapi/select_file_crosapi.h" #include "chrome/browser/chromeos/crosapi/select_file_ash.h"
#include "chromeos/crosapi/mojom/screen_manager.mojom.h" #include "chromeos/crosapi/mojom/screen_manager.mojom.h"
#include "chromeos/crosapi/mojom/select_file.mojom.h" #include "chromeos/crosapi/mojom/select_file.mojom.h"
namespace crosapi {
AshChromeServiceImpl::AshChromeServiceImpl( AshChromeServiceImpl::AshChromeServiceImpl(
mojo::PendingReceiver<crosapi::mojom::AshChromeService> pending_receiver) mojo::PendingReceiver<mojom::AshChromeService> pending_receiver)
: receiver_(this, std::move(pending_receiver)), : receiver_(this, std::move(pending_receiver)),
screen_manager_crosapi_(std::make_unique<ScreenManagerCrosapi>()) { screen_manager_crosapi_(std::make_unique<ScreenManagerCrosapi>()) {
// TODO(hidehiko): Remove non-critical log from here. // TODO(hidehiko): Remove non-critical log from here.
...@@ -24,12 +26,13 @@ AshChromeServiceImpl::AshChromeServiceImpl( ...@@ -24,12 +26,13 @@ AshChromeServiceImpl::AshChromeServiceImpl(
AshChromeServiceImpl::~AshChromeServiceImpl() = default; AshChromeServiceImpl::~AshChromeServiceImpl() = default;
void AshChromeServiceImpl::BindSelectFile( void AshChromeServiceImpl::BindSelectFile(
mojo::PendingReceiver<crosapi::mojom::SelectFile> receiver) { mojo::PendingReceiver<mojom::SelectFile> receiver) {
select_file_crosapi_ = select_file_crosapi_ = std::make_unique<SelectFileAsh>(std::move(receiver));
std::make_unique<SelectFileCrosapi>(std::move(receiver));
} }
void AshChromeServiceImpl::BindScreenManager( void AshChromeServiceImpl::BindScreenManager(
mojo::PendingReceiver<crosapi::mojom::ScreenManager> receiver) { mojo::PendingReceiver<mojom::ScreenManager> receiver) {
screen_manager_crosapi_->BindReceiver(std::move(receiver)); screen_manager_crosapi_->BindReceiver(std::move(receiver));
} }
} // namespace crosapi
...@@ -12,27 +12,32 @@ ...@@ -12,27 +12,32 @@
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
class ScreenManagerCrosapi; class ScreenManagerCrosapi;
class SelectFileCrosapi;
namespace crosapi {
class SelectFileAsh;
// Implementation of AshChromeService. It provides a set of APIs that // Implementation of AshChromeService. It provides a set of APIs that
// lacros-chrome can call into. // lacros-chrome can call into.
class AshChromeServiceImpl : public crosapi::mojom::AshChromeService { class AshChromeServiceImpl : public mojom::AshChromeService {
public: public:
explicit AshChromeServiceImpl( explicit AshChromeServiceImpl(
mojo::PendingReceiver<crosapi::mojom::AshChromeService> pending_receiver); mojo::PendingReceiver<mojom::AshChromeService> pending_receiver);
~AshChromeServiceImpl() override; ~AshChromeServiceImpl() override;
// crosapi::mojom::AshChromeService: // crosapi::mojom::AshChromeService:
void BindScreenManager( void BindScreenManager(
mojo::PendingReceiver<crosapi::mojom::ScreenManager> receiver) override; mojo::PendingReceiver<mojom::ScreenManager> receiver) override;
void BindSelectFile( void BindSelectFile(
mojo::PendingReceiver<crosapi::mojom::SelectFile> receiver) override; mojo::PendingReceiver<mojom::SelectFile> receiver) override;
private: private:
mojo::Receiver<crosapi::mojom::AshChromeService> receiver_; mojo::Receiver<mojom::AshChromeService> receiver_;
std::unique_ptr<ScreenManagerCrosapi> screen_manager_crosapi_; std::unique_ptr<ScreenManagerCrosapi> screen_manager_crosapi_;
std::unique_ptr<SelectFileCrosapi> select_file_crosapi_; std::unique_ptr<SelectFileAsh> select_file_crosapi_;
}; };
} // namespace crosapi
#endif // CHROME_BROWSER_CHROMEOS_CROSAPI_ASH_CHROME_SERVICE_IMPL_H_ #endif // CHROME_BROWSER_CHROMEOS_CROSAPI_ASH_CHROME_SERVICE_IMPL_H_
...@@ -20,10 +20,9 @@ namespace component_updater { ...@@ -20,10 +20,9 @@ namespace component_updater {
class CrOSComponentManager; class CrOSComponentManager;
} // namespace component_updater } // namespace component_updater
class AshChromeServiceImpl;
namespace crosapi { namespace crosapi {
class AshChromeServiceImpl;
class BrowserLoader; class BrowserLoader;
// Manages the lifetime of lacros-chrome, and its loading status. This class is // Manages the lifetime of lacros-chrome, and its loading status. This class is
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/crosapi/select_file_crosapi.h" #include "chrome/browser/chromeos/crosapi/select_file_ash.h"
#include <utility> #include <utility>
#include <vector> #include <vector>
...@@ -20,34 +20,34 @@ ...@@ -20,34 +20,34 @@
#include "ui/shell_dialogs/selected_file_info.h" #include "ui/shell_dialogs/selected_file_info.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace crosapi {
namespace { namespace {
ui::SelectFileDialog::Type GetUiType( ui::SelectFileDialog::Type GetUiType(mojom::SelectFileDialogType type) {
crosapi::mojom::SelectFileDialogType type) {
switch (type) { switch (type) {
case crosapi::mojom::SelectFileDialogType::kFolder: case mojom::SelectFileDialogType::kFolder:
return ui::SelectFileDialog::Type::SELECT_FOLDER; return ui::SelectFileDialog::Type::SELECT_FOLDER;
case crosapi::mojom::SelectFileDialogType::kUploadFolder: case mojom::SelectFileDialogType::kUploadFolder:
return ui::SelectFileDialog::Type::SELECT_UPLOAD_FOLDER; return ui::SelectFileDialog::Type::SELECT_UPLOAD_FOLDER;
case crosapi::mojom::SelectFileDialogType::kExistingFolder: case mojom::SelectFileDialogType::kExistingFolder:
return ui::SelectFileDialog::Type::SELECT_EXISTING_FOLDER; return ui::SelectFileDialog::Type::SELECT_EXISTING_FOLDER;
case crosapi::mojom::SelectFileDialogType::kOpenFile: case mojom::SelectFileDialogType::kOpenFile:
return ui::SelectFileDialog::Type::SELECT_OPEN_FILE; return ui::SelectFileDialog::Type::SELECT_OPEN_FILE;
case crosapi::mojom::SelectFileDialogType::kOpenMultiFile: case mojom::SelectFileDialogType::kOpenMultiFile:
return ui::SelectFileDialog::Type::SELECT_OPEN_MULTI_FILE; return ui::SelectFileDialog::Type::SELECT_OPEN_MULTI_FILE;
case crosapi::mojom::SelectFileDialogType::kSaveAsFile: case mojom::SelectFileDialogType::kSaveAsFile:
return ui::SelectFileDialog::Type::SELECT_SAVEAS_FILE; return ui::SelectFileDialog::Type::SELECT_SAVEAS_FILE;
} }
} }
ui::SelectFileDialog::FileTypeInfo::AllowedPaths GetUiAllowedPaths( ui::SelectFileDialog::FileTypeInfo::AllowedPaths GetUiAllowedPaths(
crosapi::mojom::AllowedPaths allowed_paths) { mojom::AllowedPaths allowed_paths) {
switch (allowed_paths) { switch (allowed_paths) {
case crosapi::mojom::AllowedPaths::kAnyPath: case mojom::AllowedPaths::kAnyPath:
return ui::SelectFileDialog::FileTypeInfo::ANY_PATH; return ui::SelectFileDialog::FileTypeInfo::ANY_PATH;
case crosapi::mojom::AllowedPaths::kNativePath: case mojom::AllowedPaths::kNativePath:
return ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH; return ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH;
case crosapi::mojom::AllowedPaths::kAnyPathOrUrl: case mojom::AllowedPaths::kAnyPathOrUrl:
return ui::SelectFileDialog::FileTypeInfo::ANY_PATH_OR_URL; return ui::SelectFileDialog::FileTypeInfo::ANY_PATH_OR_URL;
} }
} }
...@@ -83,8 +83,8 @@ aura::Window* GetShellSurfaceWindow(const std::string& app_id) { ...@@ -83,8 +83,8 @@ aura::Window* GetShellSurfaceWindow(const std::string& app_id) {
class SelectFileDialogHolder : public ui::SelectFileDialog::Listener { class SelectFileDialogHolder : public ui::SelectFileDialog::Listener {
public: public:
SelectFileDialogHolder(aura::Window* shell_surface_window, SelectFileDialogHolder(aura::Window* shell_surface_window,
crosapi::mojom::SelectFileOptionsPtr options, mojom::SelectFileOptionsPtr options,
crosapi::mojom::SelectFile::SelectCallback callback) mojom::SelectFile::SelectCallback callback)
: select_callback_(std::move(callback)) { : select_callback_(std::move(callback)) {
DCHECK(shell_surface_window); DCHECK(shell_surface_window);
// Policy is null because showing the file-dialog-blocked infobar is handled // Policy is null because showing the file-dialog-blocked infobar is handled
...@@ -163,10 +163,9 @@ class SelectFileDialogHolder : public ui::SelectFileDialog::Listener { ...@@ -163,10 +163,9 @@ class SelectFileDialogHolder : public ui::SelectFileDialog::Listener {
// Invokes |select_callback_| with the list of files and deletes this object. // Invokes |select_callback_| with the list of files and deletes this object.
void OnSelected(const std::vector<ui::SelectedFileInfo>& files, void OnSelected(const std::vector<ui::SelectedFileInfo>& files,
int file_type_index) { int file_type_index) {
std::vector<crosapi::mojom::SelectedFileInfoPtr> mojo_files; std::vector<mojom::SelectedFileInfoPtr> mojo_files;
for (const ui::SelectedFileInfo& file : files) { for (const ui::SelectedFileInfo& file : files) {
crosapi::mojom::SelectedFileInfoPtr mojo_file = mojom::SelectedFileInfoPtr mojo_file = mojom::SelectedFileInfo::New();
crosapi::mojom::SelectedFileInfo::New();
mojo_file->file_path = file.file_path; mojo_file->file_path = file.file_path;
mojo_file->local_path = file.local_path; mojo_file->local_path = file.local_path;
mojo_file->display_name = file.display_name; mojo_file->display_name = file.display_name;
...@@ -174,13 +173,13 @@ class SelectFileDialogHolder : public ui::SelectFileDialog::Listener { ...@@ -174,13 +173,13 @@ class SelectFileDialogHolder : public ui::SelectFileDialog::Listener {
mojo_files.push_back(std::move(mojo_file)); mojo_files.push_back(std::move(mojo_file));
} }
std::move(select_callback_) std::move(select_callback_)
.Run(crosapi::mojom::SelectFileResult::kSuccess, std::move(mojo_files), .Run(mojom::SelectFileResult::kSuccess, std::move(mojo_files),
file_type_index); file_type_index);
delete this; delete this;
} }
// Callback run after files are selected or the dialog is canceled. // Callback run after files are selected or the dialog is canceled.
crosapi::mojom::SelectFile::SelectCallback select_callback_; mojom::SelectFile::SelectCallback select_callback_;
// The file select dialog. // The file select dialog.
scoped_refptr<SelectFileDialogExtension> select_file_dialog_; scoped_refptr<SelectFileDialogExtension> select_file_dialog_;
...@@ -192,23 +191,24 @@ class SelectFileDialogHolder : public ui::SelectFileDialog::Listener { ...@@ -192,23 +191,24 @@ class SelectFileDialogHolder : public ui::SelectFileDialog::Listener {
} // namespace } // namespace
// TODO(https://crbug.com/1090587): Connection error handling. // TODO(https://crbug.com/1090587): Connection error handling.
SelectFileCrosapi::SelectFileCrosapi( SelectFileAsh::SelectFileAsh(mojo::PendingReceiver<mojom::SelectFile> receiver)
mojo::PendingReceiver<crosapi::mojom::SelectFile> receiver)
: receiver_(this, std::move(receiver)) {} : receiver_(this, std::move(receiver)) {}
SelectFileCrosapi::~SelectFileCrosapi() = default; SelectFileAsh::~SelectFileAsh() = default;
void SelectFileCrosapi::Select(crosapi::mojom::SelectFileOptionsPtr options, void SelectFileAsh::Select(mojom::SelectFileOptionsPtr options,
SelectCallback callback) { SelectCallback callback) {
aura::Window* shell_surface_window = aura::Window* shell_surface_window =
GetShellSurfaceWindow(options->owning_shell_window_id); GetShellSurfaceWindow(options->owning_shell_window_id);
// Bail out if the shell surface doesn't exist any more. // Bail out if the shell surface doesn't exist any more.
if (!shell_surface_window) { if (!shell_surface_window) {
std::move(callback).Run( std::move(callback).Run(mojom::SelectFileResult::kInvalidShellWindow, {},
crosapi::mojom::SelectFileResult::kInvalidShellWindow, {}, 0); 0);
return; return;
} }
// Deletes itself when the dialog closes. // Deletes itself when the dialog closes.
new SelectFileDialogHolder(shell_surface_window, std::move(options), new SelectFileDialogHolder(shell_surface_window, std::move(options),
std::move(callback)); std::move(callback));
} }
} // namespace crosapi
...@@ -2,30 +2,33 @@ ...@@ -2,30 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_CROSAPI_SELECT_FILE_CROSAPI_H_ #ifndef CHROME_BROWSER_CHROMEOS_CROSAPI_SELECT_FILE_ASH_H_
#define CHROME_BROWSER_CHROMEOS_CROSAPI_SELECT_FILE_CROSAPI_H_ #define CHROME_BROWSER_CHROMEOS_CROSAPI_SELECT_FILE_ASH_H_
#include "chromeos/crosapi/mojom/select_file.mojom.h" #include "chromeos/crosapi/mojom/select_file.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
namespace crosapi {
// Implements the SelectFile mojo interface for open/save dialogs. Wraps the // Implements the SelectFile mojo interface for open/save dialogs. Wraps the
// underlying Chrome OS SelectFileExtension implementation, which uses the WebUI // underlying Chrome OS SelectFileExtension implementation, which uses the WebUI
// file manager to provide the dialogs. Lives on the UI thread. // file manager to provide the dialogs. Lives on the UI thread.
class SelectFileCrosapi : public crosapi::mojom::SelectFile { class SelectFileAsh : public mojom::SelectFile {
public: public:
explicit SelectFileCrosapi( explicit SelectFileAsh(mojo::PendingReceiver<mojom::SelectFile> receiver);
mojo::PendingReceiver<crosapi::mojom::SelectFile> receiver); SelectFileAsh(const SelectFileAsh&) = delete;
SelectFileCrosapi(const SelectFileCrosapi&) = delete; SelectFileAsh& operator=(const SelectFileAsh&) = delete;
SelectFileCrosapi& operator=(const SelectFileCrosapi&) = delete; ~SelectFileAsh() override;
~SelectFileCrosapi() override;
// crosapi::mojom::SelectFile: // crosapi::mojom::SelectFile:
void Select(crosapi::mojom::SelectFileOptionsPtr options, void Select(mojom::SelectFileOptionsPtr options,
SelectCallback callback) override; SelectCallback callback) override;
private: private:
mojo::Receiver<crosapi::mojom::SelectFile> receiver_; mojo::Receiver<mojom::SelectFile> receiver_;
}; };
#endif // CHROME_BROWSER_CHROMEOS_CROSAPI_SELECT_FILE_CROSAPI_H_ } // namespace crosapi
#endif // CHROME_BROWSER_CHROMEOS_CROSAPI_SELECT_FILE_ASH_H_
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