OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete.h" | 8 #include "chrome/browser/autocomplete/autocomplete.h" |
9 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
10 #include "chrome/browser/cert_store.h" | 10 #include "chrome/browser/cert_store.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 case SECURITY_STYLE_AUTHENTICATED: | 82 case SECURITY_STYLE_AUTHENTICATED: |
83 if (ssl.displayed_insecure_content()) | 83 if (ssl.displayed_insecure_content()) |
84 return SECURITY_WARNING; | 84 return SECURITY_WARNING; |
85 if (net::IsCertStatusError(ssl.cert_status())) { | 85 if (net::IsCertStatusError(ssl.cert_status())) { |
86 DCHECK_EQ(ssl.cert_status() & net::CERT_STATUS_ALL_ERRORS, | 86 DCHECK_EQ(ssl.cert_status() & net::CERT_STATUS_ALL_ERRORS, |
87 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION); | 87 net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION); |
88 return SECURITY_WARNING; | 88 return SECURITY_WARNING; |
89 } | 89 } |
90 if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) && | 90 if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) && |
91 CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), NULL)) | 91 CertStore::GetInstance()->RetrieveCert(ssl.cert_id(), NULL)) |
92 return EV_SECURE; | 92 return EV_SECURE; |
93 return SECURE; | 93 return SECURE; |
94 | 94 |
95 default: | 95 default: |
96 NOTREACHED(); | 96 NOTREACHED(); |
97 return NONE; | 97 return NONE; |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 int ToolbarModel::GetIcon() const { | 101 int ToolbarModel::GetIcon() const { |
102 static int icon_ids[NUM_SECURITY_LEVELS] = { | 102 static int icon_ids[NUM_SECURITY_LEVELS] = { |
103 IDR_OMNIBOX_HTTP, | 103 IDR_OMNIBOX_HTTP, |
104 IDR_OMNIBOX_HTTPS_VALID, | 104 IDR_OMNIBOX_HTTPS_VALID, |
105 IDR_OMNIBOX_HTTPS_VALID, | 105 IDR_OMNIBOX_HTTPS_VALID, |
106 IDR_OMNIBOX_HTTPS_WARNING, | 106 IDR_OMNIBOX_HTTPS_WARNING, |
107 IDR_OMNIBOX_HTTPS_INVALID, | 107 IDR_OMNIBOX_HTTPS_INVALID, |
108 }; | 108 }; |
109 DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS); | 109 DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS); |
110 return icon_ids[GetSecurityLevel()]; | 110 return icon_ids[GetSecurityLevel()]; |
111 } | 111 } |
112 | 112 |
113 std::wstring ToolbarModel::GetEVCertName() const { | 113 std::wstring ToolbarModel::GetEVCertName() const { |
114 DCHECK_EQ(GetSecurityLevel(), EV_SECURE); | 114 DCHECK_EQ(GetSecurityLevel(), EV_SECURE); |
115 scoped_refptr<net::X509Certificate> cert; | 115 scoped_refptr<net::X509Certificate> cert; |
116 // Note: Navigation controller and active entry are guaranteed non-NULL or | 116 // Note: Navigation controller and active entry are guaranteed non-NULL or |
117 // the security level would be NONE. | 117 // the security level would be NONE. |
118 CertStore::GetSharedInstance()->RetrieveCert( | 118 CertStore::GetInstance()->RetrieveCert( |
119 GetNavigationController()->GetActiveEntry()->ssl().cert_id(), &cert); | 119 GetNavigationController()->GetActiveEntry()->ssl().cert_id(), &cert); |
120 return SSLManager::GetEVCertName(*cert); | 120 return SSLManager::GetEVCertName(*cert); |
121 } | 121 } |
122 | 122 |
123 NavigationController* ToolbarModel::GetNavigationController() const { | 123 NavigationController* ToolbarModel::GetNavigationController() const { |
124 // This |current_tab| can be NULL during the initialization of the | 124 // This |current_tab| can be NULL during the initialization of the |
125 // toolbar during window creation (i.e. before any tabs have been added | 125 // toolbar during window creation (i.e. before any tabs have been added |
126 // to the window). | 126 // to the window). |
127 TabContents* current_tab = browser_->GetSelectedTabContents(); | 127 TabContents* current_tab = browser_->GetSelectedTabContents(); |
128 return current_tab ? ¤t_tab->controller() : NULL; | 128 return current_tab ? ¤t_tab->controller() : NULL; |
129 } | 129 } |
OLD | NEW |