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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 std::wstring ToolbarModel::GetEVCertName() const { | 115 std::wstring ToolbarModel::GetEVCertName() const { |
116 DCHECK_EQ(GetSecurityLevel(), EV_SECURE); | 116 DCHECK_EQ(GetSecurityLevel(), EV_SECURE); |
117 scoped_refptr<net::X509Certificate> cert; | 117 scoped_refptr<net::X509Certificate> cert; |
118 // Note: Navigation controller and active entry are guaranteed non-NULL or | 118 // Note: Navigation controller and active entry are guaranteed non-NULL or |
119 // the security level would be NONE. | 119 // the security level would be NONE. |
120 CertStore::GetInstance()->RetrieveCert( | 120 CertStore::GetInstance()->RetrieveCert( |
121 GetNavigationController()->GetActiveEntry()->ssl().cert_id(), &cert); | 121 GetNavigationController()->GetActiveEntry()->ssl().cert_id(), &cert); |
122 return UTF16ToWideHack(SSLManager::GetEVCertName(*cert)); | 122 return UTF16ToWideHack(SSLManager::GetEVCertName(*cert)); |
123 } | 123 } |
124 | 124 |
| 125 string16 ToolbarModel::GetSiteName() const { |
| 126 DCHECK(GetNavigationController()); |
| 127 DCHECK(GetNavigationController()->GetActiveEntry()); |
| 128 return UTF8ToUTF16(net::GetHostAndPort( |
| 129 GetNavigationController()->GetActiveEntry()->url())); |
| 130 } |
| 131 |
| 132 string16 ToolbarModel::GetSiteAccount() const { |
| 133 if (!GetNavigationController() || |
| 134 !GetNavigationController()->GetActiveEntry()) |
| 135 return string16(); |
| 136 |
| 137 // TODO(sqs): find a better way of indicating "Logging in..." than just |
| 138 // returning a string here |
| 139 NavigationEntry* entry = GetNavigationController()->GetActiveEntry(); |
| 140 if (!entry->ssl().tls_username().empty()) |
| 141 return entry->ssl().tls_username(); |
| 142 else if (entry->url().SchemeIs("httpsv")) |
| 143 return ASCIIToUTF16("Logging in..."); |
| 144 else |
| 145 return string16(); |
| 146 } |
| 147 |
125 NavigationController* ToolbarModel::GetNavigationController() const { | 148 NavigationController* ToolbarModel::GetNavigationController() const { |
126 // This |current_tab| can be NULL during the initialization of the | 149 // This |current_tab| can be NULL during the initialization of the |
127 // toolbar during window creation (i.e. before any tabs have been added | 150 // toolbar during window creation (i.e. before any tabs have been added |
128 // to the window). | 151 // to the window). |
129 TabContents* current_tab = browser_->GetSelectedTabContents(); | 152 TabContents* current_tab = browser_->GetSelectedTabContents(); |
130 return current_tab ? ¤t_tab->controller() : NULL; | 153 return current_tab ? ¤t_tab->controller() : NULL; |
131 } | 154 } |
OLD | NEW |