Fix the duplicatedly commited composition text when switching IME.
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / input_method_engine.cc
blob6dba1f9a28b6b19e52747fdb8ede79fec8c51f4a
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
7 #undef FocusIn
8 #undef FocusOut
9 #undef RootWindow
10 #include <map>
12 #include "ash/shell.h"
13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/metrics/histogram.h"
16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h"
20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "ui/aura/window.h"
22 #include "ui/aura/window_tree_host.h"
23 #include "ui/base/ime/candidate_window.h"
24 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
25 #include "ui/base/ime/chromeos/composition_text_chromeos.h"
26 #include "ui/base/ime/chromeos/extension_ime_util.h"
27 #include "ui/base/ime/chromeos/ime_keymap.h"
28 #include "ui/base/ime/chromeos/input_method_manager.h"
29 #include "ui/base/ime/text_input_flags.h"
30 #include "ui/chromeos/ime/input_method_menu_item.h"
31 #include "ui/chromeos/ime/input_method_menu_manager.h"
32 #include "ui/events/event.h"
33 #include "ui/events/event_processor.h"
34 #include "ui/events/event_utils.h"
35 #include "ui/events/keycodes/dom/dom_code.h"
36 #include "ui/events/keycodes/dom/keycode_converter.h"
37 #include "ui/keyboard/keyboard_controller.h"
38 #include "ui/keyboard/keyboard_util.h"
40 namespace chromeos {
42 namespace {
44 const char kErrorNotActive[] = "IME is not active";
45 const char kErrorWrongContext[] = "Context is not active";
46 const char kCandidateNotFound[] = "Candidate not found";
48 // Notifies InputContextHandler that the composition is changed.
49 void UpdateComposition(const CompositionText& composition_text,
50 uint32 cursor_pos,
51 bool is_visible) {
52 IMEInputContextHandlerInterface* input_context =
53 IMEBridge::Get()->GetInputContextHandler();
54 if (input_context)
55 input_context->UpdateCompositionText(
56 composition_text, cursor_pos, is_visible);
59 // Returns the length of characters of a UTF-8 string with unknown string
60 // length. Cannot apply faster algorithm to count characters in an utf-8
61 // string without knowing the string length, so just does a full scan.
62 size_t GetUtf8StringLength(const char* s) {
63 size_t ret = 0;
64 while (*s) {
65 if ((*s & 0xC0) != 0x80)
66 ret++;
67 ++s;
69 return ret;
72 std::string GetKeyFromEvent(const ui::KeyEvent& event) {
73 const std::string code = event.GetCodeString();
74 if (base::StartsWith(code, "Control", base::CompareCase::SENSITIVE))
75 return "Ctrl";
76 if (base::StartsWith(code, "Shift", base::CompareCase::SENSITIVE))
77 return "Shift";
78 if (base::StartsWith(code, "Alt", base::CompareCase::SENSITIVE))
79 return "Alt";
80 if (base::StartsWith(code, "Arrow", base::CompareCase::SENSITIVE))
81 return code.substr(5);
82 if (code == "Escape")
83 return "Esc";
84 if (code == "Backspace" || code == "Tab" ||
85 code == "Enter" || code == "CapsLock" ||
86 code == "Power")
87 return code;
88 // Cases for media keys.
89 switch (event.key_code()) {
90 case ui::VKEY_BROWSER_BACK:
91 case ui::VKEY_F1:
92 return "HistoryBack";
93 case ui::VKEY_BROWSER_FORWARD:
94 case ui::VKEY_F2:
95 return "HistoryForward";
96 case ui::VKEY_BROWSER_REFRESH:
97 case ui::VKEY_F3:
98 return "BrowserRefresh";
99 case ui::VKEY_MEDIA_LAUNCH_APP2:
100 case ui::VKEY_F4:
101 return "ChromeOSFullscreen";
102 case ui::VKEY_MEDIA_LAUNCH_APP1:
103 case ui::VKEY_F5:
104 return "ChromeOSSwitchWindow";
105 case ui::VKEY_BRIGHTNESS_DOWN:
106 case ui::VKEY_F6:
107 return "BrightnessDown";
108 case ui::VKEY_BRIGHTNESS_UP:
109 case ui::VKEY_F7:
110 return "BrightnessUp";
111 case ui::VKEY_VOLUME_MUTE:
112 case ui::VKEY_F8:
113 return "AudioVolumeMute";
114 case ui::VKEY_VOLUME_DOWN:
115 case ui::VKEY_F9:
116 return "AudioVolumeDown";
117 case ui::VKEY_VOLUME_UP:
118 case ui::VKEY_F10:
119 return "AudioVolumeUp";
120 default:
121 break;
123 uint16 ch = 0;
124 // Ctrl+? cases, gets key value for Ctrl is not down.
125 if (event.flags() & ui::EF_CONTROL_DOWN) {
126 ui::KeyEvent event_no_ctrl(event.type(),
127 event.key_code(),
128 event.flags() ^ ui::EF_CONTROL_DOWN);
129 ch = event_no_ctrl.GetCharacter();
130 } else {
131 ch = event.GetCharacter();
133 return base::UTF16ToUTF8(base::string16(1, ch));
136 void GetExtensionKeyboardEventFromKeyEvent(
137 const ui::KeyEvent& event,
138 InputMethodEngine::KeyboardEvent* ext_event) {
139 DCHECK(event.type() == ui::ET_KEY_RELEASED ||
140 event.type() == ui::ET_KEY_PRESSED);
141 DCHECK(ext_event);
142 ext_event->type = (event.type() == ui::ET_KEY_RELEASED) ? "keyup" : "keydown";
144 if (event.code() == ui::DomCode::NONE)
145 ext_event->code = ui::KeyboardCodeToDomKeycode(event.key_code());
146 else
147 ext_event->code = event.GetCodeString();
148 ext_event->key_code = static_cast<int>(event.key_code());
149 ext_event->alt_key = event.IsAltDown();
150 ext_event->ctrl_key = event.IsControlDown();
151 ext_event->shift_key = event.IsShiftDown();
152 ext_event->caps_lock = event.IsCapsLockDown();
153 ext_event->key = GetKeyFromEvent(event);
156 } // namespace
158 InputMethodEngine::InputMethodEngine()
159 : current_input_type_(ui::TEXT_INPUT_TYPE_NONE),
160 context_id_(0),
161 next_context_id_(1),
162 composition_text_(new CompositionText()),
163 composition_cursor_(0),
164 candidate_window_(new ui::CandidateWindow()),
165 window_visible_(false),
166 sent_key_event_(NULL),
167 profile_(NULL) {
170 InputMethodEngine::~InputMethodEngine() {
173 void InputMethodEngine::Initialize(
174 scoped_ptr<InputMethodEngineInterface::Observer> observer,
175 const char* extension_id,
176 Profile* profile) {
177 DCHECK(observer) << "Observer must not be null.";
179 // TODO(komatsu): It is probably better to set observer out of Initialize.
180 observer_ = observer.Pass();
181 extension_id_ = extension_id;
182 profile_ = profile;
185 const std::string& InputMethodEngine::GetActiveComponentId() const {
186 return active_component_id_;
189 bool InputMethodEngine::SetComposition(
190 int context_id,
191 const char* text,
192 int selection_start,
193 int selection_end,
194 int cursor,
195 const std::vector<SegmentInfo>& segments,
196 std::string* error) {
197 if (!IsActive()) {
198 *error = kErrorNotActive;
199 return false;
201 if (context_id != context_id_ || context_id_ == -1) {
202 *error = kErrorWrongContext;
203 return false;
206 composition_cursor_ = cursor;
207 composition_text_.reset(new CompositionText());
208 composition_text_->set_text(base::UTF8ToUTF16(text));
210 composition_text_->set_selection_start(selection_start);
211 composition_text_->set_selection_end(selection_end);
213 // TODO: Add support for displaying selected text in the composition string.
214 for (std::vector<SegmentInfo>::const_iterator segment = segments.begin();
215 segment != segments.end(); ++segment) {
216 CompositionText::UnderlineAttribute underline;
218 switch (segment->style) {
219 case SEGMENT_STYLE_UNDERLINE:
220 underline.type = CompositionText::COMPOSITION_TEXT_UNDERLINE_SINGLE;
221 break;
222 case SEGMENT_STYLE_DOUBLE_UNDERLINE:
223 underline.type = CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE;
224 break;
225 case SEGMENT_STYLE_NO_UNDERLINE:
226 underline.type = CompositionText::COMPOSITION_TEXT_UNDERLINE_NONE;
227 break;
228 default:
229 continue;
232 underline.start_index = segment->start;
233 underline.end_index = segment->end;
234 composition_text_->mutable_underline_attributes()->push_back(underline);
237 // TODO(nona): Makes focus out mode configuable, if necessary.
238 UpdateComposition(*composition_text_, composition_cursor_, true);
239 return true;
242 bool InputMethodEngine::ClearComposition(int context_id,
243 std::string* error) {
244 if (!IsActive()) {
245 *error = kErrorNotActive;
246 return false;
248 if (context_id != context_id_ || context_id_ == -1) {
249 *error = kErrorWrongContext;
250 return false;
253 composition_cursor_ = 0;
254 composition_text_.reset(new CompositionText());
255 UpdateComposition(*composition_text_, composition_cursor_, false);
256 return true;
259 bool InputMethodEngine::CommitText(int context_id, const char* text,
260 std::string* error) {
261 if (!IsActive()) {
262 // TODO: Commit the text anyways.
263 *error = kErrorNotActive;
264 return false;
266 if (context_id != context_id_ || context_id_ == -1) {
267 *error = kErrorWrongContext;
268 return false;
271 IMEBridge::Get()->GetInputContextHandler()->CommitText(text);
273 // Records histograms for committed characters.
274 if (!composition_text_->text().empty()) {
275 size_t len = GetUtf8StringLength(text);
276 UMA_HISTOGRAM_CUSTOM_COUNTS("InputMethod.CommitLength",
277 len, 1, 25, 25);
278 composition_text_.reset(new CompositionText());
280 return true;
283 bool InputMethodEngine::SendKeyEvents(
284 int context_id,
285 const std::vector<KeyboardEvent>& events) {
286 if (!IsActive()) {
287 return false;
289 // context_id == 0, means sending key events to non-input field.
290 // context_id_ == -1, means the focus is not in an input field.
291 if (context_id != 0 && (context_id != context_id_ || context_id_ == -1)) {
292 return false;
295 ui::EventProcessor* dispatcher =
296 ash::Shell::GetPrimaryRootWindow()->GetHost()->event_processor();
298 for (size_t i = 0; i < events.size(); ++i) {
299 const KeyboardEvent& event = events[i];
300 const ui::EventType type =
301 (event.type == "keyup") ? ui::ET_KEY_RELEASED : ui::ET_KEY_PRESSED;
302 ui::KeyboardCode key_code = static_cast<ui::KeyboardCode>(event.key_code);
303 if (key_code == ui::VKEY_UNKNOWN)
304 key_code = ui::DomKeycodeToKeyboardCode(event.code);
306 int flags = ui::EF_NONE;
307 flags |= event.alt_key ? ui::EF_ALT_DOWN : ui::EF_NONE;
308 flags |= event.ctrl_key ? ui::EF_CONTROL_DOWN : ui::EF_NONE;
309 flags |= event.shift_key ? ui::EF_SHIFT_DOWN : ui::EF_NONE;
310 flags |= event.caps_lock ? ui::EF_CAPS_LOCK_DOWN : ui::EF_NONE;
312 ui::KeyEvent ui_event(
313 type, key_code,
314 ui::KeycodeConverter::CodeStringToDomCode(event.code.c_str()), flags,
315 ui::KeycodeConverter::KeyStringToDomKey(event.key.c_str()),
316 ui::EventTimeForNow());
317 base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_,
318 &ui_event);
319 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&ui_event);
320 if (details.dispatcher_destroyed)
321 break;
324 return true;
327 const InputMethodEngine::CandidateWindowProperty&
328 InputMethodEngine::GetCandidateWindowProperty() const {
329 return candidate_window_property_;
332 void InputMethodEngine::SetCandidateWindowProperty(
333 const CandidateWindowProperty& property) {
334 // Type conversion from InputMethodEngineInterface::CandidateWindowProperty to
335 // CandidateWindow::CandidateWindowProperty defined in chromeos/ime/.
336 ui::CandidateWindow::CandidateWindowProperty dest_property;
337 dest_property.page_size = property.page_size;
338 dest_property.is_cursor_visible = property.is_cursor_visible;
339 dest_property.is_vertical = property.is_vertical;
340 dest_property.show_window_at_composition =
341 property.show_window_at_composition;
342 dest_property.cursor_position =
343 candidate_window_->GetProperty().cursor_position;
344 dest_property.auxiliary_text = property.auxiliary_text;
345 dest_property.is_auxiliary_text_visible = property.is_auxiliary_text_visible;
347 candidate_window_->SetProperty(dest_property);
348 candidate_window_property_ = property;
350 if (IsActive()) {
351 IMECandidateWindowHandlerInterface* cw_handler =
352 IMEBridge::Get()->GetCandidateWindowHandler();
353 if (cw_handler)
354 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
358 bool InputMethodEngine::SetCandidateWindowVisible(bool visible,
359 std::string* error) {
360 if (!IsActive()) {
361 *error = kErrorNotActive;
362 return false;
365 window_visible_ = visible;
366 IMECandidateWindowHandlerInterface* cw_handler =
367 IMEBridge::Get()->GetCandidateWindowHandler();
368 if (cw_handler)
369 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
370 return true;
373 bool InputMethodEngine::SetCandidates(
374 int context_id,
375 const std::vector<Candidate>& candidates,
376 std::string* error) {
377 if (!IsActive()) {
378 *error = kErrorNotActive;
379 return false;
381 if (context_id != context_id_ || context_id_ == -1) {
382 *error = kErrorWrongContext;
383 return false;
386 // TODO: Nested candidates
387 candidate_ids_.clear();
388 candidate_indexes_.clear();
389 candidate_window_->mutable_candidates()->clear();
390 for (std::vector<Candidate>::const_iterator ix = candidates.begin();
391 ix != candidates.end(); ++ix) {
392 ui::CandidateWindow::Entry entry;
393 entry.value = base::UTF8ToUTF16(ix->value);
394 entry.label = base::UTF8ToUTF16(ix->label);
395 entry.annotation = base::UTF8ToUTF16(ix->annotation);
396 entry.description_title = base::UTF8ToUTF16(ix->usage.title);
397 entry.description_body = base::UTF8ToUTF16(ix->usage.body);
399 // Store a mapping from the user defined ID to the candidate index.
400 candidate_indexes_[ix->id] = candidate_ids_.size();
401 candidate_ids_.push_back(ix->id);
403 candidate_window_->mutable_candidates()->push_back(entry);
405 if (IsActive()) {
406 IMECandidateWindowHandlerInterface* cw_handler =
407 IMEBridge::Get()->GetCandidateWindowHandler();
408 if (cw_handler)
409 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
411 return true;
414 bool InputMethodEngine::SetCursorPosition(int context_id, int candidate_id,
415 std::string* error) {
416 if (!IsActive()) {
417 *error = kErrorNotActive;
418 return false;
420 if (context_id != context_id_ || context_id_ == -1) {
421 *error = kErrorWrongContext;
422 return false;
425 std::map<int, int>::const_iterator position =
426 candidate_indexes_.find(candidate_id);
427 if (position == candidate_indexes_.end()) {
428 *error = kCandidateNotFound;
429 return false;
432 candidate_window_->set_cursor_position(position->second);
433 IMECandidateWindowHandlerInterface* cw_handler =
434 IMEBridge::Get()->GetCandidateWindowHandler();
435 if (cw_handler)
436 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
437 return true;
440 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) {
441 return UpdateMenuItems(items);
444 bool InputMethodEngine::UpdateMenuItems(
445 const std::vector<MenuItem>& items) {
446 if (!IsActive())
447 return false;
449 ui::ime::InputMethodMenuItemList menu_item_list;
450 for (std::vector<MenuItem>::const_iterator item = items.begin();
451 item != items.end(); ++item) {
452 ui::ime::InputMethodMenuItem property;
453 MenuItemToProperty(*item, &property);
454 menu_item_list.push_back(property);
457 ui::ime::InputMethodMenuManager::GetInstance()->
458 SetCurrentInputMethodMenuItemList(
459 menu_item_list);
460 return true;
463 bool InputMethodEngine::IsActive() const {
464 return !active_component_id_.empty();
467 bool InputMethodEngine::DeleteSurroundingText(int context_id,
468 int offset,
469 size_t number_of_chars,
470 std::string* error) {
471 if (!IsActive()) {
472 *error = kErrorNotActive;
473 return false;
475 if (context_id != context_id_ || context_id_ == -1) {
476 *error = kErrorWrongContext;
477 return false;
480 // TODO(nona): Return false if there is ongoing composition.
482 IMEInputContextHandlerInterface* input_context =
483 IMEBridge::Get()->GetInputContextHandler();
484 if (input_context)
485 input_context->DeleteSurroundingText(offset, number_of_chars);
487 return true;
490 void InputMethodEngine::HideInputView() {
491 keyboard::KeyboardController* keyboard_controller =
492 keyboard::KeyboardController::GetInstance();
493 if (keyboard_controller) {
494 keyboard_controller->HideKeyboard(
495 keyboard::KeyboardController::HIDE_REASON_MANUAL);
499 void InputMethodEngine::SetCompositionBounds(
500 const std::vector<gfx::Rect>& bounds) {
501 if (!CheckProfile())
502 return;
503 observer_->OnCompositionBoundsChanged(bounds);
506 void InputMethodEngine::EnableInputView() {
507 keyboard::SetOverrideContentUrl(input_method::InputMethodManager::Get()
508 ->GetActiveIMEState()
509 ->GetCurrentInputMethod()
510 .input_view_url());
511 keyboard::KeyboardController* keyboard_controller =
512 keyboard::KeyboardController::GetInstance();
513 if (keyboard_controller)
514 keyboard_controller->Reload();
517 void InputMethodEngine::FocusIn(
518 const IMEEngineHandlerInterface::InputContext& input_context) {
519 if (!CheckProfile())
520 return;
521 current_input_type_ = input_context.type;
523 if (!IsActive() || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
524 return;
526 context_id_ = next_context_id_;
527 ++next_context_id_;
529 InputMethodEngineInterface::InputContext context;
530 context.id = context_id_;
531 switch (current_input_type_) {
532 case ui::TEXT_INPUT_TYPE_SEARCH:
533 context.type = "search";
534 break;
535 case ui::TEXT_INPUT_TYPE_TELEPHONE:
536 context.type = "tel";
537 break;
538 case ui::TEXT_INPUT_TYPE_URL:
539 context.type = "url";
540 break;
541 case ui::TEXT_INPUT_TYPE_EMAIL:
542 context.type = "email";
543 break;
544 case ui::TEXT_INPUT_TYPE_NUMBER:
545 context.type = "number";
546 break;
547 case ui::TEXT_INPUT_TYPE_PASSWORD:
548 context.type = "password";
549 break;
550 default:
551 context.type = "text";
552 break;
555 context.auto_correct =
556 !(input_context.flags & ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF);
557 context.auto_complete =
558 !(input_context.flags & ui::TEXT_INPUT_FLAG_AUTOCOMPLETE_OFF);
559 context.spell_check =
560 !(input_context.flags & ui::TEXT_INPUT_FLAG_SPELLCHECK_OFF);
562 observer_->OnFocus(context);
565 void InputMethodEngine::FocusOut() {
566 if (!CheckProfile())
567 return;
568 if (!IsActive() || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
569 return;
571 current_input_type_ = ui::TEXT_INPUT_TYPE_NONE;
573 int context_id = context_id_;
574 context_id_ = -1;
575 observer_->OnBlur(context_id);
578 void InputMethodEngine::Enable(const std::string& component_id) {
579 if (!CheckProfile())
580 return;
581 DCHECK(!component_id.empty());
582 active_component_id_ = component_id;
583 observer_->OnActivate(component_id);
584 const IMEEngineHandlerInterface::InputContext& input_context =
585 IMEBridge::Get()->GetCurrentInputContext();
586 current_input_type_ = input_context.type;
587 FocusIn(input_context);
588 EnableInputView();
591 void InputMethodEngine::Disable() {
592 if (!CheckProfile())
593 return;
594 active_component_id_.clear();
595 IMEBridge::Get()->GetInputContextHandler()->CommitText(
596 base::UTF16ToUTF8(composition_text_->text()));
597 composition_text_.reset(new CompositionText());
598 observer_->OnDeactivated(active_component_id_);
601 void InputMethodEngine::PropertyActivate(const std::string& property_name) {
602 if (!CheckProfile())
603 return;
604 observer_->OnMenuItemActivated(active_component_id_, property_name);
607 void InputMethodEngine::Reset() {
608 if (!CheckProfile())
609 return;
610 composition_text_.reset(new CompositionText());
611 observer_->OnReset(active_component_id_);
614 bool InputMethodEngine::IsInterestedInKeyEvent() const {
615 return observer_->IsInterestedInKeyEvent();
618 void InputMethodEngine::ProcessKeyEvent(
619 const ui::KeyEvent& key_event,
620 const KeyEventDoneCallback& callback) {
621 if (!CheckProfile())
622 return;
624 KeyEventDoneCallback* handler = new KeyEventDoneCallback();
625 *handler = callback;
627 KeyboardEvent ext_event;
628 GetExtensionKeyboardEventFromKeyEvent(key_event, &ext_event);
630 // If the given key event is equal to the key event sent by
631 // SendKeyEvents, this engine ID is propagated to the extension IME.
632 // Note, this check relies on that ui::KeyEvent is propagated as
633 // reference without copying.
634 if (&key_event == sent_key_event_)
635 ext_event.extension_id = extension_id_;
637 observer_->OnKeyEvent(
638 active_component_id_,
639 ext_event,
640 reinterpret_cast<input_method::KeyEventHandle*>(handler));
643 void InputMethodEngine::CandidateClicked(uint32 index) {
644 if (!CheckProfile())
645 return;
646 if (index > candidate_ids_.size()) {
647 return;
650 // Only left button click is supported at this moment.
651 observer_->OnCandidateClicked(
652 active_component_id_, candidate_ids_.at(index), MOUSE_BUTTON_LEFT);
655 void InputMethodEngine::SetSurroundingText(const std::string& text,
656 uint32 cursor_pos,
657 uint32 anchor_pos,
658 uint32 offset_pos) {
659 if (!CheckProfile())
660 return;
661 observer_->OnSurroundingTextChanged(
662 active_component_id_, text, static_cast<int>(cursor_pos),
663 static_cast<int>(anchor_pos), static_cast<int>(offset_pos));
666 bool InputMethodEngine::CheckProfile() const {
667 Profile* active_profile = ProfileManager::GetActiveUserProfile();
668 return active_profile == profile_ || profile_->IsSameProfile(active_profile);
671 // TODO(uekawa): rename this method to a more reasonable name.
672 void InputMethodEngine::MenuItemToProperty(
673 const MenuItem& item,
674 ui::ime::InputMethodMenuItem* property) {
675 property->key = item.id;
677 if (item.modified & MENU_ITEM_MODIFIED_LABEL) {
678 property->label = item.label;
680 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) {
681 // TODO(nona): Implement it.
683 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) {
684 property->is_selection_item_checked = item.checked;
686 if (item.modified & MENU_ITEM_MODIFIED_ENABLED) {
687 // TODO(nona): implement sensitive entry(crbug.com/140192).
689 if (item.modified & MENU_ITEM_MODIFIED_STYLE) {
690 if (!item.children.empty()) {
691 // TODO(nona): Implement it.
692 } else {
693 switch (item.style) {
694 case MENU_ITEM_STYLE_NONE:
695 NOTREACHED();
696 break;
697 case MENU_ITEM_STYLE_CHECK:
698 // TODO(nona): Implement it.
699 break;
700 case MENU_ITEM_STYLE_RADIO:
701 property->is_selection_item = true;
702 break;
703 case MENU_ITEM_STYLE_SEPARATOR:
704 // TODO(nona): Implement it.
705 break;
710 // TODO(nona): Support item.children.
713 } // namespace chromeos