OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class OmniboxViewMac : public OmniboxView, | 22 class OmniboxViewMac : public OmniboxView, |
23 public AutocompleteTextFieldObserver { | 23 public AutocompleteTextFieldObserver { |
24 public: | 24 public: |
25 OmniboxViewMac(OmniboxEditController* controller, | 25 OmniboxViewMac(OmniboxEditController* controller, |
26 Profile* profile, | 26 Profile* profile, |
27 CommandUpdater* command_updater, | 27 CommandUpdater* command_updater, |
28 AutocompleteTextField* field); | 28 AutocompleteTextField* field); |
29 virtual ~OmniboxViewMac(); | 29 virtual ~OmniboxViewMac(); |
30 | 30 |
31 // OmniboxView: | 31 // OmniboxView: |
32 virtual void SaveStateToTab(content::WebContents* tab) OVERRIDE; | 32 virtual void SaveStateToTab(content::WebContents* tab) override; |
33 virtual void OnTabChanged(const content::WebContents* web_contents) OVERRIDE; | 33 virtual void OnTabChanged(const content::WebContents* web_contents) override; |
34 virtual void Update() OVERRIDE; | 34 virtual void Update() override; |
35 virtual void UpdatePlaceholderText() OVERRIDE; | 35 virtual void UpdatePlaceholderText() override; |
36 virtual void OpenMatch(const AutocompleteMatch& match, | 36 virtual void OpenMatch(const AutocompleteMatch& match, |
37 WindowOpenDisposition disposition, | 37 WindowOpenDisposition disposition, |
38 const GURL& alternate_nav_url, | 38 const GURL& alternate_nav_url, |
39 const base::string16& pasted_text, | 39 const base::string16& pasted_text, |
40 size_t selected_line) OVERRIDE; | 40 size_t selected_line) override; |
41 virtual base::string16 GetText() const OVERRIDE; | 41 virtual base::string16 GetText() const override; |
42 virtual void SetWindowTextAndCaretPos(const base::string16& text, | 42 virtual void SetWindowTextAndCaretPos(const base::string16& text, |
43 size_t caret_pos, | 43 size_t caret_pos, |
44 bool update_popup, | 44 bool update_popup, |
45 bool notify_text_changed) OVERRIDE; | 45 bool notify_text_changed) override; |
46 virtual void SetForcedQuery() OVERRIDE; | 46 virtual void SetForcedQuery() override; |
47 virtual bool IsSelectAll() const OVERRIDE; | 47 virtual bool IsSelectAll() const override; |
48 virtual bool DeleteAtEndPressed() OVERRIDE; | 48 virtual bool DeleteAtEndPressed() override; |
49 virtual void GetSelectionBounds( | 49 virtual void GetSelectionBounds( |
50 base::string16::size_type* start, | 50 base::string16::size_type* start, |
51 base::string16::size_type* end) const OVERRIDE; | 51 base::string16::size_type* end) const override; |
52 virtual void SelectAll(bool reversed) OVERRIDE; | 52 virtual void SelectAll(bool reversed) override; |
53 virtual void RevertAll() OVERRIDE; | 53 virtual void RevertAll() override; |
54 virtual void UpdatePopup() OVERRIDE; | 54 virtual void UpdatePopup() override; |
55 virtual void CloseOmniboxPopup() OVERRIDE; | 55 virtual void CloseOmniboxPopup() override; |
56 virtual void SetFocus() OVERRIDE; | 56 virtual void SetFocus() override; |
57 virtual void ApplyCaretVisibility() OVERRIDE; | 57 virtual void ApplyCaretVisibility() override; |
58 virtual void OnTemporaryTextMaybeChanged( | 58 virtual void OnTemporaryTextMaybeChanged( |
59 const base::string16& display_text, | 59 const base::string16& display_text, |
60 bool save_original_selection, | 60 bool save_original_selection, |
61 bool notify_text_changed) OVERRIDE; | 61 bool notify_text_changed) override; |
62 virtual bool OnInlineAutocompleteTextMaybeChanged( | 62 virtual bool OnInlineAutocompleteTextMaybeChanged( |
63 const base::string16& display_text, size_t user_text_length) OVERRIDE; | 63 const base::string16& display_text, size_t user_text_length) override; |
64 virtual void OnInlineAutocompleteTextCleared() OVERRIDE; | 64 virtual void OnInlineAutocompleteTextCleared() override; |
65 virtual void OnRevertTemporaryText() OVERRIDE; | 65 virtual void OnRevertTemporaryText() override; |
66 virtual void OnBeforePossibleChange() OVERRIDE; | 66 virtual void OnBeforePossibleChange() override; |
67 virtual bool OnAfterPossibleChange() OVERRIDE; | 67 virtual bool OnAfterPossibleChange() override; |
68 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 68 virtual gfx::NativeView GetNativeView() const override; |
69 virtual gfx::NativeView GetRelativeWindowForPopup() const OVERRIDE; | 69 virtual gfx::NativeView GetRelativeWindowForPopup() const override; |
70 virtual void SetGrayTextAutocompletion(const base::string16& input) OVERRIDE; | 70 virtual void SetGrayTextAutocompletion(const base::string16& input) override; |
71 virtual base::string16 GetGrayTextAutocompletion() const OVERRIDE; | 71 virtual base::string16 GetGrayTextAutocompletion() const override; |
72 virtual int GetTextWidth() const OVERRIDE; | 72 virtual int GetTextWidth() const override; |
73 virtual int GetWidth() const OVERRIDE; | 73 virtual int GetWidth() const override; |
74 virtual bool IsImeComposing() const OVERRIDE; | 74 virtual bool IsImeComposing() const override; |
75 | 75 |
76 // Implement the AutocompleteTextFieldObserver interface. | 76 // Implement the AutocompleteTextFieldObserver interface. |
77 virtual NSRange SelectionRangeForProposedRange( | 77 virtual NSRange SelectionRangeForProposedRange( |
78 NSRange proposed_range) OVERRIDE; | 78 NSRange proposed_range) override; |
79 virtual void OnControlKeyChanged(bool pressed) OVERRIDE; | 79 virtual void OnControlKeyChanged(bool pressed) override; |
80 virtual bool CanCopy() OVERRIDE; | 80 virtual bool CanCopy() override; |
81 virtual void CopyToPasteboard(NSPasteboard* pboard) OVERRIDE; | 81 virtual void CopyToPasteboard(NSPasteboard* pboard) override; |
82 virtual bool ShouldEnableShowURL() OVERRIDE; | 82 virtual bool ShouldEnableShowURL() override; |
83 virtual void ShowURL() OVERRIDE; | 83 virtual void ShowURL() override; |
84 virtual void OnPaste() OVERRIDE; | 84 virtual void OnPaste() override; |
85 virtual bool CanPasteAndGo() OVERRIDE; | 85 virtual bool CanPasteAndGo() override; |
86 virtual int GetPasteActionStringId() OVERRIDE; | 86 virtual int GetPasteActionStringId() override; |
87 virtual void OnPasteAndGo() OVERRIDE; | 87 virtual void OnPasteAndGo() override; |
88 virtual void OnFrameChanged() OVERRIDE; | 88 virtual void OnFrameChanged() override; |
89 virtual void ClosePopup() OVERRIDE; | 89 virtual void ClosePopup() override; |
90 virtual void OnDidBeginEditing() OVERRIDE; | 90 virtual void OnDidBeginEditing() override; |
91 virtual void OnBeforeChange() OVERRIDE; | 91 virtual void OnBeforeChange() override; |
92 virtual void OnDidChange() OVERRIDE; | 92 virtual void OnDidChange() override; |
93 virtual void OnDidEndEditing() OVERRIDE; | 93 virtual void OnDidEndEditing() override; |
94 virtual bool OnDoCommandBySelector(SEL cmd) OVERRIDE; | 94 virtual bool OnDoCommandBySelector(SEL cmd) override; |
95 virtual void OnSetFocus(bool control_down) OVERRIDE; | 95 virtual void OnSetFocus(bool control_down) override; |
96 virtual void OnKillFocus() OVERRIDE; | 96 virtual void OnKillFocus() override; |
97 virtual void OnMouseDown(NSInteger button_number) OVERRIDE; | 97 virtual void OnMouseDown(NSInteger button_number) override; |
98 virtual bool ShouldSelectAllOnMouseDown() OVERRIDE; | 98 virtual bool ShouldSelectAllOnMouseDown() override; |
99 | 99 |
100 // Helper for LocationBarViewMac. Optionally selects all in |field_|. | 100 // Helper for LocationBarViewMac. Optionally selects all in |field_|. |
101 void FocusLocation(bool select_all); | 101 void FocusLocation(bool select_all); |
102 | 102 |
103 // Helper to get the font to use in the field, exposed for the | 103 // Helper to get the font to use in the field, exposed for the |
104 // popup. | 104 // popup. |
105 // The style parameter specifies the new style for the font, and is a | 105 // The style parameter specifies the new style for the font, and is a |
106 // bitmask of the values: BOLD, ITALIC and UNDERLINE (see ui/gfx/font.h). | 106 // bitmask of the values: BOLD, ITALIC and UNDERLINE (see ui/gfx/font.h). |
107 static NSFont* GetFieldFont(int style); | 107 static NSFont* GetFieldFont(int style); |
108 | 108 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // setting the display text. Most callers should use |SetText()| instead. | 147 // setting the display text. Most callers should use |SetText()| instead. |
148 void SetTextInternal(const base::string16& display_text); | 148 void SetTextInternal(const base::string16& display_text); |
149 | 149 |
150 // Update the field with |display_text| and set the selection. | 150 // Update the field with |display_text| and set the selection. |
151 void SetTextAndSelectedRange(const base::string16& display_text, | 151 void SetTextAndSelectedRange(const base::string16& display_text, |
152 const NSRange range); | 152 const NSRange range); |
153 | 153 |
154 // Pass the current content of |field_| to SetText(), maintaining | 154 // Pass the current content of |field_| to SetText(), maintaining |
155 // any selection. Named to be consistent with GTK and Windows, | 155 // any selection. Named to be consistent with GTK and Windows, |
156 // though here we cannot really do the in-place operation they do. | 156 // though here we cannot really do the in-place operation they do. |
157 virtual void EmphasizeURLComponents() OVERRIDE; | 157 virtual void EmphasizeURLComponents() override; |
158 | 158 |
159 // Calculates text attributes according to |display_text| and applies them | 159 // Calculates text attributes according to |display_text| and applies them |
160 // to the given |as| object. | 160 // to the given |as| object. |
161 void ApplyTextAttributes(const base::string16& display_text, | 161 void ApplyTextAttributes(const base::string16& display_text, |
162 NSMutableAttributedString* as); | 162 NSMutableAttributedString* as); |
163 | 163 |
164 // Return the number of UTF-16 units in the current buffer, excluding the | 164 // Return the number of UTF-16 units in the current buffer, excluding the |
165 // suggested text. | 165 // suggested text. |
166 virtual int GetOmniboxTextLength() const OVERRIDE; | 166 virtual int GetOmniboxTextLength() const override; |
167 NSUInteger GetTextLength() const; | 167 NSUInteger GetTextLength() const; |
168 | 168 |
169 // Returns true if the caret is at the end of the content. | 169 // Returns true if the caret is at the end of the content. |
170 bool IsCaretAtEnd() const; | 170 bool IsCaretAtEnd() const; |
171 | 171 |
172 scoped_ptr<OmniboxPopupView> popup_view_; | 172 scoped_ptr<OmniboxPopupView> popup_view_; |
173 | 173 |
174 AutocompleteTextField* field_; // owned by tab controller | 174 AutocompleteTextField* field_; // owned by tab controller |
175 | 175 |
176 // Selection at the point where the user started using the | 176 // Selection at the point where the user started using the |
(...skipping 19 matching lines...) Expand all Loading... |
196 bool in_coalesced_update_block_; | 196 bool in_coalesced_update_block_; |
197 bool do_coalesced_text_update_; | 197 bool do_coalesced_text_update_; |
198 base::string16 coalesced_text_update_; | 198 base::string16 coalesced_text_update_; |
199 bool do_coalesced_range_update_; | 199 bool do_coalesced_range_update_; |
200 NSRange coalesced_range_update_; | 200 NSRange coalesced_range_update_; |
201 | 201 |
202 DISALLOW_COPY_AND_ASSIGN(OmniboxViewMac); | 202 DISALLOW_COPY_AND_ASSIGN(OmniboxViewMac); |
203 }; | 203 }; |
204 | 204 |
205 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ | 205 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ |
OLD | NEW |