Chromium Code Reviews| Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
| =================================================================== |
| --- chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm (revision 119601) |
| +++ chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm (working copy) |
| @@ -329,11 +329,8 @@ |
| model_->SetUserText(text); |
| // TODO(shess): TODO below from gtk. |
| // TODO(deanm): something about selection / focus change here. |
| - SetText(display_text); |
| - if (update_popup) { |
| - UpdatePopup(); |
| - } |
| - model_->OnChanged(); |
| + SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, |
| + true); |
| } |
| NSRange OmniboxViewMac::GetSelectedRange() const { |
| @@ -364,9 +361,17 @@ |
| } |
| void OmniboxViewMac::SetWindowTextAndCaretPos(const string16& text, |
| - size_t caret_pos) { |
| + size_t caret_pos, |
| + bool update_popup, |
| + bool notify_text_changed) { |
| DCHECK_LE(caret_pos, text.size()); |
| SetTextAndSelectedRange(text, NSMakeRange(caret_pos, caret_pos)); |
| + |
| + if (update_popup) |
| + UpdatePopup(); |
| + |
| + if (notify_text_changed) |
| + TextChanged(); |
| } |
| void OmniboxViewMac::SetForcedQuery() { |
| @@ -532,6 +537,11 @@ |
| } |
| } |
| +void OmniboxViewMac::TextChanged() { |
| + EmphasizeURLComponents(); |
| + model_->OnChanged(); |
| +} |
| + |
| void OmniboxViewMac::ApplyTextAttributes(const string16& display_text, |
| NSMutableAttributedString* as) { |
| NSUInteger as_length = [as length]; |
| @@ -606,7 +616,7 @@ |
| saved_temporary_selection_ = GetSelectedRange(); |
| suggest_text_length_ = 0; |
| - SetWindowTextAndCaretPos(display_text, display_text.size()); |
| + SetWindowTextAndCaretPos(display_text, display_text.size(), false, false); |
| model_->OnChanged(); |
| [field_ clearUndoChain]; |
| } |
| @@ -698,8 +708,7 @@ |
| // Linux watches for something_changed && text_differs, but that |
| // fails for us in case you copy the URL and paste the identical URL |
| // back (we'll lose the styling). |
| - EmphasizeURLComponents(); |
| - model_->OnChanged(); |
| + TextChanged(); |
| delete_was_pressed_ = false; |
| @@ -793,7 +802,7 @@ |
| if (cmd == @selector(deleteForward:)) |
| delete_was_pressed_ = true; |
| - // Don't intercept up/down-arrow if the popup isn't open. |
| + // Don't intercept up/down-arrow or backtab if the popup isn't open. |
| if (popup_view_->IsOpen()) { |
| if (cmd == @selector(moveDown:)) { |
| model_->OnUpOrDownKeyPressed(1); |
| @@ -804,6 +813,14 @@ |
| model_->OnUpOrDownKeyPressed(-1); |
| return true; |
| } |
| + |
| + if (cmd == @selector(insertBacktab:)) { |
| + if (model_->popup_model()->selected_line_state() == |
|
Robert Sesek
2012/01/31 19:55:13
nit: You can merge this with the previous if() usi
|
| + AutocompletePopupModel::KEYWORD) { |
| + model_->ClearKeyword(GetText()); |
| + return true; |
| + } |
| + } |
| } |
| if (cmd == @selector(moveRight:)) { |
| @@ -833,22 +850,6 @@ |
| cmd == @selector(insertTabIgnoringFieldEditor:)) { |
| if (model_->is_keyword_hint()) |
| return model_->AcceptKeyword(); |
| - |
| - if (suggest_text_length_ > 0) { |
| - model_->CommitSuggestedText(true); |
| - return true; |
| - } |
| - |
| - if (!IsCaretAtEnd()) { |
| - PlaceCaretAt(GetTextLength()); |
| - // OnDidChange() will not be triggered when setting selected range in this |
| - // method, so we need to call it explicitly. |
| - OnDidChange(); |
| - return true; |
| - } |
| - |
| - if (model_->AcceptCurrentInstantPreview()) |
| - return true; |
| } |
| // |-noop:| is sent when the user presses Cmd+Return. Override the no-op |