Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac.h

Issue 113746: Overhaul omnibox focus detection on Mac. (Closed)
Patch Set: Address Pink's suggestion, add some color commentary. Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 virtual void UpdatePopup(); 73 virtual void UpdatePopup();
74 virtual void ClosePopup(); 74 virtual void ClosePopup();
75 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text, 75 virtual void OnTemporaryTextMaybeChanged(const std::wstring& display_text,
76 bool save_original_selection); 76 bool save_original_selection);
77 virtual bool OnInlineAutocompleteTextMaybeChanged( 77 virtual bool OnInlineAutocompleteTextMaybeChanged(
78 const std::wstring& display_text, size_t user_text_length); 78 const std::wstring& display_text, size_t user_text_length);
79 virtual void OnRevertTemporaryText(); 79 virtual void OnRevertTemporaryText();
80 virtual void OnBeforePossibleChange(); 80 virtual void OnBeforePossibleChange();
81 virtual bool OnAfterPossibleChange(); 81 virtual bool OnAfterPossibleChange();
82 82
83 // Helper functions which forward to |model_|, for use from 83 // Helper functions for use from AutocompleteEditHelper Objective-C
84 // AutocompleteEditHelper Objective-C class. 84 // class.
85 void OnUpOrDownKeyPressed(bool up, bool by_page); 85 void OnUpOrDownKeyPressed(bool up, bool by_page);
86 void OnEscapeKeyPressed(); 86 void OnEscapeKeyPressed();
87 // Only forwards to |model_| if the field_ has focus. 87
88 void OnSetFocus(bool f); 88 // Called when editing begins in the field, and before the results
89 void OnKillFocus(); 89 // of any editing are communicated to |model_|.
90 void OnWillBeginEditing();
91
92 // Called when editing ends in the field.
93 void OnDidEndEditing();
94
95 // Called when the window |field_| is in loses key to clean up
96 // visual state (such as closing the popup).
97 void OnDidResignKey();
98
90 void AcceptInput(WindowOpenDisposition disposition, bool for_drop); 99 void AcceptInput(WindowOpenDisposition disposition, bool for_drop);
91 100
92 // Helper for LocationBarBridge. 101 // Helper for LocationBarBridge.
93 void FocusLocation(); 102 void FocusLocation();
94 103
95 private: 104 private:
96 // Returns the field's currently selected range. Only valid if the 105 // Returns the field's currently selected range. Only valid if the
97 // field has focus. 106 // field has focus.
98 NSRange GetSelectedRange() const; 107 NSRange GetSelectedRange() const;
99 108
109 // Returns true if |field_| is first-responder in the window. Used
110 // in various DCHECKS to make sure code is running in appropriate
111 // situations.
112 bool IsFirstResponder() const;
113
100 // Grab focus if needed and set the selection to |range|. 114 // Grab focus if needed and set the selection to |range|.
101 void SetSelectedRange(const NSRange range); 115 void SetSelectedRange(const NSRange range);
102 116
103 // Update the field with |display_text| and highlight the host and 117 // Update the field with |display_text| and highlight the host and
104 // scheme (if it's an URL or URL-fragment). 118 // scheme (if it's an URL or URL-fragment).
105 void UpdateAndStyleText(const std::wstring& display_text); 119 void UpdateAndStyleText(const std::wstring& display_text);
106 120
107 scoped_ptr<AutocompleteEditModel> model_; 121 scoped_ptr<AutocompleteEditModel> model_;
108 scoped_ptr<AutocompletePopupViewMac> popup_view_; 122 scoped_ptr<AutocompletePopupViewMac> popup_view_;
109 123
(...skipping 16 matching lines...) Expand all
126 140
127 // Tracking state before and after a possible change for reporting 141 // Tracking state before and after a possible change for reporting
128 // to model_. 142 // to model_.
129 NSRange selection_before_change_; 143 NSRange selection_before_change_;
130 std::wstring text_before_change_; 144 std::wstring text_before_change_;
131 145
132 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac); 146 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewMac);
133 }; 147 };
134 148
135 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_ 149 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698