Skip to content

Commit

Permalink
Move InputMethodEngineBase's namespace to chromeos
Browse files Browse the repository at this point in the history
https://crrev.com/c/2212194 moves InputMethodEngineBase to
chromeos/input_method/ making it exclusive to chromeos so
the namespace should move as well.

Using chromeos::InputMethodEngineBase where possible because I will be
move all classes in chromeos/input_method to "chromeos::input_method" if
they are not already in it.

Also remove "#if defined(OS_CHROMEOS)" in InputMethodEngineBase

Change-Id: Ic3ecc32d863d3d141bb6567f858431dc173ed240
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2222050
Reviewed-by: Keith Lee <[email protected]>
Reviewed-by: Darren Shen <[email protected]>
Reviewed-by: Yuichiro Hanada <[email protected]>
Commit-Queue: My Nguyen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#775420}
  • Loading branch information
My Nguyen authored and Commit Bot committed Jun 5, 2020
1 parent e31b930 commit b7bb584
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ class ArcInputMethodManagerService::ArcInputMethodBoundsObserver
};

class ArcInputMethodManagerService::InputMethodEngineObserver
: public input_method::InputMethodEngineBase::Observer {
: public chromeos::InputMethodEngineBase::Observer {
public:
explicit InputMethodEngineObserver(ArcInputMethodManagerService* owner)
: owner_(owner) {}
~InputMethodEngineObserver() override = default;

// input_method::InputMethodEngineBase::Observer overrides:
// chromeos::InputMethodEngineBase::Observer overrides:
void OnActivate(const std::string& engine_id) override {
owner_->is_arc_ime_active_ = true;
// TODO(yhanada): Remove this line after we migrate to SPM completely.
Expand All @@ -151,7 +151,7 @@ class ArcInputMethodManagerService::InputMethodEngineObserver
void OnBlur(int context_id) override { owner_->Blur(); }
void OnKeyEvent(
const std::string& engine_id,
const input_method::InputMethodEngineBase::KeyboardEvent& event,
const chromeos::InputMethodEngineBase::KeyboardEvent& event,
ui::IMEEngineHandlerInterface::KeyEventDoneCallback key_data) override {
if (event.key_code == ui::VKEY_BROWSER_BACK &&
owner_->IsVirtualKeyboardShown()) {
Expand Down Expand Up @@ -184,7 +184,7 @@ class ArcInputMethodManagerService::InputMethodEngineObserver
void OnCandidateClicked(
const std::string& component_id,
int candidate_id,
input_method::InputMethodEngineBase::MouseButtonEvent button) override {}
chromeos::InputMethodEngineBase::MouseButtonEvent button) override {}
void OnMenuItemActivated(const std::string& component_id,
const std::string& menu_id) override {}
void OnScreenProjectionChanged(bool is_projected) override {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void InputConnectionImpl::SetComposingText(
if (!ime_engine_->SetComposition(
input_context_id_, base::UTF16ToUTF8(text).c_str(), selection_start,
selection_end, new_cursor_pos,
std::vector<input_method::InputMethodEngineBase::SegmentInfo>(),
std::vector<chromeos::InputMethodEngineBase::SegmentInfo>(),
&error)) {
LOG(ERROR) << "SetComposingText failed: pos=" << new_cursor_pos
<< ", error=\"" << error << "\"";
Expand Down Expand Up @@ -293,14 +293,13 @@ void InputConnectionImpl::SetCompositionRange(

const int before = selection_range.start() - new_composition_range.start();
const int after = new_composition_range.end() - selection_range.end();
input_method::InputMethodEngineBase::SegmentInfo segment_info;
chromeos::InputMethodEngineBase::SegmentInfo segment_info;
segment_info.start = 0;
segment_info.end = new_composition_range.length();
segment_info.style =
input_method::InputMethodEngineBase::SEGMENT_STYLE_UNDERLINE;
segment_info.style = chromeos::InputMethodEngineBase::SEGMENT_STYLE_UNDERLINE;

std::string error;
if (!ime_engine_->input_method::InputMethodEngineBase::SetCompositionRange(
if (!ime_engine_->chromeos::InputMethodEngineBase::SetCompositionRange(
input_context_id_, before, after, {segment_info}, &error)) {
LOG(ERROR) << "SetCompositionRange failed: range="
<< new_composition_range.ToString() << ", error=\"" << error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace arc {
namespace {

class DummyInputMethodEngineObserver
: public input_method::InputMethodEngineBase::Observer {
: public chromeos::InputMethodEngineBase::Observer {
public:
DummyInputMethodEngineObserver() = default;
~DummyInputMethodEngineObserver() override = default;
Expand All @@ -32,7 +32,7 @@ class DummyInputMethodEngineObserver
void OnBlur(int context_id) override {}
void OnKeyEvent(
const std::string& engine_id,
const input_method::InputMethodEngineBase::KeyboardEvent& event,
const chromeos::InputMethodEngineBase::KeyboardEvent& event,
ui::IMEEngineHandlerInterface::KeyEventDoneCallback key_data) override {}
void OnReset(const std::string& engine_id) override {}
void OnDeactivated(const std::string& engine_id) override {}
Expand All @@ -48,7 +48,7 @@ class DummyInputMethodEngineObserver
void OnCandidateClicked(
const std::string& component_id,
int candidate_id,
input_method::InputMethodEngineBase::MouseButtonEvent button) override {}
chromeos::InputMethodEngineBase::MouseButtonEvent button) override {}
void OnMenuItemActivated(const std::string& component_id,
const std::string& menu_id) override {}
void OnScreenProjectionChanged(bool is_projected) override {}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/extensions/input_method_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace SetSelectionRange =
namespace OnSettingsChanged =
extensions::api::input_method_private::OnSettingsChanged;

using input_method::InputMethodEngineBase;
using chromeos::InputMethodEngineBase;

namespace {

Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/chromeos/input_method/assistive_suggester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"

using input_method::InputMethodEngineBase;

namespace chromeos {

namespace {
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/input_method/assistive_suggester.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class AssistiveSuggester {

// Called when the user pressed a key.
// Returns true if suggester handles the event and it should stop propagate.
bool OnKeyEvent(
const ::input_method::InputMethodEngineBase::KeyboardEvent& event);
bool OnKeyEvent(const InputMethodEngineBase::KeyboardEvent& event);

private:
// Returns if any suggestion text should be displayed according to the
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/chromeos/input_method/emoji_suggester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include "base/task/thread_pool.h"
#include "chromeos/services/ime/constants.h"

using input_method::InputMethodEngineBase;

namespace chromeos {

namespace {
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/input_method/emoji_suggester.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class EmojiSuggester : public Suggester {
void OnFocus(int context_id) override;
void OnBlur() override;
SuggestionStatus HandleKeyEvent(
const ::input_method::InputMethodEngineBase::KeyboardEvent& event)
override;
const InputMethodEngineBase::KeyboardEvent& event) override;
bool Suggest(const base::string16& text) override;
void DismissSuggestion() override;
AssistiveType GetProposeActionType() override;
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/chromeos/input_method/input_method_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"

using input_method::InputMethodEngineBase;

namespace chromeos {

namespace {
Expand Down
9 changes: 3 additions & 6 deletions chrome/browser/chromeos/input_method/input_method_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ struct InputMethodMenuItem;
} // namespace ime
} // namespace ui

namespace input_method {
class InputMethodEngineBase;
} // namespace input_method

namespace chromeos {

struct AssistiveWindowProperties;

class InputMethodEngine : public ::input_method::InputMethodEngineBase,
class InputMethodEngine : public InputMethodEngineBase,
public SuggestionHandlerInterface {
public:
enum {
Expand Down Expand Up @@ -170,7 +167,7 @@ class InputMethodEngine : public ::input_method::InputMethodEngineBase,
bool IsValidKeyEvent(const ui::KeyEvent* ui_event) override;

private:
// input_method::InputMethodEngineBase:
// InputMethodEngineBase:
void UpdateComposition(const ui::CompositionText& composition_text,
uint32_t cursor_pos,
bool is_visible) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"

namespace input_method {
namespace chromeos {

namespace {

Expand Down Expand Up @@ -587,4 +587,4 @@ void InputMethodEngineBase::ConfirmCompositionText(bool reset_engine,
input_context->ConfirmCompositionText(reset_engine, keep_selection);
}

} // namespace input_method
} // namespace chromeos
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum class AssistiveWindowType;
} // namespace ime
} // namespace ui

namespace input_method {
namespace chromeos {

class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface {
public:
Expand Down Expand Up @@ -62,13 +62,11 @@ class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface {
SegmentStyle style;
};

#if defined(OS_CHROMEOS)
enum MouseButtonEvent {
MOUSE_BUTTON_LEFT,
MOUSE_BUTTON_RIGHT,
MOUSE_BUTTON_MIDDLE,
};
#endif

class Observer {
public:
Expand Down Expand Up @@ -107,8 +105,6 @@ class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface {
int anchor_pos,
int offset_pos) = 0;

#if defined(OS_CHROMEOS)

// Called when an InputContext's properties change while it is focused.
virtual void OnInputContextUpdate(
const IMEEngineHandlerInterface::InputContext& context) = 0;
Expand All @@ -129,7 +125,6 @@ class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface {
const std::string& menu_id) = 0;

virtual void OnScreenProjectionChanged(bool is_projected) = 0;
#endif // defined(OS_CHROMEOS)
};

InputMethodEngineBase();
Expand Down Expand Up @@ -323,6 +318,6 @@ class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface {
ui::KeyEvent ConvertKeyboardEventToUIKeyEvent(const KeyboardEvent& event);
};

} // namespace input_method
} // namespace chromeos

#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_BASE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/rect.h"

using input_method::InputMethodEngineBase;

namespace chromeos {

namespace input_method {
Expand Down Expand Up @@ -341,29 +339,29 @@ TEST_F(InputMethodEngineTest, TestSetSelectionRange) {
CreateEngine(true);
const int context = engine_->GetContextIdForTesting();
std::string error;
engine_->::input_method::InputMethodEngineBase::SetSelectionRange(
engine_->chromeos::InputMethodEngineBase::SetSelectionRange(
context, /* start */ 0, /* end */ 0, &error);
EXPECT_EQ(kErrorNotActive, error);
EXPECT_EQ(0,
mock_ime_input_context_handler_->set_selection_range_call_count());
error = "";

engine_->Enable(kTestImeComponentId);
engine_->::input_method::InputMethodEngineBase::SetSelectionRange(
engine_->chromeos::InputMethodEngineBase::SetSelectionRange(
context, /* start */ 0, /* end */ 0, &error);
EXPECT_EQ("", error);
EXPECT_EQ(1,
mock_ime_input_context_handler_->set_selection_range_call_count());
error = "";

engine_->::input_method::InputMethodEngineBase::SetSelectionRange(
engine_->chromeos::InputMethodEngineBase::SetSelectionRange(
context, /* start */ -1, /* end */ 0, &error);
EXPECT_EQ(base::StringPrintf(kErrorInvalidValue, "start", -1), error);
EXPECT_EQ(1,
mock_ime_input_context_handler_->set_selection_range_call_count());
error = "";

engine_->::input_method::InputMethodEngineBase::SetSelectionRange(
engine_->chromeos::InputMethodEngineBase::SetSelectionRange(
context, /* start */ 0, /* end */ -1, &error);
EXPECT_EQ(base::StringPrintf(kErrorInvalidValue, "end", -1), error);
EXPECT_EQ(1,
Expand All @@ -385,8 +383,8 @@ TEST_F(InputMethodEngineTest, TestDisableAfterSetCompositionRange) {
EXPECT_EQ("text", mock_ime_input_context_handler_->last_commit_text());

// Change composition range to include "text".
engine_->::input_method::InputMethodEngineBase::SetCompositionRange(
context, 0, 4, {}, &error);
engine_->chromeos::InputMethodEngineBase::SetCompositionRange(context, 0, 4,
{}, &error);
EXPECT_EQ("", error);

// Disable to commit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"

namespace {
using chromeos::InputMethodEngineBase;

using input_method::InputMethodEngineBase;
namespace {

class TestObserver : public InputMethodEngineBase::Observer {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"

using input_method::InputMethodEngineBase;

namespace chromeos {

namespace {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class PersonalInfoSuggester : public Suggester {
void OnFocus(int context_id) override;
void OnBlur() override;
SuggestionStatus HandleKeyEvent(
const ::input_method::InputMethodEngineBase::KeyboardEvent& event)
override;
const InputMethodEngineBase::KeyboardEvent& event) override;
bool Suggest(const base::string16& text) override;
void DismissSuggestion() override;
AssistiveType GetProposeActionType() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class PersonalInfoSuggesterTest : public testing::Test {
}

void SendKeyboardEvent(std::string key) {
::input_method::InputMethodEngineBase::KeyboardEvent event;
InputMethodEngineBase::KeyboardEvent event;
event.key = key;
suggester_->HandleKeyEvent(event);
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/input_method/suggester.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Suggester {
// Called when suggestion is being shown.
// Returns SuggestionStatus as suggester handles the event.
virtual SuggestionStatus HandleKeyEvent(
const ::input_method::InputMethodEngineBase::KeyboardEvent& event) = 0;
const InputMethodEngineBase::KeyboardEvent& event) = 0;

// Check if suggestion should be displayed according to the surrounding text
// information.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/api/input_ime/input_ime_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled;
namespace SetComposition = extensions::api::input_ime::SetComposition;
namespace CommitText = extensions::api::input_ime::CommitText;
namespace SendKeyEvents = extensions::api::input_ime::SendKeyEvents;
using input_method::InputMethodEngineBase;
using chromeos::InputMethodEngineBase;

namespace {
const char kErrorRouterNotAvailable[] = "The router is not available.";
Expand Down
8 changes: 5 additions & 3 deletions chrome/browser/extensions/api/input_ime/input_ime_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,21 @@ class Profile;
namespace ui {
class IMEEngineHandlerInterface;

class ImeObserver : public input_method::InputMethodEngineBase::Observer {
using chromeos::InputMethodEngineBase;

class ImeObserver : public InputMethodEngineBase::Observer {
public:
ImeObserver(const std::string& extension_id, Profile* profile);

~ImeObserver() override = default;

// input_method::InputMethodEngineBase::Observer overrides.
// InputMethodEngineBase::Observer overrides.
void OnActivate(const std::string& component_id) override;
void OnFocus(const IMEEngineHandlerInterface::InputContext& context) override;
void OnBlur(int context_id) override;
void OnKeyEvent(
const std::string& component_id,
const input_method::InputMethodEngineBase::KeyboardEvent& event,
const InputMethodEngineBase::KeyboardEvent& event,
IMEEngineHandlerInterface::KeyEventDoneCallback key_data) override;
void OnReset(const std::string& component_id) override;
void OnDeactivated(const std::string& component_id) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ namespace SetSelectionRange =
extensions::api::input_method_private::SetSelectionRange;
namespace FinishComposingText =
extensions::api::input_method_private::FinishComposingText;
using ui::IMEEngineHandlerInterface;
using input_method::InputMethodEngineBase;
using chromeos::InputMethodEngine;
using chromeos::InputMethodEngineBase;
using ui::IMEEngineHandlerInterface;

namespace {
const char kErrorEngineNotAvailable[] = "The engine is not available.";
Expand Down Expand Up @@ -141,7 +141,7 @@ class ImeObserverChromeOS : public ui::ImeObserver {

~ImeObserverChromeOS() override = default;

// input_method::InputMethodEngineBase::Observer overrides.
// chromeos::InputMethodEngineBase::Observer overrides.
void OnInputContextUpdate(
const IMEEngineHandlerInterface::InputContext& context) override {
if (extension_id_.empty() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class InputImeEventRouter : public InputImeEventRouterBase {
void UnregisterAllImes(const std::string& extension_id);

chromeos::InputMethodEngine* GetEngine(const std::string& extension_id);
input_method::InputMethodEngineBase* GetEngineIfActive(
chromeos::InputMethodEngineBase* GetEngineIfActive(
const std::string& extension_id,
std::string* error) override;

Expand Down
Loading

0 comments on commit b7bb584

Please sign in to comment.