OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/scoped_nsobject.h" | 11 #include "base/scoped_nsobject.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "chrome/browser/autocomplete/autocomplete.h" | 13 #include "chrome/browser/autocomplete/autocomplete.h" |
14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
15 #include "chrome/browser/toolbar_model.h" | 15 #include "chrome/browser/toolbar_model.h" |
16 #include "chrome/common/page_transition_types.h" | 16 #include "chrome/common/page_transition_types.h" |
17 #include "webkit/glue/window_open_disposition.h" | 17 #include "webkit/glue/window_open_disposition.h" |
18 | 18 |
19 class AutocompleteEditController; | 19 class AutocompleteEditController; |
20 @class AutocompleteEditHelper; | 20 @class AutocompleteEditHelper; |
21 class AutocompleteEditModel; | 21 class AutocompleteEditModel; |
22 class AutocompletePopupViewMac; | 22 class AutocompletePopupViewMac; |
23 @class AutocompleteTextField; | 23 @class AutocompleteTextField; |
| 24 class Clipboard; |
24 class CommandUpdater; | 25 class CommandUpdater; |
25 class Profile; | 26 class Profile; |
26 class TabContents; | 27 class TabContents; |
27 class ToolbarModel; | 28 class ToolbarModel; |
28 | 29 |
29 // Implements AutocompleteEditView on an AutocompleteTextField. | 30 // Implements AutocompleteEditView on an AutocompleteTextField. |
30 | 31 |
31 class AutocompleteEditViewMac : public AutocompleteEditView { | 32 class AutocompleteEditViewMac : public AutocompleteEditView { |
32 public: | 33 public: |
33 AutocompleteEditViewMac(AutocompleteEditController* controller, | 34 AutocompleteEditViewMac(AutocompleteEditController* controller, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // of any editing are communicated to |model_|. | 93 // of any editing are communicated to |model_|. |
93 void OnWillBeginEditing(); | 94 void OnWillBeginEditing(); |
94 | 95 |
95 // Called when editing ends in the field. | 96 // Called when editing ends in the field. |
96 void OnDidEndEditing(); | 97 void OnDidEndEditing(); |
97 | 98 |
98 // Called when the window |field_| is in loses key to clean up | 99 // Called when the window |field_| is in loses key to clean up |
99 // visual state (such as closing the popup). | 100 // visual state (such as closing the popup). |
100 void OnDidResignKey(); | 101 void OnDidResignKey(); |
101 | 102 |
| 103 // Called when the user attempts to paste into |field_|. |
| 104 void OnPaste(); |
| 105 |
102 void AcceptInput(WindowOpenDisposition disposition, bool for_drop); | 106 void AcceptInput(WindowOpenDisposition disposition, bool for_drop); |
103 | 107 |
104 // Helper for LocationBarViewMac. Selects all in |field_|. | 108 // Helper for LocationBarViewMac. Selects all in |field_|. |
105 void FocusLocation(); | 109 void FocusLocation(); |
106 | 110 |
| 111 // Helper to get appropriate contents from |clipboard|. Returns |
| 112 // empty string if no appropriate data is found on |clipboard|. |
| 113 static std::wstring GetClipboardText(Clipboard* clipboard); |
| 114 |
107 private: | 115 private: |
108 // Returns the field's currently selected range. Only valid if the | 116 // Returns the field's currently selected range. Only valid if the |
109 // field has focus. | 117 // field has focus. |
110 NSRange GetSelectedRange() const; | 118 NSRange GetSelectedRange() const; |
111 | 119 |
112 // Returns true if |field_| is first-responder in the window. Used | 120 // Returns true if |field_| is first-responder in the window. Used |
113 // in various DCHECKS to make sure code is running in appropriate | 121 // in various DCHECKS to make sure code is running in appropriate |
114 // situations. | 122 // situations. |
115 bool IsFirstResponder() const; | 123 bool IsFirstResponder() const; |
116 | 124 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 161 |
154 // Tracking state before and after a possible change for reporting | 162 // Tracking state before and after a possible change for reporting |
155 // to model_. | 163 // to model_. |
156 NSRange selection_before_change_; | 164 NSRange selection_before_change_; |
157 std::wstring text_before_change_; | 165 std::wstring text_before_change_; |
158 | 166 |
159 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); | 167 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); |
160 }; | 168 }; |
161 | 169 |
162 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 170 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
OLD | NEW |