Skip to content

Commit

Permalink
Migrate //ash/services/ime to namespace ash [3/3]
Browse files Browse the repository at this point in the history
This CL changes namespace of remaining files to ash from chromeos.

This CL is part of the Chrome OS source code directory migration:
https://docs.google.com/document/d/1g-98HpzA8XcoGBWUv1gQNr4rbnD5yfvbtYZyPDDbkaE

Change-Id: Ieaa777481060cc65bfdfaf8db2eec8334d010b33
Bug: 1164001
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3482856
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Owners-Override: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Yeunjoo Choi <ychoi@igalia.com>
Cr-Commit-Position: refs/heads/main@{#978203}
  • Loading branch information
duswnchl authored and Chromium LUCI CQ committed Mar 7, 2022
1 parent 1f8f2b4 commit 601a25a
Show file tree
Hide file tree
Showing 27 changed files with 93 additions and 171 deletions.
7 changes: 2 additions & 5 deletions ash/services/ime/associated_rule_based_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"

namespace chromeos {
namespace ash {
namespace ime {

namespace {

// TODO(https://crbug.com/1164001): remove after migrating to ash.
namespace mojom = ::ash::ime::mojom;

std::u16string ConvertToUtf16AndNormalize(const std::string& str) {
// TODO(https://crbug.com/1185629): Add a new helper in
// base/i18n/icu_string_conversions.h that does the conversion directly
Expand Down Expand Up @@ -182,4 +179,4 @@ AssociatedRuleBasedEngine::AssociatedRuleBasedEngine(
}

} // namespace ime
} // namespace chromeos
} // namespace ash
31 changes: 15 additions & 16 deletions ash/services/ime/associated_rule_based_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"

namespace chromeos {
namespace ash {
namespace ime {

// Handles rule-based input methods such as Arabic and Vietnamese.
// Rule-based input methods are based off deterministic rules and do not
// provide features such as suggestions.
class AssociatedRuleBasedEngine : public InputEngine,
public ash::ime::mojom::InputMethod {
public mojom::InputMethod {
public:
// Returns nullptr if |ime_spec| is not valid for this RuleBasedEngine.
static std::unique_ptr<AssociatedRuleBasedEngine> Create(
const std::string& ime_spec,
mojo::PendingAssociatedReceiver<ash::ime::mojom::InputMethod> receiver,
mojo::PendingAssociatedRemote<ash::ime::mojom::InputMethodHost> host);
mojo::PendingAssociatedReceiver<mojom::InputMethod> receiver,
mojo::PendingAssociatedRemote<mojom::InputMethodHost> host);

AssociatedRuleBasedEngine(const AssociatedRuleBasedEngine& other) = delete;
AssociatedRuleBasedEngine& operator=(const AssociatedRuleBasedEngine& other) =
Expand All @@ -41,19 +41,18 @@ class AssociatedRuleBasedEngine : public InputEngine,
// mojom::InputMethod overrides:
// Most of these methods are deliberately empty because rule-based input
// methods do not need to listen to these events.
void OnFocusDeprecated(
ash::ime::mojom::InputFieldInfoPtr input_field_info,
ash::ime::mojom::InputMethodSettingsPtr settings) override {}
void OnFocus(ash::ime::mojom::InputFieldInfoPtr input_field_info,
ash::ime::mojom::InputMethodSettingsPtr settings,
void OnFocusDeprecated(mojom::InputFieldInfoPtr input_field_info,
mojom::InputMethodSettingsPtr settings) override {}
void OnFocus(mojom::InputFieldInfoPtr input_field_info,
mojom::InputMethodSettingsPtr settings,
OnFocusCallback callback) override;
void OnBlur() override {}
void OnSurroundingTextChanged(
const std::string& text,
uint32_t offset,
ash::ime::mojom::SelectionRangePtr selection_range) override {}
mojom::SelectionRangePtr selection_range) override {}
void OnCompositionCanceledBySystem() override;
void ProcessKeyEvent(ash::ime::mojom::PhysicalKeyEventPtr event,
void ProcessKeyEvent(mojom::PhysicalKeyEventPtr event,
ProcessKeyEventCallback callback) override;
void OnCandidateSelected(uint32_t selected_candidate_index) override;

Expand All @@ -62,11 +61,11 @@ class AssociatedRuleBasedEngine : public InputEngine,
private:
AssociatedRuleBasedEngine(
const std::string& ime_spec,
mojo::PendingAssociatedReceiver<ash::ime::mojom::InputMethod> receiver,
mojo::PendingAssociatedRemote<ash::ime::mojom::InputMethodHost> host);
mojo::PendingAssociatedReceiver<mojom::InputMethod> receiver,
mojo::PendingAssociatedRemote<mojom::InputMethodHost> host);

mojo::AssociatedReceiver<ash::ime::mojom::InputMethod> receiver_;
mojo::AssociatedRemote<ash::ime::mojom::InputMethodHost> host_;
mojo::AssociatedReceiver<mojom::InputMethod> receiver_;
mojo::AssociatedRemote<mojom::InputMethodHost> host_;

rulebased::Engine engine_;

Expand All @@ -75,6 +74,6 @@ class AssociatedRuleBasedEngine : public InputEngine,
};

} // namespace ime
} // namespace chromeos
} // namespace ash

#endif // ASH_SERVICES_IME_ASSOCIATED_RULE_BASED_ENGINE_H_
7 changes: 2 additions & 5 deletions ash/services/ime/connection_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

#include <utility>

namespace chromeos {
namespace ash {
namespace ime {

// TODO(https://crbug.com/1164001): remove after migrating to ash.
namespace mojom = ::ash::ime::mojom;

ConnectionFactory::ConnectionFactory(
mojo::PendingReceiver<mojom::ConnectionFactory> pending_receiver)
: receiver_(this, std::move(pending_receiver)) {}
Expand All @@ -35,4 +32,4 @@ bool ConnectionFactory::IsConnected() {
}

} // namespace ime
} // namespace chromeos
} // namespace ash
18 changes: 8 additions & 10 deletions ash/services/ime/connection_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,38 @@
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"

namespace chromeos {
namespace ash {
namespace ime {

// Chromium implementation of ConnectionFactory (as opposed to the sharedlib
// implementation). This impl is used to connect the RuleBasedEngine in the ime
// service to the NativeIME when requested.
class ConnectionFactory : public ash::ime::mojom::ConnectionFactory {
class ConnectionFactory : public mojom::ConnectionFactory {
public:
explicit ConnectionFactory(
mojo::PendingReceiver<ash::ime::mojom::ConnectionFactory>
pending_receiver);
mojo::PendingReceiver<mojom::ConnectionFactory> pending_receiver);
~ConnectionFactory() override;

// chromeos::ime::mojom::ConnectionFactory overrides.
// mojom::ConnectionFactory overrides.
void ConnectToInputMethod(
const std::string& ime_spec,
mojo::PendingAssociatedReceiver<ash::ime::mojom::InputMethod>
pending_input_method,
mojo::PendingAssociatedRemote<ash::ime::mojom::InputMethodHost>
mojo::PendingAssociatedReceiver<mojom::InputMethod> pending_input_method,
mojo::PendingAssociatedRemote<mojom::InputMethodHost>
pending_input_method_host,
ConnectToInputMethodCallback callback) override;

// Is the current connection factory connected to a rule based engine?
bool IsConnected();

private:
mojo::Receiver<ash::ime::mojom::ConnectionFactory> receiver_;
mojo::Receiver<mojom::ConnectionFactory> receiver_;

// This connection factory is only ever used to connect to a rule based
// engine.
std::unique_ptr<AssociatedRuleBasedEngine> rule_based_engine_;
};

} // namespace ime
} // namespace chromeos
} // namespace ash

#endif // ASH_SERVICES_IME_CONNECTION_FACTORY_H_
4 changes: 2 additions & 2 deletions ash/services/ime/constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define FPL FILE_PATH_LITERAL
#define IME_DIR_STRING "input_methods"

namespace chromeos {
namespace ash {
namespace ime {

const base::FilePath::CharType kInputMethodsDirName[] =
Expand All @@ -39,4 +39,4 @@ const base::FilePath::CharType kLanguageDataDirName[] =
const char kGoogleKeyboardDownloadDomain[] = "dl.google.com";

} // namespace ime
} // namespace chromeos
} // namespace ash
8 changes: 1 addition & 7 deletions ash/services/ime/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "base/component_export.h"
#include "base/files/file_path.h"

namespace chromeos {
namespace ash {
namespace ime {

// The path where ChromeOS default input methods is installed, consisting of
Expand All @@ -33,13 +33,7 @@ extern const base::FilePath::CharType kLanguageDataDirName[];
// The domain of Google Keyboard language dictionary download URL.
COMPONENT_EXPORT(ASH_IME_CONSTANTS)
extern const char kGoogleKeyboardDownloadDomain[];
} // namespace ime
} // namespace chromeos

// TODO(https://crbug.com/1164001): remove when moved to ash.
namespace ash {
namespace ime {
using ::chromeos::ime::kBundledInputMethodsDirPath;
} // namespace ime
} // namespace ash

Expand Down
5 changes: 0 additions & 5 deletions ash/services/ime/decoder/decoder_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,4 @@ class DecoderEngine : public mojom::InputChannel {
} // namespace ime
} // namespace ash

// TODO(https://crbug.com/1164001): remove when the migration is finished.
namespace chromeos::ime {
using ::ash::ime::DecoderEngine;
}

#endif // ASH_SERVICES_IME_DECODER_DECODER_ENGINE_H_
5 changes: 0 additions & 5 deletions ash/services/ime/decoder/system_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,4 @@ class SystemEngine : public InputEngine {
} // namespace ime
} // namespace ash

// TODO(https://crbug.com/1164001): remove when the migration is finished.
namespace chromeos::ime {
using ::ash::ime::SystemEngine;
}

#endif // ASH_SERVICES_IME_DECODER_SYSTEM_ENGINE_H_
4 changes: 2 additions & 2 deletions ash/services/ime/ime_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/logging.h"
#include "base/no_destructor.h"

namespace chromeos {
namespace ash {
namespace ime {

namespace {
Expand Down Expand Up @@ -120,4 +120,4 @@ ImeDecoderImpl* ImeDecoderImpl::GetInstance() {
}

} // namespace ime
} // namespace chromeos
} // namespace ash
9 changes: 2 additions & 7 deletions ash/services/ime/ime_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/scoped_native_library.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

namespace chromeos {
namespace ash {
namespace ime {

// START: Signatures of "C" API entry points of CrOS 1P IME shared library.
Expand Down Expand Up @@ -103,11 +103,6 @@ class ImeDecoderImpl : public ImeDecoder {
};

} // namespace ime
} // namespace chromeos

// TODO(https://crbug.com/1164001): remove when it moved to ash.
namespace ash::ime {
using ::chromeos::ime::ImeDecoder;
}
} // namespace ash

#endif // ASH_SERVICES_IME_IME_DECODER_H_
4 changes: 2 additions & 2 deletions ash/services/ime/ime_sandbox_hook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using sandbox::syscall_broker::BrokerFilePermission;
using sandbox::syscall_broker::MakeBrokerCommandSet;

namespace chromeos {
namespace ash {
namespace ime {

namespace {
Expand Down Expand Up @@ -83,4 +83,4 @@ bool ImePreSandboxHook(sandbox::policy::SandboxLinux::Options options) {
}

} // namespace ime
} // namespace chromeos
} // namespace ash
4 changes: 2 additions & 2 deletions ash/services/ime/ime_sandbox_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

#include "sandbox/policy/linux/sandbox_linux.h"

namespace chromeos {
namespace ash {
namespace ime {

bool ImePreSandboxHook(sandbox::policy::SandboxLinux::Options options);

} // namespace ime
} // namespace chromeos
} // namespace ash

#endif // ASH_SERVICES_IME_IME_SANDBOX_HOOK_H_
7 changes: 2 additions & 5 deletions ash/services/ime/ime_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
#include "base/task/sequenced_task_runner.h"
#include "mojo/public/c/system/thunks.h"

namespace chromeos {
namespace ash {
namespace ime {

namespace {

// TODO(https://crbug.com/1164001): remove after migrating to ash.
namespace mojom = ::ash::ime::mojom;

enum SimpleDownloadError {
SIMPLE_DOWNLOAD_ERROR_OK = 0,
SIMPLE_DOWNLOAD_ERROR_FAILED = -1,
Expand Down Expand Up @@ -281,4 +278,4 @@ void ImeService::Unused1() {
}

} // namespace ime
} // namespace chromeos
} // namespace ash
Loading

0 comments on commit 601a25a

Please sign in to comment.