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

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

Issue 10968056: Fix crash bug of IME extension API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_ibus.h" 5 #include "chrome/browser/chromeos/input_method/input_method_engine_ibus.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 aux_text_visible_(false), 48 aux_text_visible_(false),
49 observer_(NULL), 49 observer_(NULL),
50 preedit_text_(new ibus::IBusText()), 50 preedit_text_(new ibus::IBusText()),
51 preedit_cursor_(0), 51 preedit_cursor_(0),
52 component_(new ibus::IBusComponent()), 52 component_(new ibus::IBusComponent()),
53 table_(new ibus::IBusLookupTable()), 53 table_(new ibus::IBusLookupTable()),
54 table_visible_(false), 54 table_visible_(false),
55 weak_ptr_factory_(this) { 55 weak_ptr_factory_(this) {
56 } 56 }
57 57
58 InputMethodEngineIBus::~InputMethodEngineIBus() {
59 GetCurrentService()->UnsetEngine();
60 input_method::InputMethodManager::GetInstance()->
61 RemoveInputMethodExtension(ibus_id_);
62 }
63
58 void InputMethodEngineIBus::Initialize( 64 void InputMethodEngineIBus::Initialize(
59 InputMethodEngine::Observer* observer, 65 InputMethodEngine::Observer* observer,
60 const char* engine_name, 66 const char* engine_name,
61 const char* extension_id, 67 const char* extension_id,
62 const char* engine_id, 68 const char* engine_id,
63 const char* description, 69 const char* description,
64 const char* language, 70 const char* language,
65 const std::vector<std::string>& layouts, 71 const std::vector<std::string>& layouts,
66 std::string* error) { 72 std::string* error) {
67 DCHECK(observer) << "Observer must not be null."; 73 DCHECK(observer) << "Observer must not be null.";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 109
104 component_->mutable_engine_description()->push_back(engine_desc); 110 component_->mutable_engine_description()->push_back(engine_desc);
105 manager->AddInputMethodExtension(ibus_id_, engine_name, layouts, language, 111 manager->AddInputMethodExtension(ibus_id_, engine_name, layouts, language,
106 this); 112 this);
107 // If connection is avaiable, register component. If there are no connection 113 // If connection is avaiable, register component. If there are no connection
108 // to ibus-daemon, OnConnected callback will register component instead. 114 // to ibus-daemon, OnConnected callback will register component instead.
109 if (IsConnected()) 115 if (IsConnected())
110 RegisterComponent(); 116 RegisterComponent();
111 } 117 }
112 118
113 InputMethodEngineIBus::~InputMethodEngineIBus() {
114 }
115
116 bool InputMethodEngineIBus::SetComposition( 119 bool InputMethodEngineIBus::SetComposition(
117 int context_id, 120 int context_id,
118 const char* text, 121 const char* text,
119 int selection_start, 122 int selection_start,
120 int selection_end, 123 int selection_end,
121 int cursor, 124 int cursor,
122 const std::vector<SegmentInfo>& segments, 125 const std::vector<SegmentInfo>& segments,
123 std::string* error) { 126 std::string* error) {
124 if (!active_) { 127 if (!active_) {
125 *error = kErrorNotActive; 128 *error = kErrorNotActive;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 // TODO(nona): Implement error handling. 567 // TODO(nona): Implement error handling.
565 } 568 }
566 569
567 void InputMethodEngineIBus::CreateEngineHandler( 570 void InputMethodEngineIBus::CreateEngineHandler(
568 const IBusEngineFactoryService::CreateEngineResponseSender& sender) { 571 const IBusEngineFactoryService::CreateEngineResponseSender& sender) {
569 DBusThreadManager::Get()->RemoveIBusEngineService(object_path_); 572 DBusThreadManager::Get()->RemoveIBusEngineService(object_path_);
570 573
571 current_object_path_++; 574 current_object_path_++;
572 object_path_ = dbus::ObjectPath(kObjectPathPrefix + 575 object_path_ = dbus::ObjectPath(kObjectPathPrefix +
573 base::IntToString(current_object_path_)); 576 base::IntToString(current_object_path_));
574 GetCurrentService()->Initialize(this); 577 GetCurrentService()->SetEngine(this);
575 sender.Run(object_path_); 578 sender.Run(object_path_);
576 } 579 }
577 580
578 } // namespace chromeos 581 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/dbus/ibus/ibus_engine_service.h » ('j') | chromeos/dbus/ibus/ibus_engine_service.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698