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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 void OmniboxEditModel::OnKillFocus() { | 786 void OmniboxEditModel::OnKillFocus() { |
787 // TODO(samarth): determine if it is safe to move the call to | 787 // TODO(samarth): determine if it is safe to move the call to |
788 // OmniboxFocusChanged() from OnWillKillFocus() to here, which would let us | 788 // OmniboxFocusChanged() from OnWillKillFocus() to here, which would let us |
789 // just call SetFocusState() to handle the state change. | 789 // just call SetFocusState() to handle the state change. |
790 focus_state_ = OMNIBOX_FOCUS_NONE; | 790 focus_state_ = OMNIBOX_FOCUS_NONE; |
791 control_key_state_ = UP; | 791 control_key_state_ = UP; |
792 paste_state_ = NONE; | 792 paste_state_ = NONE; |
793 } | 793 } |
794 | 794 |
795 bool OmniboxEditModel::OnEscapeKeyPressed() { | 795 bool OmniboxEditModel::OnEscapeKeyPressed() { |
796 if (has_temporary_text_) { | 796 if (has_temporary_text_ && !is_temporary_text_set_by_instant_) { |
797 AutocompleteMatch match; | 797 AutocompleteMatch match; |
798 InfoForCurrentSelection(&match, NULL); | 798 InfoForCurrentSelection(&match, NULL); |
799 if (match.destination_url != original_url_) { | 799 if (match.destination_url != original_url_) { |
800 RevertTemporaryText(true); | 800 RevertTemporaryText(true); |
801 return true; | 801 return true; |
802 } | 802 } |
803 } | 803 } |
804 | 804 |
805 // We do not clear the pending entry from the omnibox when a load is first | 805 // We do not clear the pending entry from the omnibox when a load is first |
806 // stopped. If the user presses Escape while stopped, we clear it. | 806 // stopped. If the user presses Escape while stopped, we clear it. |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 instant->OmniboxFocusChanged(state, reason, NULL); | 1337 instant->OmniboxFocusChanged(state, reason, NULL); |
1338 | 1338 |
1339 // Update state and notify view if the omnibox has focus and the caret | 1339 // Update state and notify view if the omnibox has focus and the caret |
1340 // visibility changed. | 1340 // visibility changed. |
1341 const bool was_caret_visible = is_caret_visible(); | 1341 const bool was_caret_visible = is_caret_visible(); |
1342 focus_state_ = state; | 1342 focus_state_ = state; |
1343 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1343 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
1344 is_caret_visible() != was_caret_visible) | 1344 is_caret_visible() != was_caret_visible) |
1345 view_->ApplyCaretVisibility(); | 1345 view_->ApplyCaretVisibility(); |
1346 } | 1346 } |
OLD | NEW |