| OLD | NEW |
| 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> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 InputMethodEngine::InputMethodEngine() | 113 InputMethodEngine::InputMethodEngine() |
| 114 : current_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 114 : current_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 115 active_(false), | 115 active_(false), |
| 116 context_id_(0), | 116 context_id_(0), |
| 117 next_context_id_(1), | 117 next_context_id_(1), |
| 118 composition_text_(new CompositionText()), | 118 composition_text_(new CompositionText()), |
| 119 composition_cursor_(0), | 119 composition_cursor_(0), |
| 120 candidate_window_(new ui::CandidateWindow()), | 120 candidate_window_(new ui::CandidateWindow()), |
| 121 window_visible_(false), | 121 window_visible_(false), |
| 122 sent_key_event_(NULL) {} | 122 sent_key_event_(NULL), |
| 123 profile_(NULL) { |
| 124 } |
| 123 | 125 |
| 124 InputMethodEngine::~InputMethodEngine() { | 126 InputMethodEngine::~InputMethodEngine() { |
| 125 if (start_time_.ToInternalValue()) | 127 if (start_time_.ToInternalValue()) |
| 126 RecordHistogram("WorkingTime", (end_time_ - start_time_).InSeconds()); | 128 RecordHistogram("WorkingTime", (end_time_ - start_time_).InSeconds()); |
| 127 input_method::InputMethodManager::Get()->RemoveInputMethodExtension(imm_id_); | 129 input_method::InputMethodManager::Get()->RemoveInputMethodExtension(profile_, |
| 130 imm_id_); |
| 128 } | 131 } |
| 129 | 132 |
| 130 void InputMethodEngine::Initialize( | 133 void InputMethodEngine::Initialize( |
| 134 Profile* profile, |
| 131 scoped_ptr<InputMethodEngineInterface::Observer> observer, | 135 scoped_ptr<InputMethodEngineInterface::Observer> observer, |
| 132 const char* engine_name, | 136 const char* engine_name, |
| 133 const char* extension_id, | 137 const char* extension_id, |
| 134 const char* engine_id, | 138 const char* engine_id, |
| 135 const std::vector<std::string>& languages, | 139 const std::vector<std::string>& languages, |
| 136 const std::vector<std::string>& layouts, | 140 const std::vector<std::string>& layouts, |
| 137 const GURL& options_page, | 141 const GURL& options_page, |
| 138 const GURL& input_view) { | 142 const GURL& input_view) { |
| 139 DCHECK(observer) << "Observer must not be null."; | 143 DCHECK(observer) << "Observer must not be null."; |
| 140 | 144 |
| 145 profile_ = profile; |
| 146 |
| 141 // TODO(komatsu): It is probably better to set observer out of Initialize. | 147 // TODO(komatsu): It is probably better to set observer out of Initialize. |
| 142 observer_ = observer.Pass(); | 148 observer_ = observer.Pass(); |
| 143 engine_id_ = engine_id; | 149 engine_id_ = engine_id; |
| 144 extension_id_ = extension_id; | 150 extension_id_ = extension_id; |
| 145 | 151 |
| 146 input_method::InputMethodManager* manager = | 152 input_method::InputMethodManager* manager = |
| 147 input_method::InputMethodManager::Get(); | 153 input_method::InputMethodManager::Get(); |
| 148 ComponentExtensionIMEManager* comp_ext_ime_manager = | 154 ComponentExtensionIMEManager* comp_ext_ime_manager = |
| 149 manager->GetComponentExtensionIMEManager(); | 155 manager->GetComponentExtensionIMEManager(); |
| 150 | 156 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 161 std::string(), // TODO(uekawa): Set short name. | 167 std::string(), // TODO(uekawa): Set short name. |
| 162 layouts, | 168 layouts, |
| 163 languages, | 169 languages, |
| 164 extension_ime_util::IsKeyboardLayoutExtension( | 170 extension_ime_util::IsKeyboardLayoutExtension( |
| 165 imm_id_), // is_login_keyboard | 171 imm_id_), // is_login_keyboard |
| 166 options_page, | 172 options_page, |
| 167 input_view); | 173 input_view); |
| 168 | 174 |
| 169 // TODO(komatsu): It is probably better to call AddInputMethodExtension | 175 // TODO(komatsu): It is probably better to call AddInputMethodExtension |
| 170 // out of Initialize. | 176 // out of Initialize. |
| 171 manager->AddInputMethodExtension(imm_id_, this); | 177 manager->AddInputMethodExtension(profile, imm_id_, this); |
| 172 } | 178 } |
| 173 | 179 |
| 174 const input_method::InputMethodDescriptor& InputMethodEngine::GetDescriptor() | 180 const input_method::InputMethodDescriptor& InputMethodEngine::GetDescriptor() |
| 175 const { | 181 const { |
| 176 return descriptor_; | 182 return descriptor_; |
| 177 } | 183 } |
| 178 | 184 |
| 179 void InputMethodEngine::RecordHistogram(const char* name, int count) { | 185 void InputMethodEngine::RecordHistogram(const char* name, int count) { |
| 180 std::string histo_name = | 186 std::string histo_name = |
| 181 base::StringPrintf("InputMethod.%s.%s", name, engine_id_.c_str()); | 187 base::StringPrintf("InputMethod.%s.%s", name, engine_id_.c_str()); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 // TODO(nona): Implement it. | 679 // TODO(nona): Implement it. |
| 674 break; | 680 break; |
| 675 } | 681 } |
| 676 } | 682 } |
| 677 } | 683 } |
| 678 | 684 |
| 679 // TODO(nona): Support item.children. | 685 // TODO(nona): Support item.children. |
| 680 } | 686 } |
| 681 | 687 |
| 682 } // namespace chromeos | 688 } // namespace chromeos |
| OLD | NEW |