OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/omnibox/browser/omnibox_edit_model.h" | 5 #include "components/omnibox/browser/omnibox_edit_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 // back out of keyword mode. For example, if a user has a keyword named "x", | 802 // back out of keyword mode. For example, if a user has a keyword named "x", |
803 // an inline-autocompletable history site "xyz.com", and a lower-ranked | 803 // an inline-autocompletable history site "xyz.com", and a lower-ranked |
804 // inline-autocompletable search "x y", then typing "x" will inline- | 804 // inline-autocompletable search "x y", then typing "x" will inline- |
805 // autocomplete to "xyz.com", hitting space will toggle into keyword mode, but | 805 // autocomplete to "xyz.com", hitting space will toggle into keyword mode, but |
806 // then hitting backspace could wind up with the default match as the "x y" | 806 // then hitting backspace could wind up with the default match as the "x y" |
807 // search, which feels bizarre. | 807 // search, which feels bizarre. |
808 if (was_toggled_into_keyword_mode && has_temporary_text_) { | 808 if (was_toggled_into_keyword_mode && has_temporary_text_) { |
809 // State 4 above. | 809 // State 4 above. |
810 is_keyword_hint_ = true; | 810 is_keyword_hint_ = true; |
811 const base::string16 window_text = keyword_ + view_->GetText(); | 811 const base::string16 window_text = keyword_ + view_->GetText(); |
812 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), | 812 view_->SetWindowTextAndCaretPos(window_text, keyword_.length(), false, |
813 false, true); | 813 true); |
814 } else { | 814 } else { |
815 // States 1-3 above. | 815 // States 1-3 above. |
816 view_->OnBeforePossibleChange(); | 816 view_->OnBeforePossibleChange(); |
817 // Add a space after the keyword to allow the user to continue typing | 817 // Add a space after the keyword to allow the user to continue typing |
818 // without re-enabling keyword mode. The common case is state 3, where | 818 // without re-enabling keyword mode. The common case is state 3, where |
819 // the user entered keyword mode unintentionally, so backspacing | 819 // the user entered keyword mode unintentionally, so backspacing |
820 // immediately out of keyword mode should keep the space. In states 1 and | 820 // immediately out of keyword mode should keep the space. In states 1 and |
821 // 2, having the space is "safer" behavior. For instance, if the user types | 821 // 2, having the space is "safer" behavior. For instance, if the user types |
822 // "google.com f" or "google.com<tab>f" in the omnibox, moves the cursor to | 822 // "google.com f" or "google.com<tab>f" in the omnibox, moves the cursor to |
823 // the left, and presses backspace to leave keyword mode (state 1), it's | 823 // the left, and presses backspace to leave keyword mode (state 1), it's |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 // Update state and notify view if the omnibox has focus and the caret | 1387 // Update state and notify view if the omnibox has focus and the caret |
1388 // visibility changed. | 1388 // visibility changed. |
1389 const bool was_caret_visible = is_caret_visible(); | 1389 const bool was_caret_visible = is_caret_visible(); |
1390 focus_state_ = state; | 1390 focus_state_ = state; |
1391 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1391 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1392 is_caret_visible() != was_caret_visible) | 1392 is_caret_visible() != was_caret_visible) |
1393 view_->ApplyCaretVisibility(); | 1393 view_->ApplyCaretVisibility(); |
1394 | 1394 |
1395 client_->OnFocusChanged(focus_state_, reason); | 1395 client_->OnFocusChanged(focus_state_, reason); |
1396 } | 1396 } |
OLD | NEW |