OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_TOOLBAR_TOOLBAR_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ |
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "chrome/browser/ssl/connection_security_helper.h" | |
13 #include "url/gurl.h" | 12 #include "url/gurl.h" |
14 | 13 |
15 namespace net { | 14 namespace net { |
16 class X509Certificate; | 15 class X509Certificate; |
17 } | 16 } |
18 | 17 |
19 // This class is the model used by the toolbar, location bar and autocomplete | 18 // This class is the model used by the toolbar, location bar and autocomplete |
20 // edit. It populates its states from the current navigation entry retrieved | 19 // edit. It populates its states from the current navigation entry retrieved |
21 // from the navigation controller returned by GetNavigationController(). | 20 // from the navigation controller returned by GetNavigationController(). |
22 class ToolbarModel { | 21 class ToolbarModel { |
23 public: | 22 public: |
| 23 // TODO(wtc): unify ToolbarModel::SecurityLevel with SecurityStyle. We |
| 24 // don't need two sets of security UI levels. SECURITY_STYLE_AUTHENTICATED |
| 25 // needs to be refined into three levels: warning, standard, and EV. |
| 26 // |
| 27 // A Java counterpart will be generated for this enum. |
| 28 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ui.toolbar |
| 29 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ToolbarModelSecurityLevel |
| 30 enum SecurityLevel { |
| 31 // HTTP/no URL/user is editing |
| 32 NONE = 0, |
| 33 |
| 34 // HTTPS with valid EV cert |
| 35 EV_SECURE = 1, |
| 36 |
| 37 // HTTPS (non-EV) |
| 38 SECURE = 2, |
| 39 |
| 40 // HTTPS, but unable to check certificate revocation status or with insecure |
| 41 // content on the page |
| 42 SECURITY_WARNING = 3, |
| 43 |
| 44 // HTTPS, but the certificate verification chain is anchored on a |
| 45 // certificate that was installed by the system administrator |
| 46 SECURITY_POLICY_WARNING = 4, |
| 47 |
| 48 // Attempted HTTPS and failed, page not authenticated |
| 49 SECURITY_ERROR = 5, |
| 50 |
| 51 NUM_SECURITY_LEVELS = 6, |
| 52 }; |
| 53 |
24 virtual ~ToolbarModel(); | 54 virtual ~ToolbarModel(); |
25 | 55 |
26 // Returns the text to be displayed in the toolbar for the current page. | 56 // Returns the text to be displayed in the toolbar for the current page. |
27 // This will have been formatted for display to the user. | 57 // This will have been formatted for display to the user. |
28 // - If the current page's URL is a search URL for the user's default search | 58 // - If the current page's URL is a search URL for the user's default search |
29 // engine, the query will be extracted and returned for display instead | 59 // engine, the query will be extracted and returned for display instead |
30 // of the URL. | 60 // of the URL. |
31 // - Otherwise, the text will contain the URL returned by GetFormattedURL(). | 61 // - Otherwise, the text will contain the URL returned by GetFormattedURL(). |
32 virtual base::string16 GetText() const = 0; | 62 virtual base::string16 GetText() const = 0; |
33 | 63 |
(...skipping 22 matching lines...) Expand all Loading... |
56 virtual bool WouldPerformSearchTermReplacement(bool ignore_editing) const = 0; | 86 virtual bool WouldPerformSearchTermReplacement(bool ignore_editing) const = 0; |
57 | 87 |
58 // Returns true if a call to GetText() would return something other than the | 88 // Returns true if a call to GetText() would return something other than the |
59 // URL because of search term replacement. | 89 // URL because of search term replacement. |
60 bool WouldReplaceURL() const; | 90 bool WouldReplaceURL() const; |
61 | 91 |
62 // Returns the security level that the toolbar should display. If | 92 // Returns the security level that the toolbar should display. If |
63 // |ignore_editing| is true, the result reflects the underlying state of the | 93 // |ignore_editing| is true, the result reflects the underlying state of the |
64 // page without regard to any user edits that may be in progress in the | 94 // page without regard to any user edits that may be in progress in the |
65 // omnibox. | 95 // omnibox. |
66 virtual ConnectionSecurityHelper::SecurityLevel GetSecurityLevel( | 96 virtual SecurityLevel GetSecurityLevel(bool ignore_editing) const = 0; |
67 bool ignore_editing) const = 0; | |
68 | 97 |
69 // Returns the resource_id of the icon to show to the left of the address, | 98 // Returns the resource_id of the icon to show to the left of the address, |
70 // based on the current URL. When search term replacement is active, this | 99 // based on the current URL. When search term replacement is active, this |
71 // returns a search icon. This doesn't cover specialized icons while the | 100 // returns a search icon. This doesn't cover specialized icons while the |
72 // user is editing; see OmniboxView::GetIcon(). | 101 // user is editing; see OmniboxView::GetIcon(). |
73 virtual int GetIcon() const = 0; | 102 virtual int GetIcon() const = 0; |
74 | 103 |
75 // As |GetIcon()|, but returns the icon only taking into account the security | 104 // As |GetIcon()|, but returns the icon only taking into account the security |
76 // |level| given, ignoring search term replacement state. | 105 // |level| given, ignoring search term replacement state. |
77 virtual int GetIconForSecurityLevel( | 106 virtual int GetIconForSecurityLevel(SecurityLevel level) const = 0; |
78 ConnectionSecurityHelper::SecurityLevel level) const = 0; | |
79 | 107 |
80 // Returns the name of the EV cert holder. This returns an empty string if | 108 // Returns the name of the EV cert holder. This returns an empty string if |
81 // the security level is not EV_SECURE. | 109 // the security level is not EV_SECURE. |
82 virtual base::string16 GetEVCertName() const = 0; | 110 virtual base::string16 GetEVCertName() const = 0; |
83 | 111 |
84 // Returns whether the URL for the current navigation entry should be | 112 // Returns whether the URL for the current navigation entry should be |
85 // in the location bar. | 113 // in the location bar. |
86 virtual bool ShouldDisplayURL() const = 0; | 114 virtual bool ShouldDisplayURL() const = 0; |
87 | 115 |
88 // Whether the text in the omnibox is currently being edited. | 116 // Whether the text in the omnibox is currently being edited. |
(...skipping 14 matching lines...) Expand all Loading... |
103 ToolbarModel(); | 131 ToolbarModel(); |
104 | 132 |
105 private: | 133 private: |
106 bool input_in_progress_; | 134 bool input_in_progress_; |
107 bool url_replacement_enabled_; | 135 bool url_replacement_enabled_; |
108 | 136 |
109 DISALLOW_COPY_AND_ASSIGN(ToolbarModel); | 137 DISALLOW_COPY_AND_ASSIGN(ToolbarModel); |
110 }; | 138 }; |
111 | 139 |
112 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ | 140 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_MODEL_H_ |
OLD | NEW |