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 // This file defines the interface class OmniboxView. Each toolkit will | 5 // This file defines the interface class OmniboxView. Each toolkit will |
6 // implement the edit view differently, so that code is inherently platform | 6 // implement the edit view differently, so that code is inherently platform |
7 // specific. However, the OmniboxEditModel needs to do some communication with | 7 // specific. However, the OmniboxEditModel needs to do some communication with |
8 // the view. Since the model is shared between platforms, we need to define an | 8 // the view. Since the model is shared between platforms, we need to define an |
9 // interface that all view implementations will share. | 9 // interface that all view implementations will share. |
10 | 10 |
11 #ifndef COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_VIEW_H_ | 11 #ifndef COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_VIEW_H_ |
12 #define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_VIEW_H_ | 12 #define COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_VIEW_H_ |
13 | 13 |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 | 15 |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
23 #include "components/omnibox/browser/autocomplete_match.h" | 23 #include "components/omnibox/browser/autocomplete_match.h" |
24 #include "ui/base/window_open_disposition.h" | 24 #include "ui/base/window_open_disposition.h" |
25 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
26 #include "ui/gfx/range/range.h" | |
26 | 27 |
27 class GURL; | 28 class GURL; |
28 class OmniboxClient; | 29 class OmniboxClient; |
29 class OmniboxEditController; | 30 class OmniboxEditController; |
30 class OmniboxViewMacTest; | 31 class OmniboxViewMacTest; |
31 class OmniboxEditModel; | 32 class OmniboxEditModel; |
32 | 33 |
33 namespace gfx { | 34 namespace gfx { |
34 enum class VectorIconId; | 35 enum class VectorIconId; |
35 } | 36 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 // Fills |state| with the current text state. | 242 // Fills |state| with the current text state. |
242 void GetState(State* state); | 243 void GetState(State* state); |
243 | 244 |
244 // Returns the delta between |before| and |after|. | 245 // Returns the delta between |before| and |after|. |
245 StateChanges GetStateChanges(const State& before, | 246 StateChanges GetStateChanges(const State& before, |
246 const State& after); | 247 const State& after); |
247 | 248 |
248 // Internally invoked whenever the text changes in some way. | 249 // Internally invoked whenever the text changes in some way. |
249 virtual void TextChanged(); | 250 virtual void TextChanged(); |
250 | 251 |
252 // Returns whether the current text in the model represents a URL. Provided | |
253 // to allow tests to override the result. | |
254 virtual bool CurrentTextIsURL(); | |
255 | |
251 // Return the number of characters in the current buffer. The name | 256 // Return the number of characters in the current buffer. The name |
252 // |GetTextLength| can't be used as the Windows override of this class | 257 // |GetTextLength| can't be used as the Windows override of this class |
253 // inherits from a class that defines a method with that name. | 258 // inherits from a class that defines a method with that name. |
254 virtual int GetOmniboxTextLength() const = 0; | 259 virtual int GetOmniboxTextLength() const = 0; |
255 | 260 |
256 // Try to parse the current text as a URL and colorize the components. | 261 // Try to parse the current text as a URL and colorize the components. |
257 virtual void EmphasizeURLComponents() = 0; | 262 virtual void EmphasizeURLComponents() = 0; |
258 | 263 |
259 OmniboxEditController* controller() { return controller_; } | 264 OmniboxEditController* controller() { return controller_; } |
260 const OmniboxEditController* controller() const { return controller_; } | 265 const OmniboxEditController* controller() const { return controller_; } |
261 | 266 |
267 // Marks part (or, if |range| is invalid, all) of the current text as | |
268 // emphasized or de-emphasized, by changing its color. | |
269 virtual void SetEmphasis(bool emphasize, const gfx::Range& range) = 0; | |
270 | |
271 // Sets the color and strikethrough state for |range|, which represents the | |
272 // current scheme, based on the current security state. Schemes are displayed | |
273 // in different ways for different security levels. | |
274 virtual void UpdateSchemeStyle(const gfx::Range& range) = 0; | |
275 | |
276 // Parses |display_text|, then invokes |SetEmphasis| and |UpdateSchemeStyle| | |
Peter Kasting
2017/03/03 02:31:10
Nit: |SetEmphasis| -> SetEmphasis(), and similar
elawrence
2017/03/03 16:07:42
Done.
| |
277 // appropriately. If the text is a query string, there is no scheme, and | |
278 // everything is emphasized equally, whereas for URLs the scheme may be styled | |
279 // based on the current security state, with parts of the URL de-emphasized to | |
280 // draw attention to whatever best represents the "identity" of the current | |
281 // URL. | |
282 void UpdateTextStyle(const base::string16& display_text, | |
283 const AutocompleteSchemeClassifier& classifier); | |
284 | |
262 private: | 285 private: |
263 friend class OmniboxViewMacTest; | 286 friend class OmniboxViewMacTest; |
264 | 287 |
265 // |model_| can be NULL in tests. | 288 // |model_| can be NULL in tests. |
266 std::unique_ptr<OmniboxEditModel> model_; | 289 std::unique_ptr<OmniboxEditModel> model_; |
267 OmniboxEditController* controller_; | 290 OmniboxEditController* controller_; |
268 | 291 |
269 DISALLOW_COPY_AND_ASSIGN(OmniboxView); | 292 DISALLOW_COPY_AND_ASSIGN(OmniboxView); |
270 }; | 293 }; |
271 | 294 |
272 #endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_VIEW_H_ | 295 #endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_VIEW_H_ |
OLD | NEW |