| 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_VIEWS_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_VIEWS_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_VIEWS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 bool HandleAfterKeyEvent(const views::KeyEvent& event, bool handled); | 59 bool HandleAfterKeyEvent(const views::KeyEvent& event, bool handled); |
| 60 | 60 |
| 61 // Called when KeyRelease event is generated on textfield. | 61 // Called when KeyRelease event is generated on textfield. |
| 62 bool HandleKeyReleaseEvent(const views::KeyEvent& event); | 62 bool HandleKeyReleaseEvent(const views::KeyEvent& event); |
| 63 | 63 |
| 64 // Called when Focus is set/unset on textfield. | 64 // Called when Focus is set/unset on textfield. |
| 65 void HandleFocusIn(); | 65 void HandleFocusIn(); |
| 66 void HandleFocusOut(); | 66 void HandleFocusOut(); |
| 67 | 67 |
| 68 // Implements views::View | 68 // Implements views::View |
| 69 virtual bool OnMousePressed(const views::MouseEvent& event); | 69 virtual void Layout() OVERRIDE; |
| 70 virtual void Layout(); | |
| 71 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 70 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 72 | 71 |
| 73 // Implement the AutocompleteEditView interface. | 72 // Implement the AutocompleteEditView interface. |
| 74 virtual AutocompleteEditModel* model(); | 73 virtual AutocompleteEditModel* model() OVERRIDE; |
| 75 virtual const AutocompleteEditModel* model() const; | 74 virtual const AutocompleteEditModel* model() const OVERRIDE; |
| 76 | 75 |
| 77 virtual void SaveStateToTab(TabContents* tab); | 76 virtual void SaveStateToTab(TabContents* tab) OVERRIDE; |
| 78 | 77 |
| 79 virtual void Update(const TabContents* tab_for_state_restoring); | 78 virtual void Update(const TabContents* tab_for_state_restoring) OVERRIDE; |
| 80 | 79 |
| 81 virtual void OpenURL(const GURL& url, | 80 virtual void OpenURL(const GURL& url, |
| 82 WindowOpenDisposition disposition, | 81 WindowOpenDisposition disposition, |
| 83 PageTransition::Type transition, | 82 PageTransition::Type transition, |
| 84 const GURL& alternate_nav_url, | 83 const GURL& alternate_nav_url, |
| 85 size_t selected_line, | 84 size_t selected_line, |
| 86 const string16& keyword); | 85 const string16& keyword) OVERRIDE; |
| 87 | 86 |
| 88 virtual string16 GetText() const; | 87 virtual string16 GetText() const OVERRIDE; |
| 89 | 88 |
| 90 virtual bool IsEditingOrEmpty() const; | 89 virtual bool IsEditingOrEmpty() const OVERRIDE; |
| 91 virtual int GetIcon() const; | 90 virtual int GetIcon() const OVERRIDE; |
| 92 virtual void SetUserText(const string16& text); | 91 virtual void SetUserText(const string16& text) OVERRIDE; |
| 93 virtual void SetUserText(const string16& text, | 92 virtual void SetUserText(const string16& text, |
| 94 const string16& display_text, | 93 const string16& display_text, |
| 95 bool update_popup); | 94 bool update_popup) OVERRIDE; |
| 96 virtual void SetWindowTextAndCaretPos(const string16& text, | 95 virtual void SetWindowTextAndCaretPos(const string16& text, |
| 97 size_t caret_pos); | 96 size_t caret_pos) OVERRIDE; |
| 98 virtual void SetForcedQuery(); | 97 virtual void SetForcedQuery() OVERRIDE; |
| 99 virtual bool IsSelectAll(); | 98 virtual bool IsSelectAll() OVERRIDE; |
| 100 virtual bool DeleteAtEndPressed(); | 99 virtual bool DeleteAtEndPressed() OVERRIDE; |
| 101 virtual void GetSelectionBounds(string16::size_type* start, | 100 virtual void GetSelectionBounds(string16::size_type* start, |
| 102 string16::size_type* end); | 101 string16::size_type* end) OVERRIDE; |
| 103 virtual void SelectAll(bool reversed); | 102 virtual void SelectAll(bool reversed) OVERRIDE; |
| 104 virtual void RevertAll(); | 103 virtual void RevertAll() OVERRIDE; |
| 105 virtual void UpdatePopup(); | 104 virtual void UpdatePopup() OVERRIDE; |
| 106 virtual void ClosePopup(); | 105 virtual void ClosePopup() OVERRIDE; |
| 107 virtual void SetFocus(); | 106 virtual void SetFocus() OVERRIDE; |
| 108 virtual void OnTemporaryTextMaybeChanged(const string16& display_text, | 107 virtual void OnTemporaryTextMaybeChanged( |
| 109 bool save_original_selection); | 108 const string16& display_text, |
| 109 bool save_original_selection) OVERRIDE; |
| 110 virtual bool OnInlineAutocompleteTextMaybeChanged( | 110 virtual bool OnInlineAutocompleteTextMaybeChanged( |
| 111 const string16& display_text, size_t user_text_length); | 111 const string16& display_text, size_t user_text_length) OVERRIDE; |
| 112 virtual void OnRevertTemporaryText(); | 112 virtual void OnRevertTemporaryText() OVERRIDE; |
| 113 virtual void OnBeforePossibleChange(); | 113 virtual void OnBeforePossibleChange() OVERRIDE; |
| 114 virtual bool OnAfterPossibleChange(); | 114 virtual bool OnAfterPossibleChange() OVERRIDE; |
| 115 virtual gfx::NativeView GetNativeView() const; | 115 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
| 116 virtual CommandUpdater* GetCommandUpdater(); | 116 virtual CommandUpdater* GetCommandUpdater() OVERRIDE; |
| 117 virtual void SetInstantSuggestion(const string16& input, | 117 virtual void SetInstantSuggestion(const string16& input, |
| 118 bool animate_to_complete); | 118 bool animate_to_complete) OVERRIDE; |
| 119 virtual string16 GetInstantSuggestion() const; | 119 virtual string16 GetInstantSuggestion() const OVERRIDE; |
| 120 virtual int TextWidth() const; | 120 virtual int TextWidth() const OVERRIDE; |
| 121 virtual bool IsImeComposing() const; | 121 virtual bool IsImeComposing() const OVERRIDE; |
| 122 virtual views::View* AddToView(views::View* parent); | 122 virtual views::View* AddToView(views::View* parent) OVERRIDE; |
| 123 virtual int OnPerformDrop(const views::DropTargetEvent& event); | 123 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE; |
| 124 | 124 |
| 125 // NotificationObserver: | 125 // NotificationObserver: |
| 126 virtual void Observe(NotificationType type, | 126 virtual void Observe(NotificationType type, |
| 127 const NotificationSource& source, | 127 const NotificationSource& source, |
| 128 const NotificationDetails& details); | 128 const NotificationDetails& details) OVERRIDE; |
| 129 | 129 |
| 130 // views::TextfieldController: | 130 // views::TextfieldController: |
| 131 virtual void ContentsChanged(views::Textfield* sender, | 131 virtual void ContentsChanged(views::Textfield* sender, |
| 132 const string16& new_contents); | 132 const string16& new_contents) OVERRIDE; |
| 133 virtual bool HandleKeyEvent(views::Textfield* sender, | 133 virtual bool HandleKeyEvent(views::Textfield* sender, |
| 134 const views::KeyEvent& key_event); | 134 const views::KeyEvent& key_event) OVERRIDE; |
| 135 virtual void OnBeforeUserAction(views::Textfield* sender) OVERRIDE; |
| 136 virtual void OnAfterUserAction(views::Textfield* sender) OVERRIDE; |
| 135 | 137 |
| 136 private: | 138 private: |
| 137 // Return the number of characers in the current buffer. | 139 // Return the number of characers in the current buffer. |
| 138 size_t GetTextLength() const; | 140 size_t GetTextLength() const; |
| 139 | 141 |
| 140 // Try to parse the current text as a URL and colorize the components. | 142 // Try to parse the current text as a URL and colorize the components. |
| 141 void EmphasizeURLComponents(); | 143 void EmphasizeURLComponents(); |
| 142 | 144 |
| 143 // Internally invoked whenever the text changes in some way. | 145 // Internally invoked whenever the text changes in some way. |
| 144 void TextChanged(); | 146 void TextChanged(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 173 | 175 |
| 174 ToolbarModel::SecurityLevel security_level_; | 176 ToolbarModel::SecurityLevel security_level_; |
| 175 | 177 |
| 176 // Selection at the point where the user started using the | 178 // Selection at the point where the user started using the |
| 177 // arrows to move around in the popup. | 179 // arrows to move around in the popup. |
| 178 ui::Range saved_temporary_selection_; | 180 ui::Range saved_temporary_selection_; |
| 179 | 181 |
| 180 // Tracking state before and after a possible change. | 182 // Tracking state before and after a possible change. |
| 181 string16 text_before_change_; | 183 string16 text_before_change_; |
| 182 ui::Range sel_before_change_; | 184 ui::Range sel_before_change_; |
| 183 | 185 bool ime_composing_before_change_; |
| 184 // TODO(oshima): following flags are copied from gtk implementation. | |
| 185 // It should be possible to refactor this class to simplify flags and | |
| 186 // logic. I'll work on this refactoring once all features are completed. | |
| 187 | |
| 188 // Indicates whether the IME changed the text. It's possible for the IME to | |
| 189 // handle a key event but not change the text contents (e.g., when pressing | |
| 190 // shift+del with no selection). | |
| 191 bool text_changed_; | |
| 192 | |
| 193 // Was delete pressed? | |
| 194 bool delete_was_pressed_; | |
| 195 | 186 |
| 196 // Was the delete key pressed with an empty selection at the end of the edit? | 187 // Was the delete key pressed with an empty selection at the end of the edit? |
| 197 bool delete_at_end_pressed_; | 188 bool delete_at_end_pressed_; |
| 198 | 189 |
| 199 // Indicates if we are handling a key press event. | |
| 200 bool handling_key_press_; | |
| 201 | |
| 202 // Indicates if omnibox's content maybe changed by a key press event, so that | |
| 203 // we need to call OnAfterPossibleChange() after handling the event. | |
| 204 // This flag should be set for changes directly caused by a key press event, | |
| 205 // including changes to content text, selection range and preedit string. | |
| 206 // Changes caused by function calls like SetUserText() should not affect this | |
| 207 // flag. | |
| 208 bool content_maybe_changed_by_key_press_; | |
| 209 | |
| 210 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewViews); | 190 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewViews); |
| 211 }; | 191 }; |
| 212 | 192 |
| 213 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_VIEWS_H_ | 193 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_VIEWS_H_ |
| OLD | NEW |