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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/input_method/input_method_engine.h" 5 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
6 6
7 #undef FocusIn 7 #undef FocusIn
8 #undef FocusOut 8 #undef FocusOut
9 #undef RootWindow 9 #undef RootWindow
10 #include <map> 10 #include <map>
11 11
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "chrome/browser/profiles/profile_manager.h"
20 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
21 #include "ui/aura/window_tree_host.h" 22 #include "ui/aura/window_tree_host.h"
22 #include "ui/base/ime/candidate_window.h" 23 #include "ui/base/ime/candidate_window.h"
23 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" 24 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
24 #include "ui/base/ime/chromeos/composition_text.h" 25 #include "ui/base/ime/chromeos/composition_text.h"
25 #include "ui/base/ime/chromeos/extension_ime_util.h" 26 #include "ui/base/ime/chromeos/extension_ime_util.h"
26 #include "ui/base/ime/chromeos/ime_keymap.h" 27 #include "ui/base/ime/chromeos/ime_keymap.h"
27 #include "ui/base/ime/chromeos/input_method_manager.h" 28 #include "ui/base/ime/chromeos/input_method_manager.h"
28 #include "ui/base/ime/text_input_flags.h" 29 #include "ui/base/ime/text_input_flags.h"
29 #include "ui/chromeos/ime/input_method_menu_item.h" 30 #include "ui/chromeos/ime/input_method_menu_item.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } // namespace 156 } // namespace
156 157
157 InputMethodEngine::InputMethodEngine() 158 InputMethodEngine::InputMethodEngine()
158 : current_input_type_(ui::TEXT_INPUT_TYPE_NONE), 159 : current_input_type_(ui::TEXT_INPUT_TYPE_NONE),
159 context_id_(0), 160 context_id_(0),
160 next_context_id_(1), 161 next_context_id_(1),
161 composition_text_(new CompositionText()), 162 composition_text_(new CompositionText()),
162 composition_cursor_(0), 163 composition_cursor_(0),
163 candidate_window_(new ui::CandidateWindow()), 164 candidate_window_(new ui::CandidateWindow()),
164 window_visible_(false), 165 window_visible_(false),
165 sent_key_event_(NULL) { 166 sent_key_event_(NULL),
167 profile_(NULL) {
166 } 168 }
167 169
168 InputMethodEngine::~InputMethodEngine() { 170 InputMethodEngine::~InputMethodEngine() {
169 } 171 }
170 172
171 void InputMethodEngine::Initialize( 173 void InputMethodEngine::Initialize(
172 scoped_ptr<InputMethodEngineInterface::Observer> observer, 174 scoped_ptr<InputMethodEngineInterface::Observer> observer,
173 const char* extension_id) { 175 const char* extension_id,
176 Profile* profile) {
174 DCHECK(observer) << "Observer must not be null."; 177 DCHECK(observer) << "Observer must not be null.";
175 178
176 // TODO(komatsu): It is probably better to set observer out of Initialize. 179 // TODO(komatsu): It is probably better to set observer out of Initialize.
177 observer_ = observer.Pass(); 180 observer_ = observer.Pass();
178 extension_id_ = extension_id; 181 extension_id_ = extension_id;
182 profile_ = profile;
179 } 183 }
180 184
181 const std::string& InputMethodEngine::GetActiveComponentId() const { 185 const std::string& InputMethodEngine::GetActiveComponentId() const {
182 return active_component_id_; 186 return active_component_id_;
183 } 187 }
184 188
185 bool InputMethodEngine::SetComposition( 189 bool InputMethodEngine::SetComposition(
186 int context_id, 190 int context_id,
187 const char* text, 191 const char* text,
188 int selection_start, 192 int selection_start,
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 return; 570 return;
567 571
568 current_input_type_ = ui::TEXT_INPUT_TYPE_NONE; 572 current_input_type_ = ui::TEXT_INPUT_TYPE_NONE;
569 573
570 int context_id = context_id_; 574 int context_id = context_id_;
571 context_id_ = -1; 575 context_id_ = -1;
572 observer_->OnBlur(context_id); 576 observer_->OnBlur(context_id);
573 } 577 }
574 578
575 void InputMethodEngine::Enable(const std::string& component_id) { 579 void InputMethodEngine::Enable(const std::string& component_id) {
580 if (!ProfileManager::GetActiveUserProfile()->IsSameProfile(profile_))
581 return;
576 DCHECK(!component_id.empty()); 582 DCHECK(!component_id.empty());
577 active_component_id_ = component_id; 583 active_component_id_ = component_id;
578 observer_->OnActivate(component_id); 584 observer_->OnActivate(component_id);
579 const IMEEngineHandlerInterface::InputContext& input_context = 585 const IMEEngineHandlerInterface::InputContext& input_context =
580 IMEBridge::Get()->GetCurrentInputContext(); 586 IMEBridge::Get()->GetCurrentInputContext();
581 current_input_type_ = input_context.type; 587 current_input_type_ = input_context.type;
582 FocusIn(input_context); 588 FocusIn(input_context);
583 EnableInputView(); 589 EnableInputView();
584 } 590 }
585 591
586 void InputMethodEngine::Disable() { 592 void InputMethodEngine::Disable() {
593 if (!ProfileManager::GetActiveUserProfile()->IsSameProfile(profile_))
594 return;
587 active_component_id_.clear(); 595 active_component_id_.clear();
588 observer_->OnDeactivated(active_component_id_); 596 observer_->OnDeactivated(active_component_id_);
589 } 597 }
590 598
591 void InputMethodEngine::PropertyActivate(const std::string& property_name) { 599 void InputMethodEngine::PropertyActivate(const std::string& property_name) {
592 observer_->OnMenuItemActivated(active_component_id_, property_name); 600 observer_->OnMenuItemActivated(active_component_id_, property_name);
593 } 601 }
594 602
595 void InputMethodEngine::Reset() { 603 void InputMethodEngine::Reset() {
596 observer_->OnReset(active_component_id_); 604 observer_->OnReset(active_component_id_);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 // TODO(nona): Implement it. 686 // TODO(nona): Implement it.
679 break; 687 break;
680 } 688 }
681 } 689 }
682 } 690 }
683 691
684 // TODO(nona): Support item.children. 692 // TODO(nona): Support item.children.
685 } 693 }
686 694
687 } // namespace chromeos 695 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698