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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 virtual const AutocompleteEditModel* model() const { return model_.get(); } | 39 virtual const AutocompleteEditModel* model() const { return model_.get(); } |
40 | 40 |
41 virtual void SaveStateToTab(TabContents* tab); | 41 virtual void SaveStateToTab(TabContents* tab); |
42 virtual void Update(const TabContents* tab_for_state_restoring); | 42 virtual void Update(const TabContents* tab_for_state_restoring); |
43 | 43 |
44 virtual void OpenURL(const GURL& url, | 44 virtual void OpenURL(const GURL& url, |
45 WindowOpenDisposition disposition, | 45 WindowOpenDisposition disposition, |
46 PageTransition::Type transition, | 46 PageTransition::Type transition, |
47 const GURL& alternate_nav_url, | 47 const GURL& alternate_nav_url, |
48 size_t selected_line, | 48 size_t selected_line, |
49 const std::wstring& keyword); | 49 const string16& keyword); |
50 | 50 |
51 virtual std::wstring GetText() const; | 51 virtual string16 GetText() const; |
52 | 52 |
53 virtual bool IsEditingOrEmpty() const; | 53 virtual bool IsEditingOrEmpty() const; |
54 virtual int GetIcon() const; | 54 virtual int GetIcon() const; |
55 | 55 |
56 virtual void SetUserText(const std::wstring& text); | 56 virtual void SetUserText(const string16& text); |
57 virtual void SetUserText(const std::wstring& text, | 57 virtual void SetUserText(const string16& text, |
58 const std::wstring& display_text, | 58 const string16& display_text, |
59 bool update_popup); | 59 bool update_popup); |
60 | 60 |
61 virtual void SetWindowTextAndCaretPos(const std::wstring& text, | 61 virtual void SetWindowTextAndCaretPos(const string16& text, |
62 size_t caret_pos); | 62 size_t caret_pos); |
63 | 63 |
64 virtual void SetForcedQuery(); | 64 virtual void SetForcedQuery(); |
65 | 65 |
66 virtual bool IsSelectAll(); | 66 virtual bool IsSelectAll(); |
67 virtual bool DeleteAtEndPressed(); | 67 virtual bool DeleteAtEndPressed(); |
68 virtual void GetSelectionBounds(std::wstring::size_type* start, | 68 virtual void GetSelectionBounds(string16::size_type* start, |
69 std::wstring::size_type* end); | 69 string16::size_type* end); |
70 | 70 |
71 virtual void SelectAll(bool reversed); | 71 virtual void SelectAll(bool reversed); |
72 virtual void RevertAll(); | 72 virtual void RevertAll(); |
73 virtual void UpdatePopup(); | 73 virtual void UpdatePopup(); |
74 virtual void ClosePopup(); | 74 virtual void ClosePopup(); |
75 virtual void SetFocus(); | 75 virtual void SetFocus(); |
76 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, | 76 virtual void OnTemporaryTextMaybeChanged(const string16& display_text, |
77 bool save_original_selection); | 77 bool save_original_selection); |
78 virtual bool OnInlineAutocompleteTextMaybeChanged( | 78 virtual bool OnInlineAutocompleteTextMaybeChanged( |
79 const std::wstring& display_text, size_t user_text_length); | 79 const string16& display_text, size_t user_text_length); |
80 virtual void OnStartingIME(); | 80 virtual void OnStartingIME(); |
81 virtual void OnRevertTemporaryText(); | 81 virtual void OnRevertTemporaryText(); |
82 virtual void OnBeforePossibleChange(); | 82 virtual void OnBeforePossibleChange(); |
83 virtual bool OnAfterPossibleChange(); | 83 virtual bool OnAfterPossibleChange(); |
84 virtual gfx::NativeView GetNativeView() const; | 84 virtual gfx::NativeView GetNativeView() const; |
85 virtual CommandUpdater* GetCommandUpdater(); | 85 virtual CommandUpdater* GetCommandUpdater(); |
86 virtual void SetInstantSuggestion(const string16& input); | 86 virtual void SetInstantSuggestion(const string16& input); |
87 virtual int TextWidth() const; | 87 virtual int TextWidth() const; |
88 virtual bool IsImeComposing() const; | 88 virtual bool IsImeComposing() const; |
89 | 89 |
(...skipping 14 matching lines...) Expand all Loading... |
104 virtual void OnSetFocus(bool control_down); | 104 virtual void OnSetFocus(bool control_down); |
105 virtual void OnKillFocus(); | 105 virtual void OnKillFocus(); |
106 | 106 |
107 bool CommitSuggestText(); | 107 bool CommitSuggestText(); |
108 | 108 |
109 // Helper for LocationBarViewMac. Optionally selects all in |field_|. | 109 // Helper for LocationBarViewMac. Optionally selects all in |field_|. |
110 void FocusLocation(bool select_all); | 110 void FocusLocation(bool select_all); |
111 | 111 |
112 // Helper to get appropriate contents from |clipboard|. Returns | 112 // Helper to get appropriate contents from |clipboard|. Returns |
113 // empty string if no appropriate data is found on |clipboard|. | 113 // empty string if no appropriate data is found on |clipboard|. |
114 static std::wstring GetClipboardText(ui::Clipboard* clipboard); | 114 static string16 GetClipboardText(ui::Clipboard* clipboard); |
115 | 115 |
116 // Helper to get the font to use in the field, exposed for the | 116 // Helper to get the font to use in the field, exposed for the |
117 // popup. | 117 // popup. |
118 static NSFont* GetFieldFont(); | 118 static NSFont* GetFieldFont(); |
119 | 119 |
120 // If |resource_id| has a PDF image which can be used, return it. | 120 // If |resource_id| has a PDF image which can be used, return it. |
121 // Otherwise return the PNG image from the resource bundle. | 121 // Otherwise return the PNG image from the resource bundle. |
122 static NSImage* ImageForResource(int resource_id); | 122 static NSImage* ImageForResource(int resource_id); |
123 | 123 |
124 private: | 124 private: |
(...skipping 15 matching lines...) Expand all Loading... |
140 // in various DCHECKS to make sure code is running in appropriate | 140 // in various DCHECKS to make sure code is running in appropriate |
141 // situations. | 141 // situations. |
142 bool IsFirstResponder() const; | 142 bool IsFirstResponder() const; |
143 | 143 |
144 // If |model_| believes it has focus, grab focus if needed and set | 144 // If |model_| believes it has focus, grab focus if needed and set |
145 // the selection to |range|. Otherwise does nothing. | 145 // the selection to |range|. Otherwise does nothing. |
146 void SetSelectedRange(const NSRange range); | 146 void SetSelectedRange(const NSRange range); |
147 | 147 |
148 // Update the field with |display_text| and highlight the host and scheme (if | 148 // Update the field with |display_text| and highlight the host and scheme (if |
149 // it's an URL or URL-fragment). Resets any suggest text that may be present. | 149 // it's an URL or URL-fragment). Resets any suggest text that may be present. |
150 void SetText(const std::wstring& display_text); | 150 void SetText(const string16& display_text); |
151 | 151 |
152 // Internal implementation of SetText. Does not reset the suggest text before | 152 // Internal implementation of SetText. Does not reset the suggest text before |
153 // setting the display text. Most callers should use |SetText()| instead. | 153 // setting the display text. Most callers should use |SetText()| instead. |
154 void SetTextInternal(const std::wstring& display_text); | 154 void SetTextInternal(const string16& display_text); |
155 | 155 |
156 // Update the field with |display_text| and set the selection. | 156 // Update the field with |display_text| and set the selection. |
157 void SetTextAndSelectedRange(const std::wstring& display_text, | 157 void SetTextAndSelectedRange(const string16& display_text, |
158 const NSRange range); | 158 const NSRange range); |
159 | 159 |
160 // Returns the non-suggest portion of |field_|'s string value. | 160 // Returns the non-suggest portion of |field_|'s string value. |
161 NSString* GetNonSuggestTextSubstring() const; | 161 NSString* GetNonSuggestTextSubstring() const; |
162 | 162 |
163 // Pass the current content of |field_| to SetText(), maintaining | 163 // Pass the current content of |field_| to SetText(), maintaining |
164 // any selection. Named to be consistent with GTK and Windows, | 164 // any selection. Named to be consistent with GTK and Windows, |
165 // though here we cannot really do the in-place operation they do. | 165 // though here we cannot really do the in-place operation they do. |
166 void EmphasizeURLComponents(); | 166 void EmphasizeURLComponents(); |
167 | 167 |
168 // Calculates text attributes according to |display_text| and applies them | 168 // Calculates text attributes according to |display_text| and applies them |
169 // to the given |as| object. | 169 // to the given |as| object. |
170 void ApplyTextAttributes(const std::wstring& display_text, | 170 void ApplyTextAttributes(const string16& display_text, |
171 NSMutableAttributedString* as); | 171 NSMutableAttributedString* as); |
172 | 172 |
173 scoped_ptr<AutocompleteEditModel> model_; | 173 scoped_ptr<AutocompleteEditModel> model_; |
174 scoped_ptr<AutocompletePopupViewMac> popup_view_; | 174 scoped_ptr<AutocompletePopupViewMac> popup_view_; |
175 | 175 |
176 AutocompleteEditController* controller_; | 176 AutocompleteEditController* controller_; |
177 ToolbarModel* toolbar_model_; | 177 ToolbarModel* toolbar_model_; |
178 | 178 |
179 // The object that handles additional command functionality exposed on the | 179 // The object that handles additional command functionality exposed on the |
180 // edit, such as invoking the keyword editor. | 180 // edit, such as invoking the keyword editor. |
181 CommandUpdater* command_updater_; | 181 CommandUpdater* command_updater_; |
182 | 182 |
183 AutocompleteTextField* field_; // owned by tab controller | 183 AutocompleteTextField* field_; // owned by tab controller |
184 | 184 |
185 // Selection at the point where the user started using the | 185 // Selection at the point where the user started using the |
186 // arrows to move around in the popup. | 186 // arrows to move around in the popup. |
187 NSRange saved_temporary_selection_; | 187 NSRange saved_temporary_selection_; |
188 | 188 |
189 // Tracking state before and after a possible change for reporting | 189 // Tracking state before and after a possible change for reporting |
190 // to model_. | 190 // to model_. |
191 NSRange selection_before_change_; | 191 NSRange selection_before_change_; |
192 std::wstring text_before_change_; | 192 string16 text_before_change_; |
193 NSRange marked_range_before_change_; | 193 NSRange marked_range_before_change_; |
194 | 194 |
195 // Length of the suggest text. The suggest text always appears at the end of | 195 // Length of the suggest text. The suggest text always appears at the end of |
196 // the field. | 196 // the field. |
197 size_t suggest_text_length_; | 197 size_t suggest_text_length_; |
198 | 198 |
199 // Was delete pressed? | 199 // Was delete pressed? |
200 bool delete_was_pressed_; | 200 bool delete_was_pressed_; |
201 | 201 |
202 // Was the delete key pressed with an empty selection at the end of the edit? | 202 // Was the delete key pressed with an empty selection at the end of the edit? |
203 bool delete_at_end_pressed_; | 203 bool delete_at_end_pressed_; |
204 | 204 |
205 // The maximum/standard line height for the displayed text. | 205 // The maximum/standard line height for the displayed text. |
206 CGFloat line_height_; | 206 CGFloat line_height_; |
207 | 207 |
208 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); | 208 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); |
209 }; | 209 }; |
210 | 210 |
211 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 211 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
OLD | NEW |