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

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_engine.cc

Issue 119133003: Make InputMethodEngine manage its descriptor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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 #define XK_MISCELLANY 7 #define XK_MISCELLANY
8 #include <X11/keysymdef.h> 8 #include <X11/keysymdef.h>
9 #include <X11/X.h> 9 #include <X11/X.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 active_(false), 58 active_(false),
59 context_id_(0), 59 context_id_(0),
60 next_context_id_(1), 60 next_context_id_(1),
61 observer_(NULL), 61 observer_(NULL),
62 preedit_text_(new IBusText()), 62 preedit_text_(new IBusText()),
63 preedit_cursor_(0), 63 preedit_cursor_(0),
64 candidate_window_(new input_method::CandidateWindow()), 64 candidate_window_(new input_method::CandidateWindow()),
65 window_visible_(false) {} 65 window_visible_(false) {}
66 66
67 InputMethodEngine::~InputMethodEngine() { 67 InputMethodEngine::~InputMethodEngine() {
68 input_method::InputMethodManager::Get()->RemoveInputMethodExtension(ibus_id_); 68 input_method::InputMethodManager::Get()->RemoveInputMethodExtension(imm_id_);
69 } 69 }
70 70
71 void InputMethodEngine::Initialize( 71 void InputMethodEngine::Initialize(
72 InputMethodEngineInterface::Observer* observer, 72 InputMethodEngineInterface::Observer* observer,
73 const char* engine_name, 73 const char* engine_name,
74 const char* extension_id, 74 const char* extension_id,
75 const char* engine_id, 75 const char* engine_id,
76 const std::vector<std::string>& languages, 76 const std::vector<std::string>& languages,
77 const std::vector<std::string>& layouts, 77 const std::vector<std::string>& layouts,
78 const GURL& options_page, 78 const GURL& options_page,
79 const GURL& input_view) { 79 const GURL& input_view) {
80 DCHECK(observer) << "Observer must not be null."; 80 DCHECK(observer) << "Observer must not be null.";
81 81
82 // TODO(komatsu): It is probably better to set observer out of Initialize.
82 observer_ = observer; 83 observer_ = observer;
83 engine_id_ = engine_id; 84 engine_id_ = engine_id;
84 85
85 input_method::InputMethodManager* manager = 86 input_method::InputMethodManager* manager =
86 input_method::InputMethodManager::Get(); 87 input_method::InputMethodManager::Get();
87 ComponentExtensionIMEManager* comp_ext_ime_manager 88 ComponentExtensionIMEManager* comp_ext_ime_manager =
88 = manager->GetComponentExtensionIMEManager(); 89 manager->GetComponentExtensionIMEManager();
89 90
90 if (comp_ext_ime_manager->IsInitialized() && 91 if (comp_ext_ime_manager->IsInitialized() &&
91 comp_ext_ime_manager->IsWhitelistedExtension(extension_id)) { 92 comp_ext_ime_manager->IsWhitelistedExtension(extension_id)) {
92 ibus_id_ = comp_ext_ime_manager->GetId(extension_id, engine_id); 93 imm_id_ = comp_ext_ime_manager->GetId(extension_id, engine_id);
93 } else { 94 } else {
94 ibus_id_ = extension_ime_util::GetInputMethodID(extension_id, engine_id); 95 imm_id_ = extension_ime_util::GetInputMethodID(extension_id, engine_id);
95 } 96 }
96 97
97 input_view_url_ = input_view; 98 input_view_url_ = input_view;
99 descriptor_ = input_method::InputMethodDescriptor(imm_id_,
100 engine_name,
101 layouts,
102 languages,
103 false, // is_login_keyboard
104 options_page,
105 input_view);
98 106
99 manager->AddInputMethodExtension(ibus_id_, engine_name, layouts, languages, 107 // TODO(komatsu): It is probably better to call AddInputMethodExtension
100 options_page, input_view, this); 108 // out of Initialize.
109 manager->AddInputMethodExtension(imm_id_, this);
110 }
111
112 const input_method::InputMethodDescriptor& InputMethodEngine::GetDescriptor()
113 const {
114 return descriptor_;
101 } 115 }
102 116
103 void InputMethodEngine::StartIme() { 117 void InputMethodEngine::StartIme() {
104 input_method::InputMethodManager* manager = 118 input_method::InputMethodManager* manager =
105 input_method::InputMethodManager::Get(); 119 input_method::InputMethodManager::Get();
106 if (manager && ibus_id_ == manager->GetCurrentInputMethod().id()) 120 if (manager && imm_id_ == manager->GetCurrentInputMethod().id())
107 Enable(); 121 Enable();
108 } 122 }
109 123
110 bool InputMethodEngine::SetComposition( 124 bool InputMethodEngine::SetComposition(
111 int context_id, 125 int context_id,
112 const char* text, 126 const char* text,
113 int selection_start, 127 int selection_start,
114 int selection_end, 128 int selection_end,
115 int cursor, 129 int cursor,
116 const std::vector<SegmentInfo>& segments, 130 const std::vector<SegmentInfo>& segments,
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // TODO(nona): Implement it. 614 // TODO(nona): Implement it.
601 break; 615 break;
602 } 616 }
603 } 617 }
604 } 618 }
605 619
606 // TODO(nona): Support item.children. 620 // TODO(nona): Support item.children.
607 } 621 }
608 622
609 } // namespace chromeos 623 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698