| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace content { | 25 namespace content { |
| 26 class WebContents; | 26 class WebContents; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // Implements OmniboxView on an AutocompleteTextField. | 29 // Implements OmniboxView on an AutocompleteTextField. |
| 30 class OmniboxViewMac : public OmniboxView, | 30 class OmniboxViewMac : public OmniboxView, |
| 31 public AutocompleteTextFieldObserver { | 31 public AutocompleteTextFieldObserver { |
| 32 public: | 32 public: |
| 33 static SkColor BaseTextColorSkia(bool in_dark_mode); | 33 static SkColor BaseTextColorSkia(bool in_dark_mode); |
| 34 static NSColor* BaseTextColor(bool in_dark_mode); | 34 static NSColor* BaseTextColor(bool in_dark_mode); |
| 35 // Returns a color representing |security_level|, adjusted based on whether |
| 36 // the browser is in Incognito mode. |
| 35 static NSColor* GetSecureTextColor( | 37 static NSColor* GetSecureTextColor( |
| 36 security_state::SecurityLevel security_level, | 38 security_state::SecurityLevel security_level, |
| 37 bool in_dark_mode); | 39 bool in_dark_mode); |
| 38 | 40 |
| 39 OmniboxViewMac(OmniboxEditController* controller, | 41 OmniboxViewMac(OmniboxEditController* controller, |
| 40 Profile* profile, | 42 Profile* profile, |
| 41 CommandUpdater* command_updater, | 43 CommandUpdater* command_updater, |
| 42 AutocompleteTextField* field); | 44 AutocompleteTextField* field); |
| 43 ~OmniboxViewMac() override; | 45 ~OmniboxViewMac() override; |
| 44 | 46 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 175 |
| 174 // Pass the current content of |field_| to SetText(), maintaining | 176 // Pass the current content of |field_| to SetText(), maintaining |
| 175 // any selection. Named to be consistent with GTK and Windows, | 177 // any selection. Named to be consistent with GTK and Windows, |
| 176 // though here we cannot really do the in-place operation they do. | 178 // though here we cannot really do the in-place operation they do. |
| 177 void EmphasizeURLComponents() override; | 179 void EmphasizeURLComponents() override; |
| 178 | 180 |
| 179 // Apply our font and paragraph style to |attributedString|. | 181 // Apply our font and paragraph style to |attributedString|. |
| 180 void ApplyTextStyle(NSMutableAttributedString* attributedString); | 182 void ApplyTextStyle(NSMutableAttributedString* attributedString); |
| 181 | 183 |
| 182 // Calculates text attributes according to |display_text| and applies them | 184 // Calculates text attributes according to |display_text| and applies them |
| 183 // to the given |attributedString| object. | 185 // to the given |attributed_string| object. |
| 184 void ApplyTextAttributes(const base::string16& display_text, | 186 void ApplyTextAttributes(const base::string16& display_text, |
| 185 NSMutableAttributedString* attributedString); | 187 NSMutableAttributedString* attributed_string); |
| 188 |
| 189 // OmniboxView: |
| 190 void SetEmphasis(bool emphasize, const gfx::Range& range) override; |
| 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 |