Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model.cc

Issue 9691003: Add Content API around CertStore. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix clang Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ssl/ssl_error_info.h" 12 #include "chrome/browser/ssl/ssl_error_info.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/common/chrome_constants.h" 14 #include "chrome/common/chrome_constants.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "content/browser/cert_store.h" 17 #include "content/public/browser/cert_store.h"
18 #include "content/public/browser/navigation_controller.h" 18 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_ui.h" 21 #include "content/public/browser/web_ui.h"
22 #include "content/public/common/content_constants.h" 22 #include "content/public/common/content_constants.h"
23 #include "content/public/common/ssl_status.h" 23 #include "content/public/common/ssl_status.h"
24 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
25 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
26 #include "net/base/cert_status_flags.h" 26 #include "net/base/cert_status_flags.h"
27 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return SECURITY_ERROR; 116 return SECURITY_ERROR;
117 117
118 case content::SECURITY_STYLE_AUTHENTICATED: 118 case content::SECURITY_STYLE_AUTHENTICATED:
119 if (!!(ssl.content_status & SSLStatus::DISPLAYED_INSECURE_CONTENT)) 119 if (!!(ssl.content_status & SSLStatus::DISPLAYED_INSECURE_CONTENT))
120 return SECURITY_WARNING; 120 return SECURITY_WARNING;
121 if (net::IsCertStatusError(ssl.cert_status)) { 121 if (net::IsCertStatusError(ssl.cert_status)) {
122 DCHECK(net::IsCertStatusMinorError(ssl.cert_status)); 122 DCHECK(net::IsCertStatusMinorError(ssl.cert_status));
123 return SECURITY_WARNING; 123 return SECURITY_WARNING;
124 } 124 }
125 if ((ssl.cert_status & net::CERT_STATUS_IS_EV) && 125 if ((ssl.cert_status & net::CERT_STATUS_IS_EV) &&
126 CertStore::GetInstance()->RetrieveCert(ssl.cert_id, NULL)) 126 content::CertStore::GetInstance()->RetrieveCert(ssl.cert_id, NULL))
127 return EV_SECURE; 127 return EV_SECURE;
128 return SECURE; 128 return SECURE;
129 129
130 default: 130 default:
131 NOTREACHED(); 131 NOTREACHED();
132 return NONE; 132 return NONE;
133 } 133 }
134 } 134 }
135 135
136 int ToolbarModel::GetIcon() const { 136 int ToolbarModel::GetIcon() const {
137 static int icon_ids[NUM_SECURITY_LEVELS] = { 137 static int icon_ids[NUM_SECURITY_LEVELS] = {
138 IDR_OMNIBOX_HTTP, 138 IDR_OMNIBOX_HTTP,
139 IDR_OMNIBOX_HTTPS_VALID, 139 IDR_OMNIBOX_HTTPS_VALID,
140 IDR_OMNIBOX_HTTPS_VALID, 140 IDR_OMNIBOX_HTTPS_VALID,
141 IDR_OMNIBOX_HTTPS_WARNING, 141 IDR_OMNIBOX_HTTPS_WARNING,
142 IDR_OMNIBOX_HTTPS_INVALID, 142 IDR_OMNIBOX_HTTPS_INVALID,
143 }; 143 };
144 DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS); 144 DCHECK(arraysize(icon_ids) == NUM_SECURITY_LEVELS);
145 return icon_ids[GetSecurityLevel()]; 145 return icon_ids[GetSecurityLevel()];
146 } 146 }
147 147
148 string16 ToolbarModel::GetEVCertName() const { 148 string16 ToolbarModel::GetEVCertName() const {
149 DCHECK_EQ(GetSecurityLevel(), EV_SECURE); 149 DCHECK_EQ(GetSecurityLevel(), EV_SECURE);
150 scoped_refptr<net::X509Certificate> cert; 150 scoped_refptr<net::X509Certificate> cert;
151 // Note: Navigation controller and active entry are guaranteed non-NULL or 151 // Note: Navigation controller and active entry are guaranteed non-NULL or
152 // the security level would be NONE. 152 // the security level would be NONE.
153 CertStore::GetInstance()->RetrieveCert( 153 content::CertStore::GetInstance()->RetrieveCert(
154 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert); 154 GetNavigationController()->GetVisibleEntry()->GetSSL().cert_id, &cert);
155 return GetEVCertName(*cert); 155 return GetEVCertName(*cert);
156 } 156 }
157 157
158 // static 158 // static
159 string16 ToolbarModel::GetEVCertName(const net::X509Certificate& cert) { 159 string16 ToolbarModel::GetEVCertName(const net::X509Certificate& cert) {
160 // EV are required to have an organization name and country. 160 // EV are required to have an organization name and country.
161 if (cert.subject().organization_names.empty() || 161 if (cert.subject().organization_names.empty() ||
162 cert.subject().country_name.empty()) { 162 cert.subject().country_name.empty()) {
163 NOTREACHED(); 163 NOTREACHED();
164 return string16(); 164 return string16();
165 } 165 }
166 166
167 return l10n_util::GetStringFUTF16( 167 return l10n_util::GetStringFUTF16(
168 IDS_SECURE_CONNECTION_EV, 168 IDS_SECURE_CONNECTION_EV,
169 UTF8ToUTF16(cert.subject().organization_names[0]), 169 UTF8ToUTF16(cert.subject().organization_names[0]),
170 UTF8ToUTF16(cert.subject().country_name)); 170 UTF8ToUTF16(cert.subject().country_name));
171 } 171 }
172 172
173 NavigationController* ToolbarModel::GetNavigationController() const { 173 NavigationController* ToolbarModel::GetNavigationController() const {
174 // This |current_tab| can be NULL during the initialization of the 174 // This |current_tab| can be NULL during the initialization of the
175 // toolbar during window creation (i.e. before any tabs have been added 175 // toolbar during window creation (i.e. before any tabs have been added
176 // to the window). 176 // to the window).
177 WebContents* current_tab = browser_->GetSelectedWebContents(); 177 WebContents* current_tab = browser_->GetSelectedWebContents();
178 return current_tab ? &current_tab->GetController() : NULL; 178 return current_tab ? &current_tab->GetController() : NULL;
179 } 179 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/page_info_bubble_controller.mm ('k') | chrome/browser/ui/views/page_info_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698