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

Side by Side Diff: chrome/browser/page_info_model.cc

Issue 159521: Implementation of the page info dialog on Linux Gtk. (Closed)
Patch Set: Fix build Created 11 years, 4 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
« no previous file with comments | « chrome/browser/page_info_model.h ('k') | chrome/browser/page_info_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/page_info_model.h" 5 #include "chrome/browser/page_info_model.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/time_format.h" 8 #include "base/time_format.h"
9 #include "chrome/browser/cert_store.h" 9 #include "chrome/browser/cert_store.h"
10 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 } 31 }
32 32
33 PageInfoModel::PageInfoModel(Profile* profile, 33 PageInfoModel::PageInfoModel(Profile* profile,
34 const GURL& url, 34 const GURL& url,
35 const NavigationEntry::SSLStatus& ssl, 35 const NavigationEntry::SSLStatus& ssl,
36 bool show_history, 36 bool show_history,
37 PageInfoModelObserver* observer) 37 PageInfoModelObserver* observer)
38 : observer_(observer) { 38 : observer_(observer) {
39 bool state = true; 39 bool state = true;
40 std::wstring head_line; 40 string16 head_line;
41 std::wstring description; 41 string16 description;
42 std::wstring connection_msg; 42 string16 connection_msg;
43 scoped_refptr<net::X509Certificate> cert; 43 scoped_refptr<net::X509Certificate> cert;
44 44
45 // Identity section. 45 // Identity section.
46 std::wstring subject_name(UTF8ToWide(url.host())); 46 string16 subject_name(UTF8ToUTF16(url.host()));
47 bool empty_subject_name = false; 47 bool empty_subject_name = false;
48 if (subject_name.empty()) { 48 if (subject_name.empty()) {
49 subject_name.assign( 49 subject_name.assign(
50 l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); 50 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
51 empty_subject_name = true; 51 empty_subject_name = true;
52 } 52 }
53 if (ssl.cert_id() && 53 if (ssl.cert_id() &&
54 CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert) && 54 CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert) &&
55 !net::IsCertStatusError(ssl.cert_status())) { 55 !net::IsCertStatusError(ssl.cert_status())) {
56 // OK HTTPS page. 56 // OK HTTPS page.
57 if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) != 0) { 57 if ((ssl.cert_status() & net::CERT_STATUS_IS_EV) != 0) {
58 DCHECK(!cert->subject().organization_names.empty()); 58 DCHECK(!cert->subject().organization_names.empty());
59 head_line = 59 head_line =
60 l10n_util::GetStringF(IDS_PAGE_INFO_EV_IDENTITY_TITLE, 60 l10n_util::GetStringFUTF16(IDS_PAGE_INFO_EV_IDENTITY_TITLE,
61 UTF8ToWide(cert->subject().organization_names[0]), 61 UTF8ToUTF16(cert->subject().organization_names[0]),
62 UTF8ToWide(url.host())); 62 UTF8ToUTF16(url.host()));
63 // An EV Cert is required to have a city (localityName) and country but 63 // An EV Cert is required to have a city (localityName) and country but
64 // state is "if any". 64 // state is "if any".
65 DCHECK(!cert->subject().locality_name.empty()); 65 DCHECK(!cert->subject().locality_name.empty());
66 DCHECK(!cert->subject().country_name.empty()); 66 DCHECK(!cert->subject().country_name.empty());
67 std::wstring locality; 67 string16 locality;
68 if (!cert->subject().state_or_province_name.empty()) { 68 if (!cert->subject().state_or_province_name.empty()) {
69 locality = l10n_util::GetStringF( 69 locality = l10n_util::GetStringFUTF16(
70 IDS_PAGEINFO_ADDRESS, 70 IDS_PAGEINFO_ADDRESS,
71 UTF8ToWide(cert->subject().locality_name), 71 UTF8ToUTF16(cert->subject().locality_name),
72 UTF8ToWide(cert->subject().state_or_province_name), 72 UTF8ToUTF16(cert->subject().state_or_province_name),
73 UTF8ToWide(cert->subject().country_name)); 73 UTF8ToUTF16(cert->subject().country_name));
74 } else { 74 } else {
75 locality = l10n_util::GetStringF( 75 locality = l10n_util::GetStringFUTF16(
76 IDS_PAGEINFO_PARTIAL_ADDRESS, 76 IDS_PAGEINFO_PARTIAL_ADDRESS,
77 UTF8ToWide(cert->subject().locality_name), 77 UTF8ToUTF16(cert->subject().locality_name),
78 UTF8ToWide(cert->subject().country_name)); 78 UTF8ToUTF16(cert->subject().country_name));
79 } 79 }
80 DCHECK(!cert->subject().organization_names.empty()); 80 DCHECK(!cert->subject().organization_names.empty());
81 description.assign(l10n_util::GetStringF( 81 description.assign(l10n_util::GetStringFUTF16(
82 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV, 82 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY_EV,
83 UTF8ToWide(cert->subject().organization_names[0]), 83 UTF8ToUTF16(cert->subject().organization_names[0]),
84 locality, 84 locality,
85 UTF8ToWide(GetIssuerName(cert->issuer())))); 85 UTF8ToUTF16(GetIssuerName(cert->issuer()))));
86 } else { 86 } else {
87 // Non EV OK HTTPS. 87 // Non EV OK HTTPS.
88 if (empty_subject_name) 88 if (empty_subject_name)
89 head_line.clear(); // Don't display any title. 89 head_line.clear(); // Don't display any title.
90 else 90 else
91 head_line.assign(subject_name); 91 head_line.assign(subject_name);
92 std::wstring issuer_name(UTF8ToWide(GetIssuerName(cert->issuer()))); 92 string16 issuer_name(UTF8ToUTF16(GetIssuerName(cert->issuer())));
93 if (issuer_name.empty()) { 93 if (issuer_name.empty()) {
94 issuer_name.assign( 94 issuer_name.assign(l10n_util::GetStringUTF16(
95 l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); 95 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
96 } else { 96 } else {
97 description.assign( 97 description.assign(l10n_util::GetStringFUTF16(
98 l10n_util::GetStringF(IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, 98 IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name));
99 issuer_name));
100 } 99 }
101 } 100 }
102 } else { 101 } else {
103 // Bad HTTPS. 102 // Bad HTTPS.
104 description.assign( 103 description.assign(l10n_util::GetStringUTF16(
105 l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); 104 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY));
106 state = false; 105 state = false;
107 } 106 }
108 sections_.push_back(SectionInfo( 107 sections_.push_back(SectionInfo(
109 state, 108 state,
110 l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), 109 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE),
111 head_line, 110 head_line,
112 description)); 111 description));
113 112
114 // Connection section. 113 // Connection section.
115 // We consider anything less than 80 bits encryption to be weak encryption. 114 // We consider anything less than 80 bits encryption to be weak encryption.
116 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and 115 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
117 // weakly encrypted connections. 116 // weakly encrypted connections.
118 state = true; 117 state = true;
119 head_line.clear(); 118 head_line.clear();
120 description.clear(); 119 description.clear();
121 if (ssl.security_bits() <= 0) { 120 if (ssl.security_bits() <= 0) {
122 state = false; 121 state = false;
123 description.assign( 122 description.assign(
124 l10n_util::GetStringF( 123 l10n_util::GetStringFUTF16(
125 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, 124 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
126 subject_name)); 125 subject_name));
127 } else if (ssl.security_bits() < 80) { 126 } else if (ssl.security_bits() < 80) {
128 state = false; 127 state = false;
129 description.assign( 128 description.assign(
130 l10n_util::GetStringF( 129 l10n_util::GetStringFUTF16(
131 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, 130 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
132 subject_name)); 131 subject_name));
133 } else { 132 } else {
134 description.assign( 133 description.assign(
135 l10n_util::GetStringF( 134 l10n_util::GetStringFUTF16(
136 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, 135 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT,
137 subject_name, 136 subject_name,
138 IntToWString(ssl.security_bits()))); 137 IntToString16(ssl.security_bits())));
139 if (ssl.has_mixed_content()) { 138 if (ssl.has_mixed_content()) {
140 state = false; 139 state = false;
141 description.assign( 140 description.assign(
142 l10n_util::GetStringF( 141 l10n_util::GetStringFUTF16(
143 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, 142 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
144 connection_msg, 143 connection_msg,
145 l10n_util::GetString( 144 l10n_util::GetStringUTF16(
146 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_MIXED_CONTENT_WARNING))); 145 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_MIXED_CONTENT_WARNING)));
147 } else if (ssl.has_unsafe_content()) { 146 } else if (ssl.has_unsafe_content()) {
148 state = false; 147 state = false;
149 description.assign( 148 description.assign(
150 l10n_util::GetStringF( 149 l10n_util::GetStringFUTF16(
151 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, 150 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK,
152 connection_msg, 151 connection_msg,
153 l10n_util::GetString( 152 l10n_util::GetStringUTF16(
154 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_BAD_HTTPS_WARNING))); 153 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_BAD_HTTPS_WARNING)));
155 } 154 }
156 } 155 }
157 sections_.push_back(SectionInfo( 156 sections_.push_back(SectionInfo(
158 state, 157 state,
159 l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE), 158 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE),
160 head_line, 159 head_line,
161 description)); 160 description));
162 161
163 // Request the number of visits. 162 // Request the number of visits.
164 HistoryService* history = profile->GetHistoryService( 163 HistoryService* history = profile->GetHistoryService(
165 Profile::EXPLICIT_ACCESS); 164 Profile::EXPLICIT_ACCESS);
166 if (show_history && history) { 165 if (show_history && history) {
167 history->GetVisitCountToHost( 166 history->GetVisitCountToHost(
168 url, 167 url,
169 &request_consumer_, 168 &request_consumer_,
(...skipping 22 matching lines...) Expand all
192 bool visited_before_today = false; 191 bool visited_before_today = false;
193 if (count) { 192 if (count) {
194 base::Time today = base::Time::Now().LocalMidnight(); 193 base::Time today = base::Time::Now().LocalMidnight();
195 base::Time first_visit_midnight = first_visit.LocalMidnight(); 194 base::Time first_visit_midnight = first_visit.LocalMidnight();
196 visited_before_today = (first_visit_midnight < today); 195 visited_before_today = (first_visit_midnight < today);
197 } 196 }
198 197
199 if (!visited_before_today) { 198 if (!visited_before_today) {
200 sections_.push_back(SectionInfo( 199 sections_.push_back(SectionInfo(
201 false, 200 false,
202 l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), 201 l10n_util::GetStringUTF16(
203 std::wstring(), 202 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE),
204 l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY))); 203 string16(),
204 l10n_util::GetStringUTF16(
205 IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY)));
205 } else { 206 } else {
206 sections_.push_back(SectionInfo( 207 sections_.push_back(SectionInfo(
207 true, 208 true,
208 l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), 209 l10n_util::GetStringUTF16(
209 std::wstring(), 210 IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE),
210 l10n_util::GetStringF(IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY, 211 string16(),
211 base::TimeFormatShortDate(first_visit)))); 212 l10n_util::GetStringFUTF16(
213 IDS_PAGE_INFO_SECURITY_TAB_VISITED_BEFORE_TODAY,
214 WideToUTF16(base::TimeFormatShortDate(first_visit)))));
212 } 215 }
213 observer_->ModelChanged(); 216 observer_->ModelChanged();
214 } 217 }
215 218
216 // static 219 // static
217 void PageInfoModel::RegisterPrefs(PrefService* prefs) { 220 void PageInfoModel::RegisterPrefs(PrefService* prefs) {
218 prefs->RegisterDictionaryPref(prefs::kPageInfoWindowPlacement); 221 prefs->RegisterDictionaryPref(prefs::kPageInfoWindowPlacement);
219 } 222 }
OLDNEW
« no previous file with comments | « chrome/browser/page_info_model.h ('k') | chrome/browser/page_info_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698