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 "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
893 has_temporary_text_ = false; | 893 has_temporary_text_ = false; |
894 | 894 |
895 if (user_input_in_progress_ || !in_revert_) | 895 if (user_input_in_progress_ || !in_revert_) |
896 delegate_->OnInputStateChanged(); | 896 delegate_->OnInputStateChanged(); |
897 } | 897 } |
898 | 898 |
899 void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) { | 899 void OmniboxEditModel::ClearKeyword(const base::string16& visible_text) { |
900 autocomplete_controller()->Stop(false); | 900 autocomplete_controller()->Stop(false); |
901 omnibox_controller_->ClearPopupKeywordMode(); | 901 omnibox_controller_->ClearPopupKeywordMode(); |
902 | 902 |
903 const base::string16 window_text(keyword_ + visible_text); | 903 // Add a space after the keyword to allow the user to continue typing without |
904 // re-enabling keyword mode | |
Peter Kasting
2015/02/20 01:39:15
Nit: Trailing period
| |
905 const base::string16 window_text = | |
906 keyword_ + base::ASCIIToUTF16(" ") + visible_text; | |
904 | 907 |
905 // Only reset the result if the edit text has changed since the | 908 // Only reset the result if the edit text has changed since the |
906 // keyword was accepted, or if the popup is closed. | 909 // keyword was accepted, or if the popup is closed. |
907 if (just_deleted_text_ || !visible_text.empty() || | 910 if (just_deleted_text_ || !visible_text.empty() || |
908 !(popup_model() && popup_model()->IsOpen())) { | 911 !(popup_model() && popup_model()->IsOpen())) { |
909 view_->OnBeforePossibleChange(); | 912 view_->OnBeforePossibleChange(); |
910 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), | 913 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1, |
911 false, false); | 914 false, false); |
912 keyword_.clear(); | 915 keyword_.clear(); |
913 is_keyword_hint_ = false; | 916 is_keyword_hint_ = false; |
914 view_->OnAfterPossibleChange(); | 917 view_->OnAfterPossibleChange(); |
915 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this | 918 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this |
916 // since the edit contents have actually grown | 919 // since the edit contents have actually grown |
917 // longer. | 920 // longer. |
918 } else { | 921 } else { |
919 is_keyword_hint_ = true; | 922 is_keyword_hint_ = true; |
920 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), | 923 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1, |
921 false, true); | 924 false, true); |
922 } | 925 } |
923 | 926 |
924 view_->UpdatePlaceholderText(); | 927 view_->UpdatePlaceholderText(); |
925 } | 928 } |
926 | 929 |
927 void OmniboxEditModel::OnSetFocus(bool control_down) { | 930 void OmniboxEditModel::OnSetFocus(bool control_down) { |
928 last_omnibox_focus_ = base::TimeTicks::Now(); | 931 last_omnibox_focus_ = base::TimeTicks::Now(); |
929 user_input_since_focus_ = false; | 932 user_input_since_focus_ = false; |
930 | 933 |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1475 // Update state and notify view if the omnibox has focus and the caret | 1478 // Update state and notify view if the omnibox has focus and the caret |
1476 // visibility changed. | 1479 // visibility changed. |
1477 const bool was_caret_visible = is_caret_visible(); | 1480 const bool was_caret_visible = is_caret_visible(); |
1478 focus_state_ = state; | 1481 focus_state_ = state; |
1479 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1482 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1480 is_caret_visible() != was_caret_visible) | 1483 is_caret_visible() != was_caret_visible) |
1481 view_->ApplyCaretVisibility(); | 1484 view_->ApplyCaretVisibility(); |
1482 | 1485 |
1483 delegate_->OnFocusChanged(focus_state_, reason); | 1486 delegate_->OnFocusChanged(focus_state_, reason); |
1484 } | 1487 } |
OLD | NEW |