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

Side by Side Diff: chrome/browser/extensions/extension_input_ime_api.cc

Issue 9230004: Remove API elements that are no longer in the IME API design document (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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/extensions/extension_input_ime_api.h" 5 #include "chrome/browser/extensions/extension_input_ime_api.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/chromeos/input_method/input_method_engine.h" 11 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 modified |= chromeos::InputMethodEngine::MENU_ITEM_MODIFIED_CHECKED; 92 modified |= chromeos::InputMethodEngine::MENU_ITEM_MODIFIED_CHECKED;
93 } 93 }
94 94
95 if (item_dict->HasKey(keys::kEnabledKey)) { 95 if (item_dict->HasKey(keys::kEnabledKey)) {
96 if (!item_dict->GetBoolean(keys::kEnabledKey, &enabled)) { 96 if (!item_dict->GetBoolean(keys::kEnabledKey, &enabled)) {
97 return false; 97 return false;
98 } 98 }
99 modified |= chromeos::InputMethodEngine::MENU_ITEM_MODIFIED_ENABLED; 99 modified |= chromeos::InputMethodEngine::MENU_ITEM_MODIFIED_ENABLED;
100 } 100 }
101 101
102 if (item_dict->HasKey(keys::kIconKey)) {
103 if (!item_dict->GetString(keys::kIconKey, &icon)) {
104 return false;
105 }
106 modified |= chromeos::InputMethodEngine::MENU_ITEM_MODIFIED_ICON;
107 }
108
109 if (item_dict->HasKey(keys::kShortcutKey)) {
110 DictionaryValue* shortcut_dict;
111 if (!item_dict->GetDictionary(keys::kShortcutKey, &shortcut_dict)) {
112 return false;
113 }
114
115 if (!shortcut_dict->GetString(keys::kKeyKey, &(shortcut_key.key))) {
116 return false;
117 }
118
119 if (shortcut_dict->HasKey(keys::kAltKeyKey)) {
120 if (!item_dict->GetBoolean(keys::kAltKeyKey, &(shortcut_key.alt_key))) {
121 return false;
122 }
123 }
124
125 if (shortcut_dict->HasKey(keys::kCtrlKeyKey)) {
126 if (!shortcut_dict->GetBoolean(keys::kCtrlKeyKey,
127 &(shortcut_key.ctrl_key))) {
128 return false;
129 }
130 }
131
132 if (shortcut_dict->HasKey(keys::kShiftKeyKey)) {
133 if (!shortcut_dict->GetBoolean(keys::kShiftKeyKey,
134 &(shortcut_key.shift_key))) {
135 return false;
136 }
137 }
138 modified |= chromeos::InputMethodEngine::MENU_ITEM_MODIFIED_SHORTCUT_KEY;
139 }
140
141 output->push_back(chromeos::InputMethodEngine::MenuItem()); 102 output->push_back(chromeos::InputMethodEngine::MenuItem());
142 output->back().id = id; 103 output->back().id = id;
143 output->back().label = label; 104 output->back().label = label;
144 output->back().style = style; 105 output->back().style = style;
145 output->back().visible = visible; 106 output->back().visible = visible;
146 output->back().enabled = enabled; 107 output->back().enabled = enabled;
147 output->back().checked = checked; 108 output->back().checked = checked;
148 output->back().icon = icon;
149 output->back().shortcut_key = shortcut_key;
150 109
151 output->back().modified = modified; 110 output->back().modified = modified;
152 111
153 if (item_dict->HasKey(keys::kItemsKey)) { 112 if (item_dict->HasKey(keys::kItemsKey)) {
154 ListValue* sub_list; 113 ListValue* sub_list;
155 if (!item_dict->GetList(keys::kItemsKey, &sub_list)) { 114 if (!item_dict->GetList(keys::kItemsKey, &sub_list)) {
156 return false; 115 return false;
157 } 116 }
158 117
159 if (!ReadMenuItems(sub_list, &(output->back().children))) { 118 if (!ReadMenuItems(sub_list, &(output->back().children))) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return; 236 return;
278 237
279 std::string request_id = 238 std::string request_id =
280 ExtensionInputImeEventRouter::GetInstance()->AddRequest(engine_id, 239 ExtensionInputImeEventRouter::GetInstance()->AddRequest(engine_id,
281 key_data); 240 key_data);
282 241
283 DictionaryValue* dict = new DictionaryValue(); 242 DictionaryValue* dict = new DictionaryValue();
284 dict->SetString("type", event.type); 243 dict->SetString("type", event.type);
285 dict->SetString("requestId", request_id); 244 dict->SetString("requestId", request_id);
286 dict->SetString("key", event.key); 245 dict->SetString("key", event.key);
287 dict->SetString("keyCode", event.key_code);
288 dict->SetBoolean("altKey", event.alt_key); 246 dict->SetBoolean("altKey", event.alt_key);
289 dict->SetBoolean("ctrlKey", event.ctrl_key); 247 dict->SetBoolean("ctrlKey", event.ctrl_key);
290 dict->SetBoolean("shiftKey", event.shift_key); 248 dict->SetBoolean("shiftKey", event.shift_key);
291 249
292 ListValue args; 250 ListValue args;
293 args.Append(Value::CreateStringValue(engine_id)); 251 args.Append(Value::CreateStringValue(engine_id));
294 args.Append(dict); 252 args.Append(dict);
295 253
296 std::string json_args; 254 std::string json_args;
297 base::JSONWriter::Write(&args, false, &json_args); 255 base::JSONWriter::Write(&args, false, &json_args);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 std::map<std::string, chromeos::InputMethodEngine*>::iterator engine_ix = 344 std::map<std::string, chromeos::InputMethodEngine*>::iterator engine_ix =
387 engine_map.find(component.id); 345 engine_map.find(component.id);
388 if (engine_ix != engine_map.end()) { 346 if (engine_ix != engine_map.end()) {
389 return false; 347 return false;
390 } 348 }
391 349
392 std::string error; 350 std::string error;
393 chromeos::ImeObserver* observer = new chromeos::ImeObserver(profile, 351 chromeos::ImeObserver* observer = new chromeos::ImeObserver(profile,
394 extension_id, 352 extension_id,
395 component.id); 353 component.id);
396 chromeos::InputMethodEngine::KeyboardEvent shortcut_key;
397 shortcut_key.key = component.shortcut_keycode;
398 shortcut_key.key_code = component.shortcut_keycode;
399 shortcut_key.alt_key = component.shortcut_alt;
400 shortcut_key.ctrl_key = component.shortcut_ctrl;
401 shortcut_key.shift_key = component.shortcut_shift;
402
403 std::vector<std::string> layouts; 354 std::vector<std::string> layouts;
404 layouts.assign(component.layouts.begin(), component.layouts.end()); 355 layouts.assign(component.layouts.begin(), component.layouts.end());
405 356
406 chromeos::InputMethodEngine* engine = 357 chromeos::InputMethodEngine* engine =
407 chromeos::InputMethodEngine::CreateEngine( 358 chromeos::InputMethodEngine::CreateEngine(
408 observer, component.name.c_str(), extension_id.c_str(), 359 observer, component.name.c_str(), extension_id.c_str(),
409 component.id.c_str(), component.description.c_str(), 360 component.id.c_str(), component.description.c_str(),
410 component.language.c_str(), layouts, 361 component.language.c_str(), layouts, &error);
411 shortcut_key, &error);
412 if (!engine) { 362 if (!engine) {
413 delete observer; 363 delete observer;
414 LOG(ERROR) << "RegisterIme: " << error; 364 LOG(ERROR) << "RegisterIme: " << error;
415 return false; 365 return false;
416 } 366 }
417 367
418 engine_map[component.id] = engine; 368 engine_map[component.id] = engine;
419 369
420 std::map<std::string, chromeos::ImeObserver*>& observer_list = 370 std::map<std::string, chromeos::ImeObserver*>& observer_list =
421 observers_[extension_id]; 371 observers_[extension_id];
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 826
877 bool handled = false; 827 bool handled = false;
878 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled)); 828 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled));
879 829
880 ExtensionInputImeEventRouter::GetInstance()->OnEventHandled( 830 ExtensionInputImeEventRouter::GetInstance()->OnEventHandled(
881 extension_id(), request_id_str, handled); 831 extension_id(), request_id_str, handled);
882 832
883 return true; 833 return true;
884 } 834 }
885 #endif 835 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698