Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Unified Diff: chrome/browser/chromeos/input_method/input_method_engine.cc

Issue 1136463005: Supports multiple profile in Chrome OS IMF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/input_method/input_method_engine.cc
diff --git a/chrome/browser/chromeos/input_method/input_method_engine.cc b/chrome/browser/chromeos/input_method/input_method_engine.cc
index c7d6ed4721f087f7cf886548fa19ae6951715d45..e5475ca5d5c513939de8d3a939a25b335218177c 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine.cc
@@ -17,6 +17,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/candidate_window.h"
@@ -162,7 +163,8 @@ InputMethodEngine::InputMethodEngine()
composition_cursor_(0),
candidate_window_(new ui::CandidateWindow()),
window_visible_(false),
- sent_key_event_(NULL) {
+ sent_key_event_(NULL),
+ profile_(NULL) {
}
InputMethodEngine::~InputMethodEngine() {
@@ -170,12 +172,14 @@ InputMethodEngine::~InputMethodEngine() {
void InputMethodEngine::Initialize(
scoped_ptr<InputMethodEngineInterface::Observer> observer,
- const char* extension_id) {
+ const char* extension_id,
+ Profile* profile) {
DCHECK(observer) << "Observer must not be null.";
// TODO(komatsu): It is probably better to set observer out of Initialize.
observer_ = observer.Pass();
extension_id_ = extension_id;
+ profile_ = profile;
}
const std::string& InputMethodEngine::GetActiveComponentId() const {
@@ -501,6 +505,8 @@ void InputMethodEngine::HideInputView() {
void InputMethodEngine::SetCompositionBounds(
const std::vector<gfx::Rect>& bounds) {
+ if (!CheckProfile())
+ return;
observer_->OnCompositionBoundsChanged(bounds);
}
@@ -517,6 +523,8 @@ void InputMethodEngine::EnableInputView() {
void InputMethodEngine::FocusIn(
const IMEEngineHandlerInterface::InputContext& input_context) {
+ if (!CheckProfile())
+ return;
current_input_type_ = input_context.type;
if (!IsActive() || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
@@ -562,6 +570,8 @@ void InputMethodEngine::FocusIn(
}
void InputMethodEngine::FocusOut() {
+ if (!CheckProfile())
+ return;
if (!IsActive() || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
return;
@@ -573,6 +583,8 @@ void InputMethodEngine::FocusOut() {
}
void InputMethodEngine::Enable(const std::string& component_id) {
+ if (!CheckProfile())
+ return;
DCHECK(!component_id.empty());
active_component_id_ = component_id;
observer_->OnActivate(component_id);
@@ -584,15 +596,21 @@ void InputMethodEngine::Enable(const std::string& component_id) {
}
void InputMethodEngine::Disable() {
+ if (!CheckProfile())
+ return;
active_component_id_.clear();
observer_->OnDeactivated(active_component_id_);
}
void InputMethodEngine::PropertyActivate(const std::string& property_name) {
+ if (!CheckProfile())
+ return;
observer_->OnMenuItemActivated(active_component_id_, property_name);
}
void InputMethodEngine::Reset() {
+ if (!CheckProfile())
+ return;
observer_->OnReset(active_component_id_);
}
@@ -603,6 +621,8 @@ bool InputMethodEngine::IsInterestedInKeyEvent() const {
void InputMethodEngine::ProcessKeyEvent(
const ui::KeyEvent& key_event,
const KeyEventDoneCallback& callback) {
+ if (!CheckProfile())
+ return;
KeyEventDoneCallback* handler = new KeyEventDoneCallback();
*handler = callback;
@@ -624,6 +644,8 @@ void InputMethodEngine::ProcessKeyEvent(
}
void InputMethodEngine::CandidateClicked(uint32 index) {
+ if (!CheckProfile())
+ return;
if (index > candidate_ids_.size()) {
return;
}
@@ -636,12 +658,19 @@ void InputMethodEngine::CandidateClicked(uint32 index) {
void InputMethodEngine::SetSurroundingText(const std::string& text,
uint32 cursor_pos,
uint32 anchor_pos) {
+ if (!CheckProfile())
+ return;
observer_->OnSurroundingTextChanged(active_component_id_,
text,
static_cast<int>(cursor_pos),
static_cast<int>(anchor_pos));
}
+bool InputMethodEngine::CheckProfile() const {
+ Profile* active_profile = ProfileManager::GetActiveUserProfile();
+ return active_profile == profile_ || profile_->IsSameProfile(active_profile);
+}
+
// TODO(uekawa): rename this method to a more reasonable name.
void InputMethodEngine::MenuItemToProperty(
const MenuItem& item,

Powered by Google App Engine
This is Rietveld 408576698