Chromium Code Reviews| Index: chrome/browser/autocomplete/autocomplete_edit.h |
| diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h |
| index 83c87c3965c8071353fda18c431c032c6914793c..3dadab77ac216e4788926220591f67da2f9ae614 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_edit.h |
| +++ b/chrome/browser/autocomplete/autocomplete_edit.h |
| @@ -99,38 +99,26 @@ class AutocompleteEditController { |
| // Returns the title of the current page. |
| virtual std::wstring GetTitle() const = 0; |
| + // Returns true if the keyword hint UI is visible. |
| + virtual bool IsKeywordHintVisible() const = 0; |
|
Peter Kasting
2011/01/14 00:43:31
This addition seems a little odd to me. The Autoc
James Su
2011/01/14 01:03:54
They keyword hint UI may not be visible if the bro
Peter Kasting
2011/01/14 01:20:01
The hint is just a hint. It is important that spa
James Su
2011/01/14 02:02:46
Existing code doesn't accept keyword by Tab key if
Peter Kasting
2011/01/14 02:30:36
Yeah, that seems like a bug.
James Su
2011/01/14 03:26:22
According to the original code, it's on purpose ra
Peter Kasting
2011/01/14 17:31:33
I am the UX designer. The original code was wrong
James Su
2011/01/14 18:04:12
Ok, I'll remove those code. It even makes the code
|
| + |
| protected: |
| virtual ~AutocompleteEditController(); |
| }; |
| class AutocompleteEditModel : public NotificationObserver { |
| public: |
| - enum KeywordUIState { |
| - // The user is typing normally. |
| - NORMAL, |
| - // The user is editing in the middle of the input string. Even if the |
| - // input looks like a keyword, don't display the keyword UI, as to not |
| - // interfere with the user's editing. |
| - NO_KEYWORD, |
| - // The user has triggered the keyword UI. Until it disappears, bias |
| - // autocomplete results so that input strings of the keyword alone default |
| - // to the keyword provider, not a normal navigation or search. |
| - KEYWORD, |
| - }; |
| - |
| struct State { |
| State(bool user_input_in_progress, |
| const std::wstring& user_text, |
| const std::wstring& keyword, |
| - bool is_keyword_hint, |
| - KeywordUIState keyword_ui_state); |
| + bool is_keyword_hint); |
| ~State(); |
| bool user_input_in_progress; |
| const std::wstring user_text; |
| const std::wstring keyword; |
| const bool is_keyword_hint; |
| - const KeywordUIState keyword_ui_state; |
| }; |
| AutocompleteEditModel(AutocompleteEditView* view, |
| @@ -258,10 +246,7 @@ class AutocompleteEditModel : public NotificationObserver { |
| // Accessors for keyword-related state (see comments on keyword_ and |
| // is_keyword_hint_). |
| - std::wstring keyword() const { |
| - return (is_keyword_hint_ || (keyword_ui_state_ != NO_KEYWORD)) ? |
| - keyword_ : std::wstring(); |
| - } |
| + const std::wstring& keyword() const { return keyword_; } |
| bool is_keyword_hint() const { return is_keyword_hint_; } |
| // Accepts the current keyword hint as a keyword. |
| @@ -297,8 +282,9 @@ class AutocompleteEditModel : public NotificationObserver { |
| // necessary. |
| void OnControlKeyChanged(bool pressed); |
| - // Called when the user pastes in text that replaces the entire edit contents. |
| - void on_paste_replacing_all() { paste_state_ = REPLACING_ALL; } |
| + // Called when the user pastes in text. |replacing_all| should be true if the |
| + // entire edit contents is being replaced. |
| + void OnPaste(bool replacing_all); |
| // Called when the user presses up or down. |count| is a repeat count, |
| // negative for moving up, positive for moving down. |
| @@ -353,6 +339,8 @@ class AutocompleteEditModel : public NotificationObserver { |
| // for every edit. If OnPaste() set the state directly to |
| // REPLACED_ALL, OnAfterPossibleChange() wouldn't know |
| // whether that represented the current edit or a past one. |
| + PASTED, // Most recent edit was a normal paste. |
| + PASTING, // Like REPLACING_ALL, but indicating a normal paste. |
| }; |
| enum ControlKeyState { |
| @@ -403,6 +391,10 @@ class AutocompleteEditModel : public NotificationObserver { |
| // on the controller. |
| void UpdateSuggestedSearchText(); |
| + // Accepts current keyword if the user only typed a whitespace at the end of |
| + // |new_user_text|. Returns true if the current keyword is accepted. |
| + bool MaybeAcceptKeywordBySpace(const std::wstring& new_user_text); |
| + |
| AutocompleteEditView* view_; |
| AutocompletePopupModel* popup_; |
| @@ -471,7 +463,6 @@ class AutocompleteEditModel : public NotificationObserver { |
| // them and not revert all the way to the permanent_text_. |
| bool has_temporary_text_; |
| GURL original_url_; |
| - KeywordUIState original_keyword_ui_state_; |
| // When the user's last action was to paste and replace all the text, we |
| // disallow inline autocomplete (on the theory that the user is trying to |
| @@ -495,9 +486,6 @@ class AutocompleteEditModel : public NotificationObserver { |
| // keyword_ to show a "Press <tab> to search" sort of hint. |
| bool is_keyword_hint_; |
| - // See KeywordUIState enum. |
| - KeywordUIState keyword_ui_state_; |
| - |
| // Paste And Go-related state. See CanPasteAndGo(). |
| mutable GURL paste_and_go_url_; |
| mutable PageTransition::Type paste_and_go_transition_; |