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 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/auto_reset.h" | |
13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
16 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 17 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
17 #include "components/omnibox/browser/omnibox_view.h" | 18 #include "components/omnibox/browser/omnibox_view.h" |
18 #include "components/security_state/core/security_state.h" | 19 #include "components/security_state/core/security_state.h" |
19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
20 | 21 |
21 class CommandUpdater; | 22 class CommandUpdater; |
22 class OmniboxPopupView; | 23 class OmniboxPopupView; |
23 class Profile; | 24 class Profile; |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 class WebContents; | 27 class WebContents; |
27 } | 28 } |
28 | 29 |
29 // Implements OmniboxView on an AutocompleteTextField. | 30 // Implements OmniboxView on an AutocompleteTextField. |
30 class OmniboxViewMac : public OmniboxView, | 31 class OmniboxViewMac : public OmniboxView, |
31 public AutocompleteTextFieldObserver { | 32 public AutocompleteTextFieldObserver { |
32 public: | 33 public: |
33 static SkColor BaseTextColorSkia(bool in_dark_mode); | 34 static SkColor BaseTextColorSkia(bool in_dark_mode); |
34 static NSColor* BaseTextColor(bool in_dark_mode); | 35 static NSColor* BaseTextColor(bool in_dark_mode); |
36 // Returns a color representing |security_level|, adjusted based on whether | |
37 // the browser is in Incognito mode. | |
35 static NSColor* GetSecureTextColor( | 38 static NSColor* GetSecureTextColor( |
36 security_state::SecurityLevel security_level, | 39 security_state::SecurityLevel security_level, |
37 bool in_dark_mode); | 40 bool in_dark_mode); |
38 | 41 |
39 OmniboxViewMac(OmniboxEditController* controller, | 42 OmniboxViewMac(OmniboxEditController* controller, |
40 Profile* profile, | 43 Profile* profile, |
41 CommandUpdater* command_updater, | 44 CommandUpdater* command_updater, |
42 AutocompleteTextField* field); | 45 AutocompleteTextField* field); |
43 ~OmniboxViewMac() override; | 46 ~OmniboxViewMac() override; |
44 | 47 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 | 176 |
174 // Pass the current content of |field_| to SetText(), maintaining | 177 // Pass the current content of |field_| to SetText(), maintaining |
175 // any selection. Named to be consistent with GTK and Windows, | 178 // any selection. Named to be consistent with GTK and Windows, |
176 // though here we cannot really do the in-place operation they do. | 179 // though here we cannot really do the in-place operation they do. |
177 void EmphasizeURLComponents() override; | 180 void EmphasizeURLComponents() override; |
178 | 181 |
179 // Apply our font and paragraph style to |attributedString|. | 182 // Apply our font and paragraph style to |attributedString|. |
180 void ApplyTextStyle(NSMutableAttributedString* attributedString); | 183 void ApplyTextStyle(NSMutableAttributedString* attributedString); |
181 | 184 |
182 // Calculates text attributes according to |display_text| and applies them | 185 // Calculates text attributes according to |display_text| and applies them |
183 // to the given |attributedString| object. | 186 // to the given |attributed_string| object. |
184 void ApplyTextAttributes(const base::string16& display_text, | 187 void ApplyTextAttributes(const base::string16& display_text, |
185 NSMutableAttributedString* attributedString); | 188 NSMutableAttributedString* attributed_string); |
189 | |
190 void SetEmphasis(bool emphasize, const gfx::Range& range) override; | |
Peter Kasting
2017/03/03 02:31:08
Nit: Consider an "// OmniboxView:" header above th
elawrence
2017/03/03 16:07:42
Done.
| |
191 void UpdateSchemeStyle(const gfx::Range& scheme_range) override; | |
186 | 192 |
187 // Return the number of UTF-16 units in the current buffer, excluding the | 193 // Return the number of UTF-16 units in the current buffer, excluding the |
188 // suggested text. | 194 // suggested text. |
189 int GetOmniboxTextLength() const override; | 195 int GetOmniboxTextLength() const override; |
190 NSUInteger GetTextLength() const; | 196 NSUInteger GetTextLength() const; |
191 | 197 |
192 // Returns true if the caret is at the end of the content. | 198 // Returns true if the caret is at the end of the content. |
193 bool IsCaretAtEnd() const; | 199 bool IsCaretAtEnd() const; |
194 | 200 |
195 // Announce that an inline autocomplete is available for screenreaders. | 201 // Announce that an inline autocomplete is available for screenreaders. |
(...skipping 28 matching lines...) Expand all Loading... | |
224 bool do_coalesced_range_update_; | 230 bool do_coalesced_range_update_; |
225 NSRange coalesced_range_update_; | 231 NSRange coalesced_range_update_; |
226 | 232 |
227 // The time of the first character insert operation that has not yet been | 233 // The time of the first character insert operation that has not yet been |
228 // painted. Used to measure omnibox responsiveness with a histogram. | 234 // painted. Used to measure omnibox responsiveness with a histogram. |
229 base::TimeTicks insert_char_time_; | 235 base::TimeTicks insert_char_time_; |
230 | 236 |
231 // The time when OnBeforeDrawRect() was called. | 237 // The time when OnBeforeDrawRect() was called. |
232 base::TimeTicks draw_rect_start_time_; | 238 base::TimeTicks draw_rect_start_time_; |
233 | 239 |
240 // Temporary pointer to the attributed display string, stored as color and | |
241 // other emphasis attributes are applied by the superclass. | |
242 NSMutableAttributedString* attributing_display_string_; // weak | |
243 | |
234 DISALLOW_COPY_AND_ASSIGN(OmniboxViewMac); | 244 DISALLOW_COPY_AND_ASSIGN(OmniboxViewMac); |
235 }; | 245 }; |
236 | 246 |
237 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ | 247 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ |
OLD | NEW |