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/browser/cocoa/autocomplete_text_field.h" |
16 #include "chrome/common/page_transition_types.h" | 17 #include "chrome/common/page_transition_types.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "webkit/glue/window_open_disposition.h" | 19 #include "webkit/glue/window_open_disposition.h" |
19 | 20 |
20 class AutocompleteEditController; | 21 class AutocompleteEditController; |
21 class AutocompleteEditModel; | 22 class AutocompleteEditModel; |
22 @class AutocompleteFieldDelegate; | 23 @class AutocompleteFieldDelegate; |
23 class AutocompletePopupViewMac; | 24 class AutocompletePopupViewMac; |
24 @class AutocompleteTextField; | |
25 class BubblePositioner; | 25 class BubblePositioner; |
26 class Clipboard; | 26 class Clipboard; |
27 class CommandUpdater; | 27 class CommandUpdater; |
28 class Profile; | 28 class Profile; |
29 class TabContents; | 29 class TabContents; |
30 class ToolbarModel; | 30 class ToolbarModel; |
31 | 31 |
32 // Implements AutocompleteEditView on an AutocompleteTextField. | 32 // Implements AutocompleteEditView on an AutocompleteTextField. |
33 | 33 |
34 class AutocompleteEditViewMac : public AutocompleteEditView { | 34 class AutocompleteEditViewMac : public AutocompleteEditView, |
| 35 public AutocompleteTextFieldObserver { |
35 public: | 36 public: |
36 AutocompleteEditViewMac(AutocompleteEditController* controller, | 37 AutocompleteEditViewMac(AutocompleteEditController* controller, |
37 const BubblePositioner* bubble_positioner, | 38 const BubblePositioner* bubble_positioner, |
38 ToolbarModel* toolbar_model, | 39 ToolbarModel* toolbar_model, |
39 Profile* profile, | 40 Profile* profile, |
40 CommandUpdater* command_updater, | 41 CommandUpdater* command_updater, |
41 AutocompleteTextField* field); | 42 AutocompleteTextField* field); |
42 virtual ~AutocompleteEditViewMac(); | 43 virtual ~AutocompleteEditViewMac(); |
43 | 44 |
44 // Implement the AutocompleteEditView interface. | 45 // Implement the AutocompleteEditView interface. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 virtual void SetFocus(); | 83 virtual void SetFocus(); |
83 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, | 84 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, |
84 bool save_original_selection); | 85 bool save_original_selection); |
85 virtual bool OnInlineAutocompleteTextMaybeChanged( | 86 virtual bool OnInlineAutocompleteTextMaybeChanged( |
86 const std::wstring& display_text, size_t user_text_length); | 87 const std::wstring& display_text, size_t user_text_length); |
87 virtual void OnRevertTemporaryText(); | 88 virtual void OnRevertTemporaryText(); |
88 virtual void OnBeforePossibleChange(); | 89 virtual void OnBeforePossibleChange(); |
89 virtual bool OnAfterPossibleChange(); | 90 virtual bool OnAfterPossibleChange(); |
90 virtual gfx::NativeView GetNativeView() const; | 91 virtual gfx::NativeView GetNativeView() const; |
91 | 92 |
92 // Helper functions for use from AutocompleteFieldDelegate Objective-C | 93 // Implement the AutocompleteTextFieldObserver interface. |
| 94 virtual void OnControlKeyChanged(bool pressed); |
| 95 virtual void OnPaste(); |
| 96 |
| 97 // Helper functions for use from AutocompleteEditHelper Objective-C |
93 // class. | 98 // class. |
94 | 99 |
95 // Returns true if |popup_view_| is open. | 100 // Returns true if |popup_view_| is open. |
96 bool IsPopupOpen() const; | 101 bool IsPopupOpen() const; |
97 | 102 |
98 // Trivial wrappers forwarding to |model_| methods. | 103 // Trivial wrappers forwarding to |model_| methods. |
99 void OnControlKeyChanged(bool pressed); | |
100 void OnEscapeKeyPressed(); | 104 void OnEscapeKeyPressed(); |
101 void OnUpOrDownKeyPressed(bool up, bool by_page); | 105 void OnUpOrDownKeyPressed(bool up, bool by_page); |
102 | 106 |
103 // Called when editing begins in the field, and before the results | 107 // Called when editing begins in the field, and before the results |
104 // of any editing are communicated to |model_|. | 108 // of any editing are communicated to |model_|. |
105 void OnWillBeginEditing(); | 109 void OnWillBeginEditing(); |
106 | 110 |
107 // Called when editing ends in the field. | 111 // Called when editing ends in the field. |
108 void OnDidEndEditing(); | 112 void OnDidEndEditing(); |
109 | 113 |
110 // Called when the window |field_| is in loses key to clean up | 114 // Called when the window |field_| is in loses key to clean up |
111 // visual state (such as closing the popup). | 115 // visual state (such as closing the popup). |
112 void OnDidResignKey(); | 116 void OnDidResignKey(); |
113 | 117 |
114 // Called when the user attempts to paste into |field_|. | |
115 void OnPaste(); | |
116 | |
117 // Returns true if the current clipboard text supports paste and go (or paste | 118 // Returns true if the current clipboard text supports paste and go (or paste |
118 // and search). | 119 // and search). |
119 bool CanPasteAndGo(); | 120 bool CanPasteAndGo(); |
120 | 121 |
121 // Returns the appropriate "Paste and Go" or "Paste and Search" context menu | 122 // Returns the appropriate "Paste and Go" or "Paste and Search" context menu |
122 // string, depending on what is currently in the clipboard. Must not be | 123 // string, depending on what is currently in the clipboard. Must not be |
123 // called unless CanPasteAndGo() returns true. | 124 // called unless CanPasteAndGo() returns true. |
124 int GetPasteActionStringId(); | 125 int GetPasteActionStringId(); |
125 | 126 |
126 // Called when the user initiates a "paste and go" or "paste and search" into | 127 // Called when the user initiates a "paste and go" or "paste and search" into |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 199 |
199 // Tracking state before and after a possible change for reporting | 200 // Tracking state before and after a possible change for reporting |
200 // to model_. | 201 // to model_. |
201 NSRange selection_before_change_; | 202 NSRange selection_before_change_; |
202 std::wstring text_before_change_; | 203 std::wstring text_before_change_; |
203 | 204 |
204 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); | 205 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); |
205 }; | 206 }; |
206 | 207 |
207 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ | 208 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ |
OLD | NEW |