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 const base::string16 window_text(keyword_ + |
904 reinterpret_cast<base::char16 const*>(L" ") + visible_text); | |
sky
2014/08/15 18:10:28
This isn't the right way to get a string16. You wa
| |
904 | 905 |
905 // Only reset the result if the edit text has changed since the | 906 // Only reset the result if the edit text has changed since the |
906 // keyword was accepted, or if the popup is closed. | 907 // keyword was accepted, or if the popup is closed. |
907 if (just_deleted_text_ || !visible_text.empty() || | 908 if (just_deleted_text_ || !visible_text.empty() || |
908 !(popup_model() && popup_model()->IsOpen())) { | 909 !(popup_model() && popup_model()->IsOpen())) { |
909 view_->OnBeforePossibleChange(); | 910 view_->OnBeforePossibleChange(); |
910 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), | 911 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1, |
911 false, false); | 912 false, false); |
912 keyword_.clear(); | 913 keyword_.clear(); |
913 is_keyword_hint_ = false; | 914 is_keyword_hint_ = false; |
914 view_->OnAfterPossibleChange(); | 915 view_->OnAfterPossibleChange(); |
915 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this | 916 just_deleted_text_ = true; // OnAfterPossibleChange() fails to clear this |
916 // since the edit contents have actually grown | 917 // since the edit contents have actually grown |
917 // longer. | 918 // longer. |
918 } else { | 919 } else { |
919 is_keyword_hint_ = true; | 920 is_keyword_hint_ = true; |
920 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length(), | 921 view_->SetWindowTextAndCaretPos(window_text.c_str(), keyword_.length() + 1, |
921 false, true); | 922 false, true); |
922 } | 923 } |
923 | 924 |
924 view_->UpdatePlaceholderText(); | 925 view_->UpdatePlaceholderText(); |
925 } | 926 } |
926 | 927 |
927 void OmniboxEditModel::OnSetFocus(bool control_down) { | 928 void OmniboxEditModel::OnSetFocus(bool control_down) { |
928 last_omnibox_focus_ = base::TimeTicks::Now(); | 929 last_omnibox_focus_ = base::TimeTicks::Now(); |
929 user_input_since_focus_ = false; | 930 user_input_since_focus_ = false; |
930 | 931 |
(...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 | 1476 // Update state and notify view if the omnibox has focus and the caret |
1476 // visibility changed. | 1477 // visibility changed. |
1477 const bool was_caret_visible = is_caret_visible(); | 1478 const bool was_caret_visible = is_caret_visible(); |
1478 focus_state_ = state; | 1479 focus_state_ = state; |
1479 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1480 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1480 is_caret_visible() != was_caret_visible) | 1481 is_caret_visible() != was_caret_visible) |
1481 view_->ApplyCaretVisibility(); | 1482 view_->ApplyCaretVisibility(); |
1482 | 1483 |
1483 delegate_->OnFocusChanged(focus_state_, reason); | 1484 delegate_->OnFocusChanged(focus_state_, reason); |
1484 } | 1485 } |
OLD | NEW |