Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / input_method_engine.cc
blob8b73134c79af3102c12b1754c3617a14b5bd74f2
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/input_method.h"
30 #include "ui/base/ime/text_input_flags.h"
31 #include "ui/chromeos/ime/input_method_menu_item.h"
32 #include "ui/chromeos/ime/input_method_menu_manager.h"
33 #include "ui/events/event.h"
34 #include "ui/events/event_processor.h"
35 #include "ui/events/event_utils.h"
36 #include "ui/events/keycodes/dom/dom_code.h"
37 #include "ui/events/keycodes/dom/keycode_converter.h"
38 #include "ui/keyboard/keyboard_controller.h"
39 #include "ui/keyboard/keyboard_util.h"
41 namespace chromeos {
43 namespace {
45 const char kErrorNotActive[] = "IME is not active";
46 const char kErrorWrongContext[] = "Context is not active";
47 const char kCandidateNotFound[] = "Candidate not found";
49 // Notifies InputContextHandler that the composition is changed.
50 void UpdateComposition(const CompositionText& composition_text,
51 uint32 cursor_pos,
52 bool is_visible) {
53 IMEInputContextHandlerInterface* input_context =
54 IMEBridge::Get()->GetInputContextHandler();
55 if (input_context)
56 input_context->UpdateCompositionText(
57 composition_text, cursor_pos, is_visible);
60 // Returns the length of characters of a UTF-8 string with unknown string
61 // length. Cannot apply faster algorithm to count characters in an utf-8
62 // string without knowing the string length, so just does a full scan.
63 size_t GetUtf8StringLength(const char* s) {
64 size_t ret = 0;
65 while (*s) {
66 if ((*s & 0xC0) != 0x80)
67 ret++;
68 ++s;
70 return ret;
73 std::string GetKeyFromEvent(const ui::KeyEvent& event) {
74 const std::string code = event.GetCodeString();
75 if (base::StartsWith(code, "Control", base::CompareCase::SENSITIVE))
76 return "Ctrl";
77 if (base::StartsWith(code, "Shift", base::CompareCase::SENSITIVE))
78 return "Shift";
79 if (base::StartsWith(code, "Alt", base::CompareCase::SENSITIVE))
80 return "Alt";
81 if (base::StartsWith(code, "Arrow", base::CompareCase::SENSITIVE))
82 return code.substr(5);
83 if (code == "Escape")
84 return "Esc";
85 if (code == "Backspace" || code == "Tab" ||
86 code == "Enter" || code == "CapsLock" ||
87 code == "Power")
88 return code;
89 // Cases for media keys.
90 switch (event.key_code()) {
91 case ui::VKEY_BROWSER_BACK:
92 case ui::VKEY_F1:
93 return "HistoryBack";
94 case ui::VKEY_BROWSER_FORWARD:
95 case ui::VKEY_F2:
96 return "HistoryForward";
97 case ui::VKEY_BROWSER_REFRESH:
98 case ui::VKEY_F3:
99 return "BrowserRefresh";
100 case ui::VKEY_MEDIA_LAUNCH_APP2:
101 case ui::VKEY_F4:
102 return "ChromeOSFullscreen";
103 case ui::VKEY_MEDIA_LAUNCH_APP1:
104 case ui::VKEY_F5:
105 return "ChromeOSSwitchWindow";
106 case ui::VKEY_BRIGHTNESS_DOWN:
107 case ui::VKEY_F6:
108 return "BrightnessDown";
109 case ui::VKEY_BRIGHTNESS_UP:
110 case ui::VKEY_F7:
111 return "BrightnessUp";
112 case ui::VKEY_VOLUME_MUTE:
113 case ui::VKEY_F8:
114 return "AudioVolumeMute";
115 case ui::VKEY_VOLUME_DOWN:
116 case ui::VKEY_F9:
117 return "AudioVolumeDown";
118 case ui::VKEY_VOLUME_UP:
119 case ui::VKEY_F10:
120 return "AudioVolumeUp";
121 default:
122 break;
124 uint16 ch = 0;
125 // Ctrl+? cases, gets key value for Ctrl is not down.
126 if (event.flags() & ui::EF_CONTROL_DOWN) {
127 ui::KeyEvent event_no_ctrl(event.type(),
128 event.key_code(),
129 event.flags() ^ ui::EF_CONTROL_DOWN);
130 ch = event_no_ctrl.GetCharacter();
131 } else {
132 ch = event.GetCharacter();
134 return base::UTF16ToUTF8(base::string16(1, ch));
137 void GetExtensionKeyboardEventFromKeyEvent(
138 const ui::KeyEvent& event,
139 InputMethodEngine::KeyboardEvent* ext_event) {
140 DCHECK(event.type() == ui::ET_KEY_RELEASED ||
141 event.type() == ui::ET_KEY_PRESSED);
142 DCHECK(ext_event);
143 ext_event->type = (event.type() == ui::ET_KEY_RELEASED) ? "keyup" : "keydown";
145 if (event.code() == ui::DomCode::NONE)
146 ext_event->code = ui::KeyboardCodeToDomKeycode(event.key_code());
147 else
148 ext_event->code = event.GetCodeString();
149 ext_event->key_code = static_cast<int>(event.key_code());
150 ext_event->alt_key = event.IsAltDown();
151 ext_event->ctrl_key = event.IsControlDown();
152 ext_event->shift_key = event.IsShiftDown();
153 ext_event->caps_lock = event.IsCapsLockDown();
154 ext_event->key = GetKeyFromEvent(event);
157 } // namespace
159 InputMethodEngine::InputMethodEngine()
160 : current_input_type_(ui::TEXT_INPUT_TYPE_NONE),
161 context_id_(0),
162 next_context_id_(1),
163 composition_text_(new CompositionText()),
164 composition_cursor_(0),
165 candidate_window_(new ui::CandidateWindow()),
166 window_visible_(false),
167 sent_key_event_(NULL),
168 profile_(NULL) {
171 InputMethodEngine::~InputMethodEngine() {
174 void InputMethodEngine::Initialize(
175 scoped_ptr<InputMethodEngineInterface::Observer> observer,
176 const char* extension_id,
177 Profile* profile) {
178 DCHECK(observer) << "Observer must not be null.";
180 // TODO(komatsu): It is probably better to set observer out of Initialize.
181 observer_ = observer.Pass();
182 extension_id_ = extension_id;
183 profile_ = profile;
186 const std::string& InputMethodEngine::GetActiveComponentId() const {
187 return active_component_id_;
190 bool InputMethodEngine::SetComposition(
191 int context_id,
192 const char* text,
193 int selection_start,
194 int selection_end,
195 int cursor,
196 const std::vector<SegmentInfo>& segments,
197 std::string* error) {
198 if (!IsActive()) {
199 *error = kErrorNotActive;
200 return false;
202 if (context_id != context_id_ || context_id_ == -1) {
203 *error = kErrorWrongContext;
204 return false;
207 composition_cursor_ = cursor;
208 composition_text_.reset(new CompositionText());
209 composition_text_->set_text(base::UTF8ToUTF16(text));
211 composition_text_->set_selection_start(selection_start);
212 composition_text_->set_selection_end(selection_end);
214 // TODO: Add support for displaying selected text in the composition string.
215 for (std::vector<SegmentInfo>::const_iterator segment = segments.begin();
216 segment != segments.end(); ++segment) {
217 CompositionText::UnderlineAttribute underline;
219 switch (segment->style) {
220 case SEGMENT_STYLE_UNDERLINE:
221 underline.type = CompositionText::COMPOSITION_TEXT_UNDERLINE_SINGLE;
222 break;
223 case SEGMENT_STYLE_DOUBLE_UNDERLINE:
224 underline.type = CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE;
225 break;
226 case SEGMENT_STYLE_NO_UNDERLINE:
227 underline.type = CompositionText::COMPOSITION_TEXT_UNDERLINE_NONE;
228 break;
229 default:
230 continue;
233 underline.start_index = segment->start;
234 underline.end_index = segment->end;
235 composition_text_->mutable_underline_attributes()->push_back(underline);
238 // TODO(nona): Makes focus out mode configuable, if necessary.
239 UpdateComposition(*composition_text_, composition_cursor_, true);
240 return true;
243 bool InputMethodEngine::ClearComposition(int context_id,
244 std::string* error) {
245 if (!IsActive()) {
246 *error = kErrorNotActive;
247 return false;
249 if (context_id != context_id_ || context_id_ == -1) {
250 *error = kErrorWrongContext;
251 return false;
254 composition_cursor_ = 0;
255 composition_text_.reset(new CompositionText());
256 UpdateComposition(*composition_text_, composition_cursor_, false);
257 return true;
260 bool InputMethodEngine::CommitText(int context_id, const char* text,
261 std::string* error) {
262 if (!IsActive()) {
263 // TODO: Commit the text anyways.
264 *error = kErrorNotActive;
265 return false;
267 if (context_id != context_id_ || context_id_ == -1) {
268 *error = kErrorWrongContext;
269 return false;
272 IMEBridge::Get()->GetInputContextHandler()->CommitText(text);
274 // Records histograms for committed characters.
275 if (!composition_text_->text().empty()) {
276 size_t len = GetUtf8StringLength(text);
277 UMA_HISTOGRAM_CUSTOM_COUNTS("InputMethod.CommitLength",
278 len, 1, 25, 25);
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::InputMethod* input_method =
296 ash::Shell::GetTargetRootWindow()->GetHost()->GetInputMethod();
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 base::char16 ch = 0;
313 // 4-bytes UTF-8 string is at least 2-characters UTF-16 string.
314 // And Key char can only be single UTF-16 character.
315 if (!event.key.empty() && event.key.size() < 4) {
316 base::string16 key_char = base::UTF8ToUTF16(event.key);
317 if (key_char.size() == 1)
318 ch = key_char[0];
320 ui::KeyEvent ui_event(
321 type, key_code,
322 ui::KeycodeConverter::CodeStringToDomCode(event.code.c_str()), flags,
323 ui::KeycodeConverter::KeyStringToDomKey(event.key.c_str()), ch,
324 ui::EventTimeForNow());
325 base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_,
326 &ui_event);
327 input_method->DispatchKeyEvent(ui_event);
330 return true;
333 const InputMethodEngine::CandidateWindowProperty&
334 InputMethodEngine::GetCandidateWindowProperty() const {
335 return candidate_window_property_;
338 void InputMethodEngine::SetCandidateWindowProperty(
339 const CandidateWindowProperty& property) {
340 // Type conversion from InputMethodEngineInterface::CandidateWindowProperty to
341 // CandidateWindow::CandidateWindowProperty defined in chromeos/ime/.
342 ui::CandidateWindow::CandidateWindowProperty dest_property;
343 dest_property.page_size = property.page_size;
344 dest_property.is_cursor_visible = property.is_cursor_visible;
345 dest_property.is_vertical = property.is_vertical;
346 dest_property.show_window_at_composition =
347 property.show_window_at_composition;
348 dest_property.cursor_position =
349 candidate_window_->GetProperty().cursor_position;
350 dest_property.auxiliary_text = property.auxiliary_text;
351 dest_property.is_auxiliary_text_visible = property.is_auxiliary_text_visible;
353 candidate_window_->SetProperty(dest_property);
354 candidate_window_property_ = property;
356 if (IsActive()) {
357 IMECandidateWindowHandlerInterface* cw_handler =
358 IMEBridge::Get()->GetCandidateWindowHandler();
359 if (cw_handler)
360 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
364 bool InputMethodEngine::SetCandidateWindowVisible(bool visible,
365 std::string* error) {
366 if (!IsActive()) {
367 *error = kErrorNotActive;
368 return false;
371 window_visible_ = visible;
372 IMECandidateWindowHandlerInterface* cw_handler =
373 IMEBridge::Get()->GetCandidateWindowHandler();
374 if (cw_handler)
375 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
376 return true;
379 bool InputMethodEngine::SetCandidates(
380 int context_id,
381 const std::vector<Candidate>& candidates,
382 std::string* error) {
383 if (!IsActive()) {
384 *error = kErrorNotActive;
385 return false;
387 if (context_id != context_id_ || context_id_ == -1) {
388 *error = kErrorWrongContext;
389 return false;
392 // TODO: Nested candidates
393 candidate_ids_.clear();
394 candidate_indexes_.clear();
395 candidate_window_->mutable_candidates()->clear();
396 for (std::vector<Candidate>::const_iterator ix = candidates.begin();
397 ix != candidates.end(); ++ix) {
398 ui::CandidateWindow::Entry entry;
399 entry.value = base::UTF8ToUTF16(ix->value);
400 entry.label = base::UTF8ToUTF16(ix->label);
401 entry.annotation = base::UTF8ToUTF16(ix->annotation);
402 entry.description_title = base::UTF8ToUTF16(ix->usage.title);
403 entry.description_body = base::UTF8ToUTF16(ix->usage.body);
405 // Store a mapping from the user defined ID to the candidate index.
406 candidate_indexes_[ix->id] = candidate_ids_.size();
407 candidate_ids_.push_back(ix->id);
409 candidate_window_->mutable_candidates()->push_back(entry);
411 if (IsActive()) {
412 IMECandidateWindowHandlerInterface* cw_handler =
413 IMEBridge::Get()->GetCandidateWindowHandler();
414 if (cw_handler)
415 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
417 return true;
420 bool InputMethodEngine::SetCursorPosition(int context_id, int candidate_id,
421 std::string* error) {
422 if (!IsActive()) {
423 *error = kErrorNotActive;
424 return false;
426 if (context_id != context_id_ || context_id_ == -1) {
427 *error = kErrorWrongContext;
428 return false;
431 std::map<int, int>::const_iterator position =
432 candidate_indexes_.find(candidate_id);
433 if (position == candidate_indexes_.end()) {
434 *error = kCandidateNotFound;
435 return false;
438 candidate_window_->set_cursor_position(position->second);
439 IMECandidateWindowHandlerInterface* cw_handler =
440 IMEBridge::Get()->GetCandidateWindowHandler();
441 if (cw_handler)
442 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
443 return true;
446 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) {
447 return UpdateMenuItems(items);
450 bool InputMethodEngine::UpdateMenuItems(
451 const std::vector<MenuItem>& items) {
452 if (!IsActive())
453 return false;
455 ui::ime::InputMethodMenuItemList menu_item_list;
456 for (std::vector<MenuItem>::const_iterator item = items.begin();
457 item != items.end(); ++item) {
458 ui::ime::InputMethodMenuItem property;
459 MenuItemToProperty(*item, &property);
460 menu_item_list.push_back(property);
463 ui::ime::InputMethodMenuManager::GetInstance()->
464 SetCurrentInputMethodMenuItemList(
465 menu_item_list);
466 return true;
469 bool InputMethodEngine::IsActive() const {
470 return !active_component_id_.empty();
473 bool InputMethodEngine::DeleteSurroundingText(int context_id,
474 int offset,
475 size_t number_of_chars,
476 std::string* error) {
477 if (!IsActive()) {
478 *error = kErrorNotActive;
479 return false;
481 if (context_id != context_id_ || context_id_ == -1) {
482 *error = kErrorWrongContext;
483 return false;
486 // TODO(nona): Return false if there is ongoing composition.
488 IMEInputContextHandlerInterface* input_context =
489 IMEBridge::Get()->GetInputContextHandler();
490 if (input_context)
491 input_context->DeleteSurroundingText(offset, number_of_chars);
493 return true;
496 void InputMethodEngine::HideInputView() {
497 keyboard::KeyboardController* keyboard_controller =
498 keyboard::KeyboardController::GetInstance();
499 if (keyboard_controller) {
500 keyboard_controller->HideKeyboard(
501 keyboard::KeyboardController::HIDE_REASON_MANUAL);
505 void InputMethodEngine::SetCompositionBounds(
506 const std::vector<gfx::Rect>& bounds) {
507 if (!CheckProfile())
508 return;
509 observer_->OnCompositionBoundsChanged(bounds);
512 void InputMethodEngine::EnableInputView() {
513 keyboard::SetOverrideContentUrl(input_method::InputMethodManager::Get()
514 ->GetActiveIMEState()
515 ->GetCurrentInputMethod()
516 .input_view_url());
517 keyboard::KeyboardController* keyboard_controller =
518 keyboard::KeyboardController::GetInstance();
519 if (keyboard_controller)
520 keyboard_controller->Reload();
523 void InputMethodEngine::FocusIn(
524 const IMEEngineHandlerInterface::InputContext& input_context) {
525 if (!CheckProfile())
526 return;
527 current_input_type_ = input_context.type;
529 if (!IsActive() || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
530 return;
532 context_id_ = next_context_id_;
533 ++next_context_id_;
535 InputMethodEngineInterface::InputContext context;
536 context.id = context_id_;
537 switch (current_input_type_) {
538 case ui::TEXT_INPUT_TYPE_SEARCH:
539 context.type = "search";
540 break;
541 case ui::TEXT_INPUT_TYPE_TELEPHONE:
542 context.type = "tel";
543 break;
544 case ui::TEXT_INPUT_TYPE_URL:
545 context.type = "url";
546 break;
547 case ui::TEXT_INPUT_TYPE_EMAIL:
548 context.type = "email";
549 break;
550 case ui::TEXT_INPUT_TYPE_NUMBER:
551 context.type = "number";
552 break;
553 case ui::TEXT_INPUT_TYPE_PASSWORD:
554 context.type = "password";
555 break;
556 default:
557 context.type = "text";
558 break;
561 context.auto_correct =
562 !(input_context.flags & ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF);
563 context.auto_complete =
564 !(input_context.flags & ui::TEXT_INPUT_FLAG_AUTOCOMPLETE_OFF);
565 context.spell_check =
566 !(input_context.flags & ui::TEXT_INPUT_FLAG_SPELLCHECK_OFF);
568 observer_->OnFocus(context);
571 void InputMethodEngine::FocusOut() {
572 if (!CheckProfile())
573 return;
574 if (!IsActive() || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
575 return;
577 current_input_type_ = ui::TEXT_INPUT_TYPE_NONE;
579 int context_id = context_id_;
580 context_id_ = -1;
581 observer_->OnBlur(context_id);
584 void InputMethodEngine::Enable(const std::string& component_id) {
585 if (!CheckProfile())
586 return;
587 DCHECK(!component_id.empty());
588 active_component_id_ = component_id;
589 observer_->OnActivate(component_id);
590 const IMEEngineHandlerInterface::InputContext& input_context =
591 IMEBridge::Get()->GetCurrentInputContext();
592 current_input_type_ = input_context.type;
593 FocusIn(input_context);
594 EnableInputView();
597 void InputMethodEngine::Disable() {
598 if (!CheckProfile())
599 return;
600 active_component_id_.clear();
601 IMEBridge::Get()->GetInputContextHandler()->CommitText(
602 base::UTF16ToUTF8(composition_text_->text()));
603 observer_->OnDeactivated(active_component_id_);
606 void InputMethodEngine::PropertyActivate(const std::string& property_name) {
607 if (!CheckProfile())
608 return;
609 observer_->OnMenuItemActivated(active_component_id_, property_name);
612 void InputMethodEngine::Reset() {
613 if (!CheckProfile())
614 return;
615 observer_->OnReset(active_component_id_);
618 bool InputMethodEngine::IsInterestedInKeyEvent() const {
619 return observer_->IsInterestedInKeyEvent();
622 void InputMethodEngine::ProcessKeyEvent(
623 const ui::KeyEvent& key_event,
624 const KeyEventDoneCallback& callback) {
625 if (!CheckProfile())
626 return;
628 KeyEventDoneCallback* handler = new KeyEventDoneCallback();
629 *handler = callback;
631 KeyboardEvent ext_event;
632 GetExtensionKeyboardEventFromKeyEvent(key_event, &ext_event);
634 // If the given key event is equal to the key event sent by
635 // SendKeyEvents, this engine ID is propagated to the extension IME.
636 // Note, this check relies on that ui::KeyEvent is propagated as
637 // reference without copying.
638 if (&key_event == sent_key_event_)
639 ext_event.extension_id = extension_id_;
641 observer_->OnKeyEvent(
642 active_component_id_,
643 ext_event,
644 reinterpret_cast<input_method::KeyEventHandle*>(handler));
647 void InputMethodEngine::CandidateClicked(uint32 index) {
648 if (!CheckProfile())
649 return;
650 if (index > candidate_ids_.size()) {
651 return;
654 // Only left button click is supported at this moment.
655 observer_->OnCandidateClicked(
656 active_component_id_, candidate_ids_.at(index), MOUSE_BUTTON_LEFT);
659 void InputMethodEngine::SetSurroundingText(const std::string& text,
660 uint32 cursor_pos,
661 uint32 anchor_pos) {
662 if (!CheckProfile())
663 return;
664 observer_->OnSurroundingTextChanged(active_component_id_,
665 text,
666 static_cast<int>(cursor_pos),
667 static_cast<int>(anchor_pos));
670 bool InputMethodEngine::CheckProfile() const {
671 Profile* active_profile = ProfileManager::GetActiveUserProfile();
672 return active_profile == profile_ || profile_->IsSameProfile(active_profile);
675 // TODO(uekawa): rename this method to a more reasonable name.
676 void InputMethodEngine::MenuItemToProperty(
677 const MenuItem& item,
678 ui::ime::InputMethodMenuItem* property) {
679 property->key = item.id;
681 if (item.modified & MENU_ITEM_MODIFIED_LABEL) {
682 property->label = item.label;
684 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) {
685 // TODO(nona): Implement it.
687 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) {
688 property->is_selection_item_checked = item.checked;
690 if (item.modified & MENU_ITEM_MODIFIED_ENABLED) {
691 // TODO(nona): implement sensitive entry(crbug.com/140192).
693 if (item.modified & MENU_ITEM_MODIFIED_STYLE) {
694 if (!item.children.empty()) {
695 // TODO(nona): Implement it.
696 } else {
697 switch (item.style) {
698 case MENU_ITEM_STYLE_NONE:
699 NOTREACHED();
700 break;
701 case MENU_ITEM_STYLE_CHECK:
702 // TODO(nona): Implement it.
703 break;
704 case MENU_ITEM_STYLE_RADIO:
705 property->is_selection_item = true;
706 break;
707 case MENU_ITEM_STYLE_SEPARATOR:
708 // TODO(nona): Implement it.
709 break;
714 // TODO(nona): Support item.children.
717 } // namespace chromeos