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

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

Issue 7111013: Move most of the core SSL code from chrome to content. The UI code that's specific to Chrome (i.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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) 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/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/browser/cert_store.h"
18 #include "content/browser/tab_contents/navigation_controller.h" 18 #include "content/browser/tab_contents/navigation_controller.h"
19 #include "content/browser/tab_contents/navigation_entry.h" 19 #include "content/browser/tab_contents/navigation_entry.h"
20 #include "content/browser/tab_contents/tab_contents.h" 20 #include "content/browser/tab_contents/tab_contents.h"
21 #include "content/common/content_constants.h" 21 #include "content/common/content_constants.h"
22 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
23 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
24 #include "net/base/cert_status_flags.h" 24 #include "net/base/cert_status_flags.h"
25 #include "net/base/net_util.h" 25 #include "net/base/net_util.h"
26 #include "ui/base/l10n/l10n_util.h"
26 27
27 ToolbarModel::ToolbarModel(Browser* browser) 28 ToolbarModel::ToolbarModel(Browser* browser)
28 : browser_(browser), 29 : browser_(browser),
29 input_in_progress_(false) { 30 input_in_progress_(false) {
30 } 31 }
31 32
32 ToolbarModel::~ToolbarModel() { 33 ToolbarModel::~ToolbarModel() {
33 } 34 }
34 35
35 // ToolbarModel Implementation. 36 // ToolbarModel Implementation.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return icon_ids[GetSecurityLevel()]; 114 return icon_ids[GetSecurityLevel()];
114 } 115 }
115 116
116 std::wstring ToolbarModel::GetEVCertName() const { 117 std::wstring ToolbarModel::GetEVCertName() const {
117 DCHECK_EQ(GetSecurityLevel(), EV_SECURE); 118 DCHECK_EQ(GetSecurityLevel(), EV_SECURE);
118 scoped_refptr<net::X509Certificate> cert; 119 scoped_refptr<net::X509Certificate> cert;
119 // Note: Navigation controller and active entry are guaranteed non-NULL or 120 // Note: Navigation controller and active entry are guaranteed non-NULL or
120 // the security level would be NONE. 121 // the security level would be NONE.
121 CertStore::GetInstance()->RetrieveCert( 122 CertStore::GetInstance()->RetrieveCert(
122 GetNavigationController()->GetActiveEntry()->ssl().cert_id(), &cert); 123 GetNavigationController()->GetActiveEntry()->ssl().cert_id(), &cert);
123 return UTF16ToWideHack(SSLManager::GetEVCertName(*cert)); 124 return UTF16ToWideHack(GetEVCertName(*cert));
125 }
126
127 // static
128 string16 ToolbarModel::GetEVCertName(const net::X509Certificate& cert) {
129 // EV are required to have an organization name and country.
130 if (cert.subject().organization_names.empty() ||
131 cert.subject().country_name.empty()) {
132 NOTREACHED();
133 return string16();
134 }
135
136 return l10n_util::GetStringFUTF16(
137 IDS_SECURE_CONNECTION_EV,
138 UTF8ToUTF16(cert.subject().organization_names[0]),
139 UTF8ToUTF16(cert.subject().country_name));
124 } 140 }
125 141
126 NavigationController* ToolbarModel::GetNavigationController() const { 142 NavigationController* ToolbarModel::GetNavigationController() const {
127 // This |current_tab| can be NULL during the initialization of the 143 // This |current_tab| can be NULL during the initialization of the
128 // toolbar during window creation (i.e. before any tabs have been added 144 // toolbar during window creation (i.e. before any tabs have been added
129 // to the window). 145 // to the window).
130 TabContents* current_tab = browser_->GetSelectedTabContents(); 146 TabContents* current_tab = browser_->GetSelectedTabContents();
131 return current_tab ? &current_tab->controller() : NULL; 147 return current_tab ? &current_tab->controller() : NULL;
132 } 148 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_model.h ('k') | chrome/browser/ui/views/ssl_client_certificate_selector_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698