OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autocomplete/autocomplete_edit.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 // user's selection gets screwy; and if we don't update the popup, and the | 598 // user's selection gets screwy; and if we don't update the popup, and the |
599 // user reverts, then the selected item will be as if control is still | 599 // user reverts, then the selected item will be as if control is still |
600 // pressed, even though maybe it isn't any more. There is no obvious | 600 // pressed, even though maybe it isn't any more. There is no obvious |
601 // right answer here :( | 601 // right answer here :( |
602 } | 602 } |
603 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(text), | 603 view_->OnTemporaryTextMaybeChanged(DisplayTextFromUserText(text), |
604 save_original_selection); | 604 save_original_selection); |
605 return; | 605 return; |
606 } | 606 } |
607 | 607 |
608 // All cases that can result in |has_temporary_text_| being set should have | 608 bool call_controller_onchanged = true; |
609 // been handled by the conditional above. | |
610 DCHECK(!has_temporary_text_); | |
611 | 609 |
Peter Kasting
2011/01/24 23:25:52
Nit: Unnecessary blank line
James Su
2011/01/25 02:24:55
Done.
| |
612 inline_autocomplete_text_ = text; | 610 inline_autocomplete_text_ = text; |
613 if (view_->OnInlineAutocompleteTextMaybeChanged( | 611 if (view_->OnInlineAutocompleteTextMaybeChanged( |
614 DisplayTextFromUserText(user_text_ + inline_autocomplete_text_), | 612 DisplayTextFromUserText(user_text_ + inline_autocomplete_text_), |
615 DisplayTextFromUserText(user_text_).length())) | 613 DisplayTextFromUserText(user_text_).length())) |
616 return; | 614 call_controller_onchanged = false; |
617 | 615 |
618 // All other code paths that return invoke OnChanged. We need to invoke | 616 // |has_temporary_text_| is true here means we have been reverted to the |
Peter Kasting
2011/01/24 23:25:52
Nit: How about:
// If |has_temporary_text_| is
James Su
2011/01/25 02:24:55
Done.
| |
619 // OnChanged in case the destination url changed (as could happen when control | 617 // default match, so we need to ask view to revert as well. We need to do it |
620 // is toggled). | 618 // after updating the display text, to make sure the selection can be reverted |
621 controller_->OnChanged(); | 619 // correctly. |
620 // This route can only be triggered when deleting the selected item in popup. | |
621 if (has_temporary_text_) { | |
622 has_temporary_text_ = false; | |
Peter Kasting
2011/01/24 23:25:52
Let's refactor a little:
[private] void RevertTem
James Su
2011/01/25 02:24:55
It's actually not possible. In OnEscapeKeyPressed(
Peter Kasting
2011/01/25 02:36:20
In that case, let's refactor and make that call a
James Su
2011/01/25 02:51:51
Ok, I'll update it asap.
| |
623 view_->OnRevertTemporaryText(); | |
624 call_controller_onchanged = false; | |
625 } | |
626 | |
627 // We need to invoke OnChanged in case the destination url changed (as could | |
628 // happen when control is toggled). | |
629 if (call_controller_onchanged) | |
630 controller_->OnChanged(); | |
622 } | 631 } |
623 | 632 |
624 bool AutocompleteEditModel::OnAfterPossibleChange( | 633 bool AutocompleteEditModel::OnAfterPossibleChange( |
625 const std::wstring& new_text, | 634 const std::wstring& new_text, |
626 bool selection_differs, | 635 bool selection_differs, |
627 bool text_differs, | 636 bool text_differs, |
628 bool just_deleted_text, | 637 bool just_deleted_text, |
629 bool allow_keyword_ui_change) { | 638 bool allow_keyword_ui_change) { |
630 // Update the paste state as appropriate: if we're just finishing a paste | 639 // Update the paste state as appropriate: if we're just finishing a paste |
631 // that replaced all the text, preserve that information; otherwise, if we've | 640 // that replaced all the text, preserve that information; otherwise, if we've |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 // static | 802 // static |
794 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 803 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
795 switch (c) { | 804 switch (c) { |
796 case 0x0020: // Space | 805 case 0x0020: // Space |
797 case 0x3000: // Ideographic Space | 806 case 0x3000: // Ideographic Space |
798 return true; | 807 return true; |
799 default: | 808 default: |
800 return false; | 809 return false; |
801 } | 810 } |
802 } | 811 } |
OLD | NEW |