| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file defines the interface class AutocompleteEditView. Each toolkit | 5 // This file defines the interface class AutocompleteEditView. Each toolkit |
| 6 // will implement the edit view differently, so that code is inherently | 6 // will implement the edit view differently, so that code is inherently |
| 7 // platform specific. However, the AutocompleteEditModel needs to do some | 7 // platform specific. However, the AutocompleteEditModel needs to do some |
| 8 // communication with the view. Since the model is shared between platforms, | 8 // communication with the view. Since the model is shared between platforms, |
| 9 // we need to define an interface that all view implementations will share. | 9 // we need to define an interface that all view implementations will share. |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // |selected_line| is passed to SendOpenNotification(); see comments there. | 53 // |selected_line| is passed to SendOpenNotification(); see comments there. |
| 54 // | 54 // |
| 55 // If the URL was expanded from a keyword, |keyword| is that keyword. | 55 // If the URL was expanded from a keyword, |keyword| is that keyword. |
| 56 // | 56 // |
| 57 // This may close the popup. | 57 // This may close the popup. |
| 58 virtual void OpenURL(const GURL& url, | 58 virtual void OpenURL(const GURL& url, |
| 59 WindowOpenDisposition disposition, | 59 WindowOpenDisposition disposition, |
| 60 PageTransition::Type transition, | 60 PageTransition::Type transition, |
| 61 const GURL& alternate_nav_url, | 61 const GURL& alternate_nav_url, |
| 62 size_t selected_line, | 62 size_t selected_line, |
| 63 const string16& keyword) = 0; | 63 const std::wstring& keyword) = 0; |
| 64 | 64 |
| 65 // Returns the current text of the edit control, which could be the | 65 // Returns the current text of the edit control, which could be the |
| 66 // "temporary" text set by the popup, the "permanent" text set by the | 66 // "temporary" text set by the popup, the "permanent" text set by the |
| 67 // browser, or just whatever the user has currently typed. | 67 // browser, or just whatever the user has currently typed. |
| 68 virtual string16 GetText() const = 0; | 68 virtual std::wstring GetText() const = 0; |
| 69 | 69 |
| 70 // |true| if the user is in the process of editing the field, or if | 70 // |true| if the user is in the process of editing the field, or if |
| 71 // the field is empty. | 71 // the field is empty. |
| 72 virtual bool IsEditingOrEmpty() const = 0; | 72 virtual bool IsEditingOrEmpty() const = 0; |
| 73 | 73 |
| 74 // Returns the resource ID of the icon to show for the current text. | 74 // Returns the resource ID of the icon to show for the current text. |
| 75 virtual int GetIcon() const = 0; | 75 virtual int GetIcon() const = 0; |
| 76 | 76 |
| 77 // The user text is the text the user has manually keyed in. When present, | 77 // The user text is the text the user has manually keyed in. When present, |
| 78 // this is shown in preference to the permanent text; hitting escape will | 78 // this is shown in preference to the permanent text; hitting escape will |
| 79 // revert to the permanent text. | 79 // revert to the permanent text. |
| 80 virtual void SetUserText(const string16& text) = 0; | 80 virtual void SetUserText(const std::wstring& text) = 0; |
| 81 virtual void SetUserText(const string16& text, | 81 virtual void SetUserText(const std::wstring& text, |
| 82 const string16& display_text, | 82 const std::wstring& display_text, |
| 83 bool update_popup) = 0; | 83 bool update_popup) = 0; |
| 84 | 84 |
| 85 // Sets the window text and the caret position. | 85 // Sets the window text and the caret position. |
| 86 virtual void SetWindowTextAndCaretPos(const string16& text, | 86 virtual void SetWindowTextAndCaretPos(const std::wstring& text, |
| 87 size_t caret_pos) = 0; | 87 size_t caret_pos) = 0; |
| 88 | 88 |
| 89 // Sets the edit to forced query mode. Practically speaking, this means that | 89 // Sets the edit to forced query mode. Practically speaking, this means that |
| 90 // if the edit is not in forced query mode, its text is set to "?" with the | 90 // if the edit is not in forced query mode, its text is set to "?" with the |
| 91 // cursor at the end, and if the edit is in forced query mode (its first | 91 // cursor at the end, and if the edit is in forced query mode (its first |
| 92 // non-whitespace character is '?'), the text after the '?' is selected. | 92 // non-whitespace character is '?'), the text after the '?' is selected. |
| 93 // | 93 // |
| 94 // In the future we should display the search engine UI for the default engine | 94 // In the future we should display the search engine UI for the default engine |
| 95 // rather than '?'. | 95 // rather than '?'. |
| 96 virtual void SetForcedQuery() = 0; | 96 virtual void SetForcedQuery() = 0; |
| 97 | 97 |
| 98 // Returns true if all text is selected or there is no text at all. | 98 // Returns true if all text is selected or there is no text at all. |
| 99 virtual bool IsSelectAll() = 0; | 99 virtual bool IsSelectAll() = 0; |
| 100 | 100 |
| 101 // Returns true if the user deleted the suggested text. | 101 // Returns true if the user deleted the suggested text. |
| 102 virtual bool DeleteAtEndPressed() = 0; | 102 virtual bool DeleteAtEndPressed() = 0; |
| 103 | 103 |
| 104 // Fills |start| and |end| with the indexes of the current selection's bounds. | 104 // Fills |start| and |end| with the indexes of the current selection's bounds. |
| 105 // It is not guaranteed that |*start < *end|, as the selection can be | 105 // It is not guaranteed that |*start < *end|, as the selection can be |
| 106 // directed. If there is no selection, |start| and |end| will both be equal | 106 // directed. If there is no selection, |start| and |end| will both be equal |
| 107 // to the current cursor position. | 107 // to the current cursor position. |
| 108 virtual void GetSelectionBounds(string16::size_type* start, | 108 virtual void GetSelectionBounds(std::wstring::size_type* start, |
| 109 string16::size_type* end) = 0; | 109 std::wstring::size_type* end) = 0; |
| 110 | 110 |
| 111 // Selects all the text in the edit. Use this in place of SetSelAll() to | 111 // Selects all the text in the edit. Use this in place of SetSelAll() to |
| 112 // avoid selecting the "phantom newline" at the end of the edit. | 112 // avoid selecting the "phantom newline" at the end of the edit. |
| 113 virtual void SelectAll(bool reversed) = 0; | 113 virtual void SelectAll(bool reversed) = 0; |
| 114 | 114 |
| 115 // Reverts the edit and popup back to their unedited state (permanent text | 115 // Reverts the edit and popup back to their unedited state (permanent text |
| 116 // showing, popup closed, no user input in progress). | 116 // showing, popup closed, no user input in progress). |
| 117 virtual void RevertAll() = 0; | 117 virtual void RevertAll() = 0; |
| 118 | 118 |
| 119 // Updates the autocomplete popup and other state after the text has been | 119 // Updates the autocomplete popup and other state after the text has been |
| 120 // changed by the user. | 120 // changed by the user. |
| 121 virtual void UpdatePopup() = 0; | 121 virtual void UpdatePopup() = 0; |
| 122 | 122 |
| 123 // Closes the autocomplete popup, if it's open. | 123 // Closes the autocomplete popup, if it's open. |
| 124 virtual void ClosePopup() = 0; | 124 virtual void ClosePopup() = 0; |
| 125 | 125 |
| 126 // Sets the focus to the autocomplete view. | 126 // Sets the focus to the autocomplete view. |
| 127 virtual void SetFocus() = 0; | 127 virtual void SetFocus() = 0; |
| 128 | 128 |
| 129 // Called when the temporary text in the model may have changed. | 129 // Called when the temporary text in the model may have changed. |
| 130 // |display_text| is the new text to show; |save_original_selection| is true | 130 // |display_text| is the new text to show; |save_original_selection| is true |
| 131 // when there wasn't previously a temporary text and thus we need to save off | 131 // when there wasn't previously a temporary text and thus we need to save off |
| 132 // the user's existing selection. | 132 // the user's existing selection. |
| 133 virtual void OnTemporaryTextMaybeChanged(const string16& display_text, | 133 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, |
| 134 bool save_original_selection) = 0; | 134 bool save_original_selection) = 0; |
| 135 | 135 |
| 136 // Called when the inline autocomplete text in the model may have changed. | 136 // Called when the inline autocomplete text in the model may have changed. |
| 137 // |display_text| is the new text to show; |user_text_length| is the length of | 137 // |display_text| is the new text to show; |user_text_length| is the length of |
| 138 // the user input portion of that (so, up to but not including the inline | 138 // the user input portion of that (so, up to but not including the inline |
| 139 // autocompletion). Returns whether the display text actually changed. | 139 // autocompletion). Returns whether the display text actually changed. |
| 140 virtual bool OnInlineAutocompleteTextMaybeChanged( | 140 virtual bool OnInlineAutocompleteTextMaybeChanged( |
| 141 const string16& display_text, size_t user_text_length) = 0; | 141 const std::wstring& display_text, size_t user_text_length) = 0; |
| 142 | 142 |
| 143 // Called when the temporary text has been reverted by the user. This will | 143 // Called when the temporary text has been reverted by the user. This will |
| 144 // reset the user's original selection. | 144 // reset the user's original selection. |
| 145 virtual void OnRevertTemporaryText() = 0; | 145 virtual void OnRevertTemporaryText() = 0; |
| 146 | 146 |
| 147 // Every piece of code that can change the edit should call these functions | 147 // Every piece of code that can change the edit should call these functions |
| 148 // before and after the change. These functions determine if anything | 148 // before and after the change. These functions determine if anything |
| 149 // meaningful changed, and do any necessary updating and notification. | 149 // meaningful changed, and do any necessary updating and notification. |
| 150 virtual void OnBeforePossibleChange() = 0; | 150 virtual void OnBeforePossibleChange() = 0; |
| 151 // OnAfterPossibleChange() returns true if there was a change that caused it | 151 // OnAfterPossibleChange() returns true if there was a change that caused it |
| (...skipping 15 matching lines...) Expand all Loading... |
| 167 | 167 |
| 168 // Returns true if the user is composing something in an IME. | 168 // Returns true if the user is composing something in an IME. |
| 169 virtual bool IsImeComposing() const = 0; | 169 virtual bool IsImeComposing() const = 0; |
| 170 | 170 |
| 171 #if defined(TOOLKIT_VIEWS) | 171 #if defined(TOOLKIT_VIEWS) |
| 172 // Adds the autocomplete edit view to view hierarchy and | 172 // Adds the autocomplete edit view to view hierarchy and |
| 173 // returns the views::View of the edit view. | 173 // returns the views::View of the edit view. |
| 174 virtual views::View* AddToView(views::View* parent) = 0; | 174 virtual views::View* AddToView(views::View* parent) = 0; |
| 175 | 175 |
| 176 // Commits the suggested text. | 176 // Commits the suggested text. |
| 177 virtual bool CommitInstantSuggestion(const string16& typed_text, | 177 virtual bool CommitInstantSuggestion(const std::wstring& typed_text, |
| 178 const string16& suggested_text) = 0; | 178 const std::wstring& suggested_text) = 0; |
| 179 #endif | 179 #endif |
| 180 | 180 |
| 181 virtual ~AutocompleteEditView() {} | 181 virtual ~AutocompleteEditView() {} |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_H_ | 184 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_H_ |
| OLD | NEW |