Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / input_method / input_method_engine.cc
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.
4
5 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
6
7 #undef FocusIn
8 #undef FocusOut
9 #undef RootWindow
10 #include <map>
11
12 #include "ash/ime/input_method_menu_item.h"
13 #include "ash/ime/input_method_menu_manager.h"
14 #include "ash/shell.h"
15 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/metrics/histogram.h"
18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h"
22 #include "chromeos/ime/component_extension_ime_manager.h"
23 #include "chromeos/ime/composition_text.h"
24 #include "chromeos/ime/extension_ime_util.h"
25 #include "chromeos/ime/input_method_manager.h"
26 #include "ui/aura/window.h"
27 #include "ui/aura/window_tree_host.h"
28 #include "ui/base/ime/candidate_window.h"
29 #include "ui/base/ime/chromeos/ime_keymap.h"
30 #include "ui/events/event.h"
31 #include "ui/events/event_processor.h"
32 #include "ui/keyboard/keyboard_controller.h"
33 #include "ui/keyboard/keyboard_util.h"
34
35 namespace chromeos {
36 const char* kErrorNotActive = "IME is not active";
37 const char* kErrorWrongContext = "Context is not active";
38 const char* kCandidateNotFound = "Candidate not found";
39
40 namespace {
41
42 // Notifies InputContextHandler that the composition is changed.
43 void UpdateComposition(const CompositionText& composition_text,
44                        uint32 cursor_pos,
45                        bool is_visible) {
46   IMEInputContextHandlerInterface* input_context =
47       IMEBridge::Get()->GetInputContextHandler();
48   if (input_context)
49     input_context->UpdateCompositionText(
50         composition_text, cursor_pos, is_visible);
51 }
52
53 // Returns the length of characters of a UTF-8 string with unknown string
54 // length. Cannot apply faster algorithm to count characters in an utf-8
55 // string without knowing the string length,  so just does a full scan.
56 size_t GetUtf8StringLength(const char* s) {
57   size_t ret = 0;
58   while (*s) {
59     if ((*s & 0xC0) != 0x80)
60       ret++;
61     ++s;
62   }
63   return ret;
64 }
65
66 std::string GetKeyFromEvent(const ui::KeyEvent& event) {
67   const std::string& code = event.code();
68   if (StartsWithASCII(code, "Control", true))
69     return "Ctrl";
70   if (StartsWithASCII(code, "Shift", true))
71     return "Shift";
72   if (StartsWithASCII(code, "Alt", true))
73     return "Alt";
74   if (StartsWithASCII(code, "Arrow", true))
75     return code.substr(5);
76   if (code == "Escape")
77     return "Esc";
78   if (code == "Backspace" || code == "Tab" ||
79       code == "Enter" || code == "CapsLock")
80     return code;
81   uint16 ch = 0;
82   // Ctrl+? cases, gets key value for Ctrl is not down.
83   if (event.flags() & ui::EF_CONTROL_DOWN) {
84     ui::KeyEvent event_no_ctrl(event.type(),
85                                event.key_code(),
86                                event.flags() ^ ui::EF_CONTROL_DOWN,
87                                false);
88     ch = event_no_ctrl.GetCharacter();
89   } else {
90     ch = event.GetCharacter();
91   }
92   return base::UTF16ToUTF8(base::string16(1, ch));
93 }
94
95 void GetExtensionKeyboardEventFromKeyEvent(
96     const ui::KeyEvent& event,
97     InputMethodEngine::KeyboardEvent* ext_event) {
98   DCHECK(event.type() == ui::ET_KEY_RELEASED ||
99          event.type() == ui::ET_KEY_PRESSED);
100   DCHECK(ext_event);
101   ext_event->type = (event.type() == ui::ET_KEY_RELEASED) ? "keyup" : "keydown";
102
103   ext_event->code = event.code();
104   ext_event->key_code = static_cast<int>(event.key_code());
105   ext_event->alt_key = event.IsAltDown();
106   ext_event->ctrl_key = event.IsControlDown();
107   ext_event->shift_key = event.IsShiftDown();
108   ext_event->caps_lock = event.IsCapsLockDown();
109   ext_event->key = GetKeyFromEvent(event);
110 }
111
112 }  // namespace
113
114 InputMethodEngine::InputMethodEngine()
115     : current_input_type_(ui::TEXT_INPUT_TYPE_NONE),
116       active_(false),
117       context_id_(0),
118       next_context_id_(1),
119       composition_text_(new CompositionText()),
120       composition_cursor_(0),
121       candidate_window_(new ui::CandidateWindow()),
122       window_visible_(false),
123       sent_key_event_(NULL),
124       profile_(NULL) {
125 }
126
127 InputMethodEngine::~InputMethodEngine() {
128   if (start_time_.ToInternalValue())
129     RecordHistogram("WorkingTime", (end_time_ - start_time_).InSeconds());
130   input_method::InputMethodManager::Get()->RemoveInputMethodExtension(profile_,
131                                                                       imm_id_);
132 }
133
134 void InputMethodEngine::Initialize(
135     Profile* profile,
136     scoped_ptr<InputMethodEngineInterface::Observer> observer,
137     const char* engine_name,
138     const char* extension_id,
139     const char* engine_id,
140     const std::vector<std::string>& languages,
141     const std::vector<std::string>& layouts,
142     const GURL& options_page,
143     const GURL& input_view) {
144   DCHECK(observer) << "Observer must not be null.";
145
146   profile_ = profile;
147
148   // TODO(komatsu): It is probably better to set observer out of Initialize.
149   observer_ = observer.Pass();
150   engine_id_ = engine_id;
151   extension_id_ = extension_id;
152
153   input_method::InputMethodManager* manager =
154       input_method::InputMethodManager::Get();
155   ComponentExtensionIMEManager* comp_ext_ime_manager =
156       manager->GetComponentExtensionIMEManager();
157
158   if (comp_ext_ime_manager && comp_ext_ime_manager->IsInitialized() &&
159       comp_ext_ime_manager->IsWhitelistedExtension(extension_id)) {
160     imm_id_ = comp_ext_ime_manager->GetId(extension_id, engine_id);
161   } else {
162     imm_id_ = extension_ime_util::GetInputMethodID(extension_id, engine_id);
163   }
164
165   input_view_url_ = input_view;
166   descriptor_ = input_method::InputMethodDescriptor(
167       imm_id_,
168       engine_name,
169       std::string(), // TODO(uekawa): Set short name.
170       layouts,
171       languages,
172       extension_ime_util::IsKeyboardLayoutExtension(
173           imm_id_), // is_login_keyboard
174       options_page,
175       input_view);
176
177   // TODO(komatsu): It is probably better to call AddInputMethodExtension
178   // out of Initialize.
179   manager->AddInputMethodExtension(profile, imm_id_, this);
180 }
181
182 const input_method::InputMethodDescriptor& InputMethodEngine::GetDescriptor()
183     const {
184   return descriptor_;
185 }
186
187 void InputMethodEngine::RecordHistogram(const char* name, int count) {
188   std::string histo_name =
189       base::StringPrintf("InputMethod.%s.%s", name, engine_id_.c_str());
190   base::HistogramBase* counter = base::Histogram::FactoryGet(
191       histo_name, 0, 1000000, 50, base::HistogramBase::kNoFlags);
192   if (counter)
193     counter->Add(count);
194 }
195
196 void InputMethodEngine::NotifyImeReady() {
197   input_method::InputMethodManager* manager =
198       input_method::InputMethodManager::Get();
199   if (manager && imm_id_ == manager->GetCurrentInputMethod().id())
200     Enable();
201 }
202
203 bool InputMethodEngine::SetComposition(
204     int context_id,
205     const char* text,
206     int selection_start,
207     int selection_end,
208     int cursor,
209     const std::vector<SegmentInfo>& segments,
210     std::string* error) {
211   if (!active_) {
212     *error = kErrorNotActive;
213     return false;
214   }
215   if (context_id != context_id_ || context_id_ == -1) {
216     *error = kErrorWrongContext;
217     return false;
218   }
219
220   composition_cursor_ = cursor;
221   composition_text_.reset(new CompositionText());
222   composition_text_->set_text(base::UTF8ToUTF16(text));
223
224   composition_text_->set_selection_start(selection_start);
225   composition_text_->set_selection_end(selection_end);
226
227   // TODO: Add support for displaying selected text in the composition string.
228   for (std::vector<SegmentInfo>::const_iterator segment = segments.begin();
229        segment != segments.end(); ++segment) {
230     CompositionText::UnderlineAttribute underline;
231
232     switch (segment->style) {
233       case SEGMENT_STYLE_UNDERLINE:
234         underline.type = CompositionText::COMPOSITION_TEXT_UNDERLINE_SINGLE;
235         break;
236       case SEGMENT_STYLE_DOUBLE_UNDERLINE:
237         underline.type = CompositionText::COMPOSITION_TEXT_UNDERLINE_DOUBLE;
238         break;
239       default:
240         continue;
241     }
242
243     underline.start_index = segment->start;
244     underline.end_index = segment->end;
245     composition_text_->mutable_underline_attributes()->push_back(underline);
246   }
247
248   // TODO(nona): Makes focus out mode configuable, if necessary.
249   UpdateComposition(*composition_text_, composition_cursor_, true);
250   return true;
251 }
252
253 bool InputMethodEngine::ClearComposition(int context_id,
254                                          std::string* error)  {
255   if (!active_) {
256     *error = kErrorNotActive;
257     return false;
258   }
259   if (context_id != context_id_ || context_id_ == -1) {
260     *error = kErrorWrongContext;
261     return false;
262   }
263
264   composition_cursor_ = 0;
265   composition_text_.reset(new CompositionText());
266   UpdateComposition(*composition_text_, composition_cursor_, false);
267   return true;
268 }
269
270 bool InputMethodEngine::CommitText(int context_id, const char* text,
271                                    std::string* error) {
272   if (!active_) {
273     // TODO: Commit the text anyways.
274     *error = kErrorNotActive;
275     return false;
276   }
277   if (context_id != context_id_ || context_id_ == -1) {
278     *error = kErrorWrongContext;
279     return false;
280   }
281
282   IMEBridge::Get()->GetInputContextHandler()->CommitText(text);
283
284   // Records times for using input method.
285   if (!start_time_.ToInternalValue())
286     start_time_ = base::Time::Now();
287   end_time_ = base::Time::Now();
288   // Records histograms for counts of commits and committed characters.
289   RecordHistogram("Commit", 1);
290   RecordHistogram("CommitCharacter", GetUtf8StringLength(text));
291   return true;
292 }
293
294 bool InputMethodEngine::SendKeyEvents(
295     int context_id,
296     const std::vector<KeyboardEvent>& events) {
297   if (!active_) {
298     return false;
299   }
300   // context_id  ==  0, means sending key events to non-input field.
301   // context_id_ == -1, means the focus is not in an input field.
302   if (context_id != 0 && (context_id != context_id_ || context_id_ == -1)) {
303     return false;
304   }
305
306   ui::EventProcessor* dispatcher =
307       ash::Shell::GetPrimaryRootWindow()->GetHost()->event_processor();
308
309   for (size_t i = 0; i < events.size(); ++i) {
310     const KeyboardEvent& event = events[i];
311     const ui::EventType type =
312         (event.type == "keyup") ? ui::ET_KEY_RELEASED : ui::ET_KEY_PRESSED;
313     ui::KeyboardCode key_code = static_cast<ui::KeyboardCode>(event.key_code);
314     if (key_code == ui::VKEY_UNKNOWN)
315       key_code = ui::DomKeycodeToKeyboardCode(event.code);
316
317     int flags = ui::EF_NONE;
318     flags |= event.alt_key   ? ui::EF_ALT_DOWN       : ui::EF_NONE;
319     flags |= event.ctrl_key  ? ui::EF_CONTROL_DOWN   : ui::EF_NONE;
320     flags |= event.shift_key ? ui::EF_SHIFT_DOWN     : ui::EF_NONE;
321     flags |= event.caps_lock ? ui::EF_CAPS_LOCK_DOWN : ui::EF_NONE;
322
323     ui::KeyEvent ui_event(type,
324                           key_code,
325                           event.code,
326                           flags,
327                           false /* is_char */);
328     // 4-bytes UTF-8 string is at least 2-characters UTF-16 string.
329     // And Key char can only be single UTF-16 character.
330     if (!event.key.empty() && event.key.size() < 4) {
331       base::string16 key_char = base::UTF8ToUTF16(event.key);
332       if (key_char.size() == 1)
333         ui_event.set_character(key_char[0]);
334     }
335     base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_,
336                                                         &ui_event);
337     ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&ui_event);
338     if (details.dispatcher_destroyed)
339       break;
340   }
341   return true;
342 }
343
344 const InputMethodEngine::CandidateWindowProperty&
345 InputMethodEngine::GetCandidateWindowProperty() const {
346   return candidate_window_property_;
347 }
348
349 void InputMethodEngine::SetCandidateWindowProperty(
350     const CandidateWindowProperty& property) {
351   // Type conversion from InputMethodEngineInterface::CandidateWindowProperty to
352   // CandidateWindow::CandidateWindowProperty defined in chromeos/ime/.
353   ui::CandidateWindow::CandidateWindowProperty dest_property;
354   dest_property.page_size = property.page_size;
355   dest_property.is_cursor_visible = property.is_cursor_visible;
356   dest_property.is_vertical = property.is_vertical;
357   dest_property.show_window_at_composition =
358       property.show_window_at_composition;
359   dest_property.cursor_position =
360       candidate_window_->GetProperty().cursor_position;
361   dest_property.auxiliary_text = property.auxiliary_text;
362   dest_property.is_auxiliary_text_visible = property.is_auxiliary_text_visible;
363
364   candidate_window_->SetProperty(dest_property);
365   candidate_window_property_ = property;
366
367   if (active_) {
368     IMECandidateWindowHandlerInterface* cw_handler =
369         IMEBridge::Get()->GetCandidateWindowHandler();
370     if (cw_handler)
371       cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
372   }
373 }
374
375 bool InputMethodEngine::SetCandidateWindowVisible(bool visible,
376                                                   std::string* error) {
377   if (!active_) {
378     *error = kErrorNotActive;
379     return false;
380   }
381
382   window_visible_ = visible;
383   IMECandidateWindowHandlerInterface* cw_handler =
384       IMEBridge::Get()->GetCandidateWindowHandler();
385   if (cw_handler)
386     cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
387   return true;
388 }
389
390 bool InputMethodEngine::SetCandidates(
391     int context_id,
392     const std::vector<Candidate>& candidates,
393     std::string* error) {
394   if (!active_) {
395     *error = kErrorNotActive;
396     return false;
397   }
398   if (context_id != context_id_ || context_id_ == -1) {
399     *error = kErrorWrongContext;
400     return false;
401   }
402
403   // TODO: Nested candidates
404   candidate_ids_.clear();
405   candidate_indexes_.clear();
406   candidate_window_->mutable_candidates()->clear();
407   for (std::vector<Candidate>::const_iterator ix = candidates.begin();
408        ix != candidates.end(); ++ix) {
409     ui::CandidateWindow::Entry entry;
410     entry.value = base::UTF8ToUTF16(ix->value);
411     entry.label = base::UTF8ToUTF16(ix->label);
412     entry.annotation = base::UTF8ToUTF16(ix->annotation);
413     entry.description_title = base::UTF8ToUTF16(ix->usage.title);
414     entry.description_body = base::UTF8ToUTF16(ix->usage.body);
415
416     // Store a mapping from the user defined ID to the candidate index.
417     candidate_indexes_[ix->id] = candidate_ids_.size();
418     candidate_ids_.push_back(ix->id);
419
420     candidate_window_->mutable_candidates()->push_back(entry);
421   }
422   if (active_) {
423     IMECandidateWindowHandlerInterface* cw_handler =
424         IMEBridge::Get()->GetCandidateWindowHandler();
425     if (cw_handler)
426       cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
427   }
428   return true;
429 }
430
431 bool InputMethodEngine::SetCursorPosition(int context_id, int candidate_id,
432                                           std::string* error) {
433   if (!active_) {
434     *error = kErrorNotActive;
435     return false;
436   }
437   if (context_id != context_id_ || context_id_ == -1) {
438     *error = kErrorWrongContext;
439     return false;
440   }
441
442   std::map<int, int>::const_iterator position =
443       candidate_indexes_.find(candidate_id);
444   if (position == candidate_indexes_.end()) {
445     *error = kCandidateNotFound;
446     return false;
447   }
448
449   candidate_window_->set_cursor_position(position->second);
450   IMECandidateWindowHandlerInterface* cw_handler =
451       IMEBridge::Get()->GetCandidateWindowHandler();
452   if (cw_handler)
453     cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
454   return true;
455 }
456
457 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) {
458   return UpdateMenuItems(items);
459 }
460
461 bool InputMethodEngine::UpdateMenuItems(
462     const std::vector<MenuItem>& items) {
463   if (!active_)
464     return false;
465
466   ash::ime::InputMethodMenuItemList menu_item_list;
467   for (std::vector<MenuItem>::const_iterator item = items.begin();
468        item != items.end(); ++item) {
469     ash::ime::InputMethodMenuItem property;
470     MenuItemToProperty(*item, &property);
471     menu_item_list.push_back(property);
472   }
473
474   ash::ime::InputMethodMenuManager::GetInstance()->
475       SetCurrentInputMethodMenuItemList(
476           menu_item_list);
477   return true;
478 }
479
480 bool InputMethodEngine::IsActive() const {
481   return active_;
482 }
483
484 bool InputMethodEngine::DeleteSurroundingText(int context_id,
485                                               int offset,
486                                               size_t number_of_chars,
487                                               std::string* error) {
488   if (!active_) {
489     *error = kErrorNotActive;
490     return false;
491   }
492   if (context_id != context_id_ || context_id_ == -1) {
493     *error = kErrorWrongContext;
494     return false;
495   }
496
497   if (offset < 0 && static_cast<size_t>(-1 * offset) != size_t(number_of_chars))
498     return false;  // Currently we can only support preceding text.
499
500   // TODO(nona): Return false if there is ongoing composition.
501
502   IMEInputContextHandlerInterface* input_context =
503       IMEBridge::Get()->GetInputContextHandler();
504   if (input_context)
505     input_context->DeleteSurroundingText(offset, number_of_chars);
506
507   return true;
508 }
509
510 void InputMethodEngine::HideInputView() {
511   keyboard::KeyboardController* keyboard_controller =
512     keyboard::KeyboardController::GetInstance();
513   if (keyboard_controller) {
514     keyboard_controller->HideKeyboard(
515         keyboard::KeyboardController::HIDE_REASON_MANUAL);
516   }
517 }
518
519 void InputMethodEngine::EnableInputView(bool enabled) {
520   const GURL& url = enabled ? input_view_url_ : GURL();
521   keyboard::SetOverrideContentUrl(url);
522   keyboard::KeyboardController* keyboard_controller =
523       keyboard::KeyboardController::GetInstance();
524   if (keyboard_controller)
525     keyboard_controller->Reload();
526 }
527
528 void InputMethodEngine::FocusIn(
529     const IMEEngineHandlerInterface::InputContext& input_context) {
530   current_input_type_ = input_context.type;
531
532   if (!active_ || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
533     return;
534
535   context_id_ = next_context_id_;
536   ++next_context_id_;
537
538   InputMethodEngineInterface::InputContext context;
539   context.id = context_id_;
540   switch (current_input_type_) {
541     case ui::TEXT_INPUT_TYPE_SEARCH:
542       context.type = "search";
543       break;
544     case ui::TEXT_INPUT_TYPE_TELEPHONE:
545       context.type = "tel";
546       break;
547     case ui::TEXT_INPUT_TYPE_URL:
548       context.type = "url";
549       break;
550     case ui::TEXT_INPUT_TYPE_EMAIL:
551       context.type = "email";
552       break;
553     case ui::TEXT_INPUT_TYPE_NUMBER:
554       context.type = "number";
555       break;
556     case ui::TEXT_INPUT_TYPE_PASSWORD:
557       context.type = "password";
558       break;
559     default:
560       context.type = "text";
561       break;
562   }
563
564   observer_->OnFocus(context);
565 }
566
567 void InputMethodEngine::FocusOut() {
568   if (!active_ || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
569     return;
570
571   current_input_type_ = ui::TEXT_INPUT_TYPE_NONE;
572
573   int context_id = context_id_;
574   context_id_ = -1;
575   observer_->OnBlur(context_id);
576 }
577
578 void InputMethodEngine::Enable() {
579   active_ = true;
580   observer_->OnActivate(engine_id_);
581   current_input_type_ = IMEBridge::Get()->GetCurrentTextInputType();
582   FocusIn(IMEEngineHandlerInterface::InputContext(
583       current_input_type_, ui::TEXT_INPUT_MODE_DEFAULT));
584   EnableInputView(true);
585
586   start_time_ = base::Time();
587   end_time_ = base::Time();
588   RecordHistogram("Enable", 1);
589 }
590
591 void InputMethodEngine::Disable() {
592   active_ = false;
593   observer_->OnDeactivated(engine_id_);
594
595   if (start_time_.ToInternalValue())
596     RecordHistogram("WorkingTime", (end_time_ - start_time_).InSeconds());
597 }
598
599 void InputMethodEngine::PropertyActivate(const std::string& property_name) {
600   observer_->OnMenuItemActivated(engine_id_, property_name);
601 }
602
603 void InputMethodEngine::Reset() {
604   observer_->OnReset(engine_id_);
605 }
606
607 void InputMethodEngine::ProcessKeyEvent(
608     const ui::KeyEvent& key_event,
609     const KeyEventDoneCallback& callback) {
610
611   KeyEventDoneCallback *handler = new KeyEventDoneCallback();
612   *handler = callback;
613
614   KeyboardEvent ext_event;
615   GetExtensionKeyboardEventFromKeyEvent(key_event, &ext_event);
616
617   // If the given key event is equal to the key event sent by
618   // SendKeyEvents, this engine ID is propagated to the extension IME.
619   // Note, this check relies on that ui::KeyEvent is propagated as
620   // reference without copying.
621   if (&key_event == sent_key_event_)
622     ext_event.extension_id = extension_id_;
623
624   observer_->OnKeyEvent(
625       engine_id_,
626       ext_event,
627       reinterpret_cast<input_method::KeyEventHandle*>(handler));
628 }
629
630 void InputMethodEngine::CandidateClicked(uint32 index) {
631   if (index > candidate_ids_.size()) {
632     return;
633   }
634
635   // Only left button click is supported at this moment.
636   observer_->OnCandidateClicked(
637       engine_id_, candidate_ids_.at(index), MOUSE_BUTTON_LEFT);
638 }
639
640 void InputMethodEngine::SetSurroundingText(const std::string& text,
641                                            uint32 cursor_pos,
642                                            uint32 anchor_pos) {
643   observer_->OnSurroundingTextChanged(engine_id_,
644                                       text,
645                                       static_cast<int>(cursor_pos),
646                                       static_cast<int>(anchor_pos));
647 }
648
649 // TODO(uekawa): rename this method to a more reasonable name.
650 void InputMethodEngine::MenuItemToProperty(
651     const MenuItem& item,
652     ash::ime::InputMethodMenuItem* property) {
653   property->key = item.id;
654
655   if (item.modified & MENU_ITEM_MODIFIED_LABEL) {
656     property->label = item.label;
657   }
658   if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) {
659     // TODO(nona): Implement it.
660   }
661   if (item.modified & MENU_ITEM_MODIFIED_CHECKED) {
662     property->is_selection_item_checked = item.checked;
663   }
664   if (item.modified & MENU_ITEM_MODIFIED_ENABLED) {
665     // TODO(nona): implement sensitive entry(crbug.com/140192).
666   }
667   if (item.modified & MENU_ITEM_MODIFIED_STYLE) {
668     if (!item.children.empty()) {
669       // TODO(nona): Implement it.
670     } else {
671       switch (item.style) {
672         case MENU_ITEM_STYLE_NONE:
673           NOTREACHED();
674           break;
675         case MENU_ITEM_STYLE_CHECK:
676           // TODO(nona): Implement it.
677           break;
678         case MENU_ITEM_STYLE_RADIO:
679           property->is_selection_item = true;
680           break;
681         case MENU_ITEM_STYLE_SEPARATOR:
682           // TODO(nona): Implement it.
683           break;
684       }
685     }
686   }
687
688   // TODO(nona): Support item.children.
689 }
690
691 }  // namespace chromeos