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 IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_VIEW_IOS_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_VIEW_IOS_H_ |
6 #define IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_VIEW_IOS_H_ | 6 #define IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_VIEW_IOS_H_ |
7 | 7 |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 #include "base/auto_reset.h" |
12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
13 #include "components/omnibox/browser/omnibox_view.h" | 13 #include "components/omnibox/browser/omnibox_view.h" |
14 #include "components/toolbar/toolbar_model.h" | 14 #include "components/toolbar/toolbar_model.h" |
15 #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" | 15 #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" |
16 | 16 |
17 struct AutocompleteMatch; | 17 struct AutocompleteMatch; |
18 class AutocompleteResult; | 18 class AutocompleteResult; |
19 @class AutocompleteTextFieldDelegate; | 19 @class AutocompleteTextFieldDelegate; |
20 class GURL; | 20 class GURL; |
21 @class OmniboxTextFieldIOS; | 21 @class OmniboxTextFieldIOS; |
(...skipping 11 matching lines...) Expand all Loading... |
33 class OmniboxViewIOS : public OmniboxView { | 33 class OmniboxViewIOS : public OmniboxView { |
34 public: | 34 public: |
35 // Retains |field|. | 35 // Retains |field|. |
36 OmniboxViewIOS(OmniboxTextFieldIOS* field, | 36 OmniboxViewIOS(OmniboxTextFieldIOS* field, |
37 WebOmniboxEditController* controller, | 37 WebOmniboxEditController* controller, |
38 ios::ChromeBrowserState* browser_state, | 38 ios::ChromeBrowserState* browser_state, |
39 id<PreloadProvider> prerender, | 39 id<PreloadProvider> prerender, |
40 id<OmniboxPopupPositioner> positioner); | 40 id<OmniboxPopupPositioner> positioner); |
41 ~OmniboxViewIOS() override; | 41 ~OmniboxViewIOS() override; |
42 | 42 |
| 43 // Returns a color representing |security_level|, adjusted based on whether |
| 44 // the browser is in Incognito mode. |
| 45 static UIColor* GetSecureTextColor( |
| 46 security_state::SecurityLevel security_level, |
| 47 bool in_dark_mode); |
| 48 |
43 // OmniboxView implementation. | 49 // OmniboxView implementation. |
44 void OpenMatch(const AutocompleteMatch& match, | 50 void OpenMatch(const AutocompleteMatch& match, |
45 WindowOpenDisposition disposition, | 51 WindowOpenDisposition disposition, |
46 const GURL& alternate_nav_url, | 52 const GURL& alternate_nav_url, |
47 const base::string16& pasted_text, | 53 const base::string16& pasted_text, |
48 size_t selected_line) override; | 54 size_t selected_line) override; |
49 base::string16 GetText() const override; | 55 base::string16 GetText() const override; |
50 void SetWindowTextAndCaretPos(const base::string16& text, | 56 void SetWindowTextAndCaretPos(const base::string16& text, |
51 size_t caret_pos, | 57 size_t caret_pos, |
52 bool update_popup, | 58 bool update_popup, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 136 |
131 protected: | 137 protected: |
132 int GetOmniboxTextLength() const override; | 138 int GetOmniboxTextLength() const override; |
133 void EmphasizeURLComponents() override; | 139 void EmphasizeURLComponents() override; |
134 | 140 |
135 private: | 141 private: |
136 // Calculates text attributes according to |display_text| and | 142 // Calculates text attributes according to |display_text| and |
137 // returns them in an autoreleased object. | 143 // returns them in an autoreleased object. |
138 NSAttributedString* ApplyTextAttributes(const base::string16& text); | 144 NSAttributedString* ApplyTextAttributes(const base::string16& text); |
139 | 145 |
| 146 void SetEmphasis(bool emphasize, const gfx::Range& range) override; |
| 147 void UpdateSchemeStyle(const gfx::Range& scheme_range) override; |
| 148 |
140 // Removes the query refinement chip from the omnibox. | 149 // Removes the query refinement chip from the omnibox. |
141 void RemoveQueryRefinementChip(); | 150 void RemoveQueryRefinementChip(); |
142 | 151 |
143 // Returns true if user input should currently be ignored. On iOS7, | 152 // Returns true if user input should currently be ignored. On iOS7, |
144 // modifying the contents of a text field while Siri is pending leads to a | 153 // modifying the contents of a text field while Siri is pending leads to a |
145 // UIKit crash. In order to sidestep that crash, OmniboxViewIOS checks that | 154 // UIKit crash. In order to sidestep that crash, OmniboxViewIOS checks that |
146 // voice search is not pending before attempting to process user actions that | 155 // voice search is not pending before attempting to process user actions that |
147 // may modify text field contents. | 156 // may modify text field contents. |
148 // TODO(crbug.com/303212): Remove this workaround once the crash is fixed. | 157 // TODO(crbug.com/303212): Remove this workaround once the crash is fixed. |
149 bool ShouldIgnoreUserInputDueToPendingVoiceSearch(); | 158 bool ShouldIgnoreUserInputDueToPendingVoiceSearch(); |
(...skipping 11 matching lines...) Expand all Loading... |
161 NSRange old_selection_; | 170 NSRange old_selection_; |
162 | 171 |
163 // TODO(rohitrao): This is a monster hack, needed because closing the popup | 172 // TODO(rohitrao): This is a monster hack, needed because closing the popup |
164 // ends up inadvertently triggering a new round of autocomplete. Fix the | 173 // ends up inadvertently triggering a new round of autocomplete. Fix the |
165 // underlying problem, which is that textDidChange: is called when closing the | 174 // underlying problem, which is that textDidChange: is called when closing the |
166 // popup, and then remove this hack. b/5877366. | 175 // popup, and then remove this hack. b/5877366. |
167 BOOL ignore_popup_updates_; | 176 BOOL ignore_popup_updates_; |
168 | 177 |
169 // Bridges delegate method calls from |field_| to C++ land. | 178 // Bridges delegate method calls from |field_| to C++ land. |
170 base::scoped_nsobject<AutocompleteTextFieldDelegate> field_delegate_; | 179 base::scoped_nsobject<AutocompleteTextFieldDelegate> field_delegate_; |
| 180 |
| 181 // Temporary pointer to the attributed display string, stored as color and |
| 182 // other emphasis attributes are applied by the superclass. |
| 183 NSMutableAttributedString* attributing_display_string_; // weak |
171 }; | 184 }; |
172 | 185 |
173 #endif // IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_VIEW_IOS_H_ | 186 #endif // IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_VIEW_IOS_H_ |
OLD | NEW |