ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / input_method_engine.cc
blob8d8522012566fb4a1e9894598b0fc5fb64226230
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 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 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&ui_event);
328 if (details.dispatcher_destroyed)
329 break;
332 return true;
335 const InputMethodEngine::CandidateWindowProperty&
336 InputMethodEngine::GetCandidateWindowProperty() const {
337 return candidate_window_property_;
340 void InputMethodEngine::SetCandidateWindowProperty(
341 const CandidateWindowProperty& property) {
342 // Type conversion from InputMethodEngineInterface::CandidateWindowProperty to
343 // CandidateWindow::CandidateWindowProperty defined in chromeos/ime/.
344 ui::CandidateWindow::CandidateWindowProperty dest_property;
345 dest_property.page_size = property.page_size;
346 dest_property.is_cursor_visible = property.is_cursor_visible;
347 dest_property.is_vertical = property.is_vertical;
348 dest_property.show_window_at_composition =
349 property.show_window_at_composition;
350 dest_property.cursor_position =
351 candidate_window_->GetProperty().cursor_position;
352 dest_property.auxiliary_text = property.auxiliary_text;
353 dest_property.is_auxiliary_text_visible = property.is_auxiliary_text_visible;
355 candidate_window_->SetProperty(dest_property);
356 candidate_window_property_ = property;
358 if (IsActive()) {
359 IMECandidateWindowHandlerInterface* cw_handler =
360 IMEBridge::Get()->GetCandidateWindowHandler();
361 if (cw_handler)
362 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
366 bool InputMethodEngine::SetCandidateWindowVisible(bool visible,
367 std::string* error) {
368 if (!IsActive()) {
369 *error = kErrorNotActive;
370 return false;
373 window_visible_ = visible;
374 IMECandidateWindowHandlerInterface* cw_handler =
375 IMEBridge::Get()->GetCandidateWindowHandler();
376 if (cw_handler)
377 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
378 return true;
381 bool InputMethodEngine::SetCandidates(
382 int context_id,
383 const std::vector<Candidate>& candidates,
384 std::string* error) {
385 if (!IsActive()) {
386 *error = kErrorNotActive;
387 return false;
389 if (context_id != context_id_ || context_id_ == -1) {
390 *error = kErrorWrongContext;
391 return false;
394 // TODO: Nested candidates
395 candidate_ids_.clear();
396 candidate_indexes_.clear();
397 candidate_window_->mutable_candidates()->clear();
398 for (std::vector<Candidate>::const_iterator ix = candidates.begin();
399 ix != candidates.end(); ++ix) {
400 ui::CandidateWindow::Entry entry;
401 entry.value = base::UTF8ToUTF16(ix->value);
402 entry.label = base::UTF8ToUTF16(ix->label);
403 entry.annotation = base::UTF8ToUTF16(ix->annotation);
404 entry.description_title = base::UTF8ToUTF16(ix->usage.title);
405 entry.description_body = base::UTF8ToUTF16(ix->usage.body);
407 // Store a mapping from the user defined ID to the candidate index.
408 candidate_indexes_[ix->id] = candidate_ids_.size();
409 candidate_ids_.push_back(ix->id);
411 candidate_window_->mutable_candidates()->push_back(entry);
413 if (IsActive()) {
414 IMECandidateWindowHandlerInterface* cw_handler =
415 IMEBridge::Get()->GetCandidateWindowHandler();
416 if (cw_handler)
417 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
419 return true;
422 bool InputMethodEngine::SetCursorPosition(int context_id, int candidate_id,
423 std::string* error) {
424 if (!IsActive()) {
425 *error = kErrorNotActive;
426 return false;
428 if (context_id != context_id_ || context_id_ == -1) {
429 *error = kErrorWrongContext;
430 return false;
433 std::map<int, int>::const_iterator position =
434 candidate_indexes_.find(candidate_id);
435 if (position == candidate_indexes_.end()) {
436 *error = kCandidateNotFound;
437 return false;
440 candidate_window_->set_cursor_position(position->second);
441 IMECandidateWindowHandlerInterface* cw_handler =
442 IMEBridge::Get()->GetCandidateWindowHandler();
443 if (cw_handler)
444 cw_handler->UpdateLookupTable(*candidate_window_, window_visible_);
445 return true;
448 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) {
449 return UpdateMenuItems(items);
452 bool InputMethodEngine::UpdateMenuItems(
453 const std::vector<MenuItem>& items) {
454 if (!IsActive())
455 return false;
457 ui::ime::InputMethodMenuItemList menu_item_list;
458 for (std::vector<MenuItem>::const_iterator item = items.begin();
459 item != items.end(); ++item) {
460 ui::ime::InputMethodMenuItem property;
461 MenuItemToProperty(*item, &property);
462 menu_item_list.push_back(property);
465 ui::ime::InputMethodMenuManager::GetInstance()->
466 SetCurrentInputMethodMenuItemList(
467 menu_item_list);
468 return true;
471 bool InputMethodEngine::IsActive() const {
472 return !active_component_id_.empty();
475 bool InputMethodEngine::DeleteSurroundingText(int context_id,
476 int offset,
477 size_t number_of_chars,
478 std::string* error) {
479 if (!IsActive()) {
480 *error = kErrorNotActive;
481 return false;
483 if (context_id != context_id_ || context_id_ == -1) {
484 *error = kErrorWrongContext;
485 return false;
488 // TODO(nona): Return false if there is ongoing composition.
490 IMEInputContextHandlerInterface* input_context =
491 IMEBridge::Get()->GetInputContextHandler();
492 if (input_context)
493 input_context->DeleteSurroundingText(offset, number_of_chars);
495 return true;
498 void InputMethodEngine::HideInputView() {
499 keyboard::KeyboardController* keyboard_controller =
500 keyboard::KeyboardController::GetInstance();
501 if (keyboard_controller) {
502 keyboard_controller->HideKeyboard(
503 keyboard::KeyboardController::HIDE_REASON_MANUAL);
507 void InputMethodEngine::SetCompositionBounds(
508 const std::vector<gfx::Rect>& bounds) {
509 if (!CheckProfile())
510 return;
511 observer_->OnCompositionBoundsChanged(bounds);
514 void InputMethodEngine::EnableInputView() {
515 keyboard::SetOverrideContentUrl(input_method::InputMethodManager::Get()
516 ->GetActiveIMEState()
517 ->GetCurrentInputMethod()
518 .input_view_url());
519 keyboard::KeyboardController* keyboard_controller =
520 keyboard::KeyboardController::GetInstance();
521 if (keyboard_controller)
522 keyboard_controller->Reload();
525 void InputMethodEngine::FocusIn(
526 const IMEEngineHandlerInterface::InputContext& input_context) {
527 if (!CheckProfile())
528 return;
529 current_input_type_ = input_context.type;
531 if (!IsActive() || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
532 return;
534 context_id_ = next_context_id_;
535 ++next_context_id_;
537 InputMethodEngineInterface::InputContext context;
538 context.id = context_id_;
539 switch (current_input_type_) {
540 case ui::TEXT_INPUT_TYPE_SEARCH:
541 context.type = "search";
542 break;
543 case ui::TEXT_INPUT_TYPE_TELEPHONE:
544 context.type = "tel";
545 break;
546 case ui::TEXT_INPUT_TYPE_URL:
547 context.type = "url";
548 break;
549 case ui::TEXT_INPUT_TYPE_EMAIL:
550 context.type = "email";
551 break;
552 case ui::TEXT_INPUT_TYPE_NUMBER:
553 context.type = "number";
554 break;
555 case ui::TEXT_INPUT_TYPE_PASSWORD:
556 context.type = "password";
557 break;
558 default:
559 context.type = "text";
560 break;
563 context.auto_correct =
564 !(input_context.flags & ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF);
565 context.auto_complete =
566 !(input_context.flags & ui::TEXT_INPUT_FLAG_AUTOCOMPLETE_OFF);
567 context.spell_check =
568 !(input_context.flags & ui::TEXT_INPUT_FLAG_SPELLCHECK_OFF);
570 observer_->OnFocus(context);
573 void InputMethodEngine::FocusOut() {
574 if (!CheckProfile())
575 return;
576 if (!IsActive() || current_input_type_ == ui::TEXT_INPUT_TYPE_NONE)
577 return;
579 current_input_type_ = ui::TEXT_INPUT_TYPE_NONE;
581 int context_id = context_id_;
582 context_id_ = -1;
583 observer_->OnBlur(context_id);
586 void InputMethodEngine::Enable(const std::string& component_id) {
587 if (!CheckProfile())
588 return;
589 DCHECK(!component_id.empty());
590 active_component_id_ = component_id;
591 observer_->OnActivate(component_id);
592 const IMEEngineHandlerInterface::InputContext& input_context =
593 IMEBridge::Get()->GetCurrentInputContext();
594 current_input_type_ = input_context.type;
595 FocusIn(input_context);
596 EnableInputView();
599 void InputMethodEngine::Disable() {
600 if (!CheckProfile())
601 return;
602 active_component_id_.clear();
603 IMEBridge::Get()->GetInputContextHandler()->CommitText(
604 base::UTF16ToUTF8(composition_text_->text()));
605 observer_->OnDeactivated(active_component_id_);
608 void InputMethodEngine::PropertyActivate(const std::string& property_name) {
609 if (!CheckProfile())
610 return;
611 observer_->OnMenuItemActivated(active_component_id_, property_name);
614 void InputMethodEngine::Reset() {
615 if (!CheckProfile())
616 return;
617 composition_text_.reset(new CompositionText());
618 observer_->OnReset(active_component_id_);
621 bool InputMethodEngine::IsInterestedInKeyEvent() const {
622 return observer_->IsInterestedInKeyEvent();
625 void InputMethodEngine::ProcessKeyEvent(
626 const ui::KeyEvent& key_event,
627 const KeyEventDoneCallback& callback) {
628 if (!CheckProfile())
629 return;
631 KeyEventDoneCallback* handler = new KeyEventDoneCallback();
632 *handler = callback;
634 KeyboardEvent ext_event;
635 GetExtensionKeyboardEventFromKeyEvent(key_event, &ext_event);
637 // If the given key event is equal to the key event sent by
638 // SendKeyEvents, this engine ID is propagated to the extension IME.
639 // Note, this check relies on that ui::KeyEvent is propagated as
640 // reference without copying.
641 if (&key_event == sent_key_event_)
642 ext_event.extension_id = extension_id_;
644 observer_->OnKeyEvent(
645 active_component_id_,
646 ext_event,
647 reinterpret_cast<input_method::KeyEventHandle*>(handler));
650 void InputMethodEngine::CandidateClicked(uint32 index) {
651 if (!CheckProfile())
652 return;
653 if (index > candidate_ids_.size()) {
654 return;
657 // Only left button click is supported at this moment.
658 observer_->OnCandidateClicked(
659 active_component_id_, candidate_ids_.at(index), MOUSE_BUTTON_LEFT);
662 void InputMethodEngine::SetSurroundingText(const std::string& text,
663 uint32 cursor_pos,
664 uint32 anchor_pos,
665 uint32 offset_pos) {
666 if (!CheckProfile())
667 return;
668 observer_->OnSurroundingTextChanged(
669 active_component_id_, text, static_cast<int>(cursor_pos),
670 static_cast<int>(anchor_pos), static_cast<int>(offset_pos));
673 bool InputMethodEngine::CheckProfile() const {
674 Profile* active_profile = ProfileManager::GetActiveUserProfile();
675 return active_profile == profile_ || profile_->IsSameProfile(active_profile);
678 // TODO(uekawa): rename this method to a more reasonable name.
679 void InputMethodEngine::MenuItemToProperty(
680 const MenuItem& item,
681 ui::ime::InputMethodMenuItem* property) {
682 property->key = item.id;
684 if (item.modified & MENU_ITEM_MODIFIED_LABEL) {
685 property->label = item.label;
687 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) {
688 // TODO(nona): Implement it.
690 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) {
691 property->is_selection_item_checked = item.checked;
693 if (item.modified & MENU_ITEM_MODIFIED_ENABLED) {
694 // TODO(nona): implement sensitive entry(crbug.com/140192).
696 if (item.modified & MENU_ITEM_MODIFIED_STYLE) {
697 if (!item.children.empty()) {
698 // TODO(nona): Implement it.
699 } else {
700 switch (item.style) {
701 case MENU_ITEM_STYLE_NONE:
702 NOTREACHED();
703 break;
704 case MENU_ITEM_STYLE_CHECK:
705 // TODO(nona): Implement it.
706 break;
707 case MENU_ITEM_STYLE_RADIO:
708 property->is_selection_item = true;
709 break;
710 case MENU_ITEM_STYLE_SEPARATOR:
711 // TODO(nona): Implement it.
712 break;
717 // TODO(nona): Support item.children.
720 } // namespace chromeos