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

Side by Side Diff: chrome/browser/ui/page_info/page_info.cc

Issue 2754383004: Rename WebsiteSettings code to PageInfo. (Closed)
Patch Set: Upload missing comment fix for WebSettingsUI -> PageInfoUI. Created 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/page_info/website_settings.h" 5 #include "chrome/browser/ui/page_info/page_info.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/i18n/time_formatting.h" 14 #include "base/i18n/time_formatting.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
(...skipping 16 matching lines...) Expand all
32 #include "chrome/browser/history/history_service_factory.h" 32 #include "chrome/browser/history/history_service_factory.h"
33 #include "chrome/browser/infobars/infobar_service.h" 33 #include "chrome/browser/infobars/infobar_service.h"
34 #include "chrome/browser/permissions/chooser_context_base.h" 34 #include "chrome/browser/permissions/chooser_context_base.h"
35 #include "chrome/browser/permissions/permission_manager.h" 35 #include "chrome/browser/permissions/permission_manager.h"
36 #include "chrome/browser/permissions/permission_result.h" 36 #include "chrome/browser/permissions/permission_result.h"
37 #include "chrome/browser/permissions/permission_uma_util.h" 37 #include "chrome/browser/permissions/permission_uma_util.h"
38 #include "chrome/browser/permissions/permission_util.h" 38 #include "chrome/browser/permissions/permission_util.h"
39 #include "chrome/browser/profiles/profile.h" 39 #include "chrome/browser/profiles/profile.h"
40 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" 40 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
41 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" 41 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
42 #include "chrome/browser/ui/page_info/website_settings_ui.h" 42 #include "chrome/browser/ui/page_info/page_info_ui.h"
43 #include "chrome/browser/usb/usb_chooser_context.h" 43 #include "chrome/browser/usb/usb_chooser_context.h"
44 #include "chrome/browser/usb/usb_chooser_context_factory.h" 44 #include "chrome/browser/usb/usb_chooser_context_factory.h"
45 #include "chrome/common/chrome_switches.h" 45 #include "chrome/common/chrome_switches.h"
46 #include "chrome/common/url_constants.h" 46 #include "chrome/common/url_constants.h"
47 #include "chrome/grit/chromium_strings.h" 47 #include "chrome/grit/chromium_strings.h"
48 #include "chrome/grit/generated_resources.h" 48 #include "chrome/grit/generated_resources.h"
49 #include "chrome/grit/theme_resources.h" 49 #include "chrome/grit/theme_resources.h"
50 #include "components/content_settings/core/browser/content_settings_utils.h" 50 #include "components/content_settings/core/browser/content_settings_utils.h"
51 #include "components/content_settings/core/browser/host_content_settings_map.h" 51 #include "components/content_settings/core/browser/host_content_settings_map.h"
52 #include "components/content_settings/core/common/content_settings.h" 52 #include "components/content_settings/core/common/content_settings.h"
(...skipping 15 matching lines...) Expand all
68 #include "third_party/boringssl/src/include/openssl/ssl.h" 68 #include "third_party/boringssl/src/include/openssl/ssl.h"
69 #include "ui/base/l10n/l10n_util.h" 69 #include "ui/base/l10n/l10n_util.h"
70 70
71 #if defined(OS_CHROMEOS) 71 #if defined(OS_CHROMEOS)
72 #include "chrome/browser/chromeos/policy/policy_cert_service.h" 72 #include "chrome/browser/chromeos/policy/policy_cert_service.h"
73 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" 73 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
74 #endif 74 #endif
75 75
76 #if !defined(OS_ANDROID) 76 #if !defined(OS_ANDROID)
77 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" 77 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
78 #include "chrome/browser/ui/page_info/website_settings_infobar_delegate.h" 78 #include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
79 #endif 79 #endif
80 80
81 using base::ASCIIToUTF16; 81 using base::ASCIIToUTF16;
82 using base::UTF8ToUTF16; 82 using base::UTF8ToUTF16;
83 using base::UTF16ToUTF8; 83 using base::UTF16ToUTF8;
84 using content::BrowserThread; 84 using content::BrowserThread;
85 85
86 namespace { 86 namespace {
87 87
88 // Events for UMA. Do not reorder or change! 88 // Events for UMA. Do not reorder or change!
89 enum SSLCertificateDecisionsDidRevoke { 89 enum SSLCertificateDecisionsDidRevoke {
90 USER_CERT_DECISIONS_NOT_REVOKED = 0, 90 USER_CERT_DECISIONS_NOT_REVOKED = 0,
91 USER_CERT_DECISIONS_REVOKED, 91 USER_CERT_DECISIONS_REVOKED,
92 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM 92 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM
93 }; 93 };
94 94
95 // The list of content settings types to display on the Website Settings UI. THE 95 // The list of content settings types to display on the Page Info UI. THE
96 // ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email 96 // ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email
97 // security-dev@chromium.org. 97 // security-dev@chromium.org.
98 ContentSettingsType kPermissionType[] = { 98 ContentSettingsType kPermissionType[] = {
99 CONTENT_SETTINGS_TYPE_GEOLOCATION, 99 CONTENT_SETTINGS_TYPE_GEOLOCATION,
100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, 100 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
101 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, 101 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
102 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 102 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
103 CONTENT_SETTINGS_TYPE_JAVASCRIPT, 103 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
104 #if !defined(OS_ANDROID) 104 #if !defined(OS_ANDROID)
105 CONTENT_SETTINGS_TYPE_PLUGINS, 105 CONTENT_SETTINGS_TYPE_PLUGINS,
106 CONTENT_SETTINGS_TYPE_IMAGES, 106 CONTENT_SETTINGS_TYPE_IMAGES,
107 #endif 107 #endif
108 CONTENT_SETTINGS_TYPE_POPUPS, 108 CONTENT_SETTINGS_TYPE_POPUPS,
109 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, 109 CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
110 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, 110 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
111 CONTENT_SETTINGS_TYPE_AUTOPLAY, 111 CONTENT_SETTINGS_TYPE_AUTOPLAY,
112 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 112 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
113 }; 113 };
114 114
115 // Determines whether to show permission |type| in the Website Settings UI. Only 115 // Determines whether to show permission |type| in the Page Info UI. Only
116 // applies to permissions listed in |kPermissionType|. 116 // applies to permissions listed in |kPermissionType|.
117 bool ShouldShowPermission(ContentSettingsType type) { 117 bool ShouldShowPermission(ContentSettingsType type) {
118 #if !defined(OS_ANDROID) 118 #if !defined(OS_ANDROID)
119 // Autoplay is Android-only at the moment. 119 // Autoplay is Android-only at the moment.
120 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY) 120 if (type == CONTENT_SETTINGS_TYPE_AUTOPLAY)
121 return false; 121 return false;
122 #endif 122 #endif
123 123
124 return true; 124 return true;
125 } 125 }
(...skipping 30 matching lines...) Expand all
156 if (net::IsCertStatusError(security_info.cert_status) && 156 if (net::IsCertStatusError(security_info.cert_status) &&
157 !net::IsCertStatusMinorError(security_info.cert_status)) { 157 !net::IsCertStatusMinorError(security_info.cert_status)) {
158 return; 158 return;
159 } 159 }
160 CheckContentStatus(security_info.content_with_cert_errors_status, displayed, 160 CheckContentStatus(security_info.content_with_cert_errors_status, displayed,
161 ran); 161 ran);
162 } 162 }
163 163
164 void GetSiteIdentityByMaliciousContentStatus( 164 void GetSiteIdentityByMaliciousContentStatus(
165 security_state::MaliciousContentStatus malicious_content_status, 165 security_state::MaliciousContentStatus malicious_content_status,
166 WebsiteSettings::SiteIdentityStatus* status, 166 PageInfo::SiteIdentityStatus* status,
167 base::string16* details) { 167 base::string16* details) {
168 switch (malicious_content_status) { 168 switch (malicious_content_status) {
169 case security_state::MALICIOUS_CONTENT_STATUS_NONE: 169 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
170 NOTREACHED(); 170 NOTREACHED();
171 break; 171 break;
172 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE: 172 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
173 *status = WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE; 173 *status = PageInfo::SITE_IDENTITY_STATUS_MALWARE;
174 *details = l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS); 174 *details = l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
175 break; 175 break;
176 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING: 176 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
177 *status = WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING; 177 *status = PageInfo::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
178 *details = 178 *details =
179 l10n_util::GetStringUTF16(IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS); 179 l10n_util::GetStringUTF16(IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
180 break; 180 break;
181 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE: 181 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
182 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE; 182 *status = PageInfo::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
183 *details = 183 *details =
184 l10n_util::GetStringUTF16(IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS); 184 l10n_util::GetStringUTF16(IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
185 break; 185 break;
186 } 186 }
187 } 187 }
188 188
189 base::string16 GetSimpleSiteName(const GURL& url) { 189 base::string16 GetSimpleSiteName(const GURL& url) {
190 return url_formatter::FormatUrlForSecurityDisplay( 190 return url_formatter::FormatUrlForSecurityDisplay(
191 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); 191 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
192 } 192 }
193 193
194 ChooserContextBase* GetUsbChooserContext(Profile* profile) { 194 ChooserContextBase* GetUsbChooserContext(Profile* profile) {
195 return UsbChooserContextFactory::GetForProfile(profile); 195 return UsbChooserContextFactory::GetForProfile(profile);
196 } 196 }
197 197
198 // The list of chooser types that need to display entries in the Website 198 // The list of chooser types that need to display entries in the Website
199 // Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, 199 // Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it,
200 // email security-dev@chromium.org. 200 // email security-dev@chromium.org.
201 WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = { 201 PageInfo::ChooserUIInfo kChooserUIInfo[] = {
202 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, 202 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
203 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL, 203 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_PAGE_INFO_USB_DEVICE_LABEL,
204 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"}, 204 IDS_PAGE_INFO_DELETE_USB_DEVICE, "name"},
205 }; 205 };
206 206
207 } // namespace 207 } // namespace
208 208
209 WebsiteSettings::WebsiteSettings( 209 PageInfo::PageInfo(PageInfoUI* ui,
210 WebsiteSettingsUI* ui, 210 Profile* profile,
211 Profile* profile, 211 TabSpecificContentSettings* tab_specific_content_settings,
212 TabSpecificContentSettings* tab_specific_content_settings, 212 content::WebContents* web_contents,
213 content::WebContents* web_contents, 213 const GURL& url,
214 const GURL& url, 214 const security_state::SecurityInfo& security_info)
215 const security_state::SecurityInfo& security_info)
216 : TabSpecificContentSettings::SiteDataObserver( 215 : TabSpecificContentSettings::SiteDataObserver(
217 tab_specific_content_settings), 216 tab_specific_content_settings),
218 content::WebContentsObserver(web_contents), 217 content::WebContentsObserver(web_contents),
219 ui_(ui), 218 ui_(ui),
220 show_info_bar_(false), 219 show_info_bar_(false),
221 site_url_(url), 220 site_url_(url),
222 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), 221 site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
223 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), 222 site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
224 show_ssl_decision_revoke_button_(false), 223 show_ssl_decision_revoke_button_(false),
225 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)), 224 content_settings_(HostContentSettingsMapFactory::GetForProfile(profile)),
226 chrome_ssl_host_state_delegate_( 225 chrome_ssl_host_state_delegate_(
227 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)), 226 ChromeSSLHostStateDelegateFactory::GetForProfile(profile)),
228 did_revoke_user_ssl_decisions_(false), 227 did_revoke_user_ssl_decisions_(false),
229 profile_(profile), 228 profile_(profile),
230 security_level_(security_state::NONE) { 229 security_level_(security_state::NONE) {
231 Init(url, security_info); 230 Init(url, security_info);
232 231
233 PresentSitePermissions(); 232 PresentSitePermissions();
234 PresentSiteData(); 233 PresentSiteData();
235 PresentSiteIdentity(); 234 PresentSiteIdentity();
236 235
237 // Every time the Website Settings UI is opened a |WebsiteSettings| object is 236 // Every time the Page Info UI is opened a |PageInfo| object is
238 // created. So this counts how ofter the Website Settings UI is opened. 237 // created. So this counts how ofter the Page Info UI is opened.
239 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED); 238 RecordPageInfoAction(PAGE_INFO_OPENED);
240 } 239 }
241 240
242 WebsiteSettings::~WebsiteSettings() {} 241 PageInfo::~PageInfo() {}
243 242
244 void WebsiteSettings::RecordWebsiteSettingsAction( 243 void PageInfo::RecordPageInfoAction(PageInfoAction action) {
245 WebsiteSettingsAction action) { 244 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action, PAGE_INFO_COUNT);
246 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action,
247 WEBSITE_SETTINGS_COUNT);
248 245
249 std::string histogram_name; 246 std::string histogram_name;
250 247
251 if (site_url_.SchemeIsCryptographic()) { 248 if (site_url_.SchemeIsCryptographic()) {
252 if (security_level_ == security_state::SECURE || 249 if (security_level_ == security_state::SECURE ||
253 security_level_ == security_state::EV_SECURE) { 250 security_level_ == security_state::EV_SECURE) {
254 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid", 251 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
255 action, WEBSITE_SETTINGS_COUNT); 252 action, PAGE_INFO_COUNT);
256 } else if (security_level_ == security_state::NONE) { 253 } else if (security_level_ == security_state::NONE) {
257 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded", 254 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Downgraded",
258 action, WEBSITE_SETTINGS_COUNT); 255 action, PAGE_INFO_COUNT);
259 } else if (security_level_ == security_state::DANGEROUS) { 256 } else if (security_level_ == security_state::DANGEROUS) {
260 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous", 257 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Dangerous",
261 action, WEBSITE_SETTINGS_COUNT); 258 action, PAGE_INFO_COUNT);
262 } 259 }
263 return; 260 return;
264 } 261 }
265 262
266 if (security_level_ == security_state::HTTP_SHOW_WARNING) { 263 if (security_level_ == security_state::HTTP_SHOW_WARNING) {
267 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning", 264 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Warning",
268 action, WEBSITE_SETTINGS_COUNT); 265 action, PAGE_INFO_COUNT);
269 } else if (security_level_ == security_state::DANGEROUS) { 266 } else if (security_level_ == security_state::DANGEROUS) {
270 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous", 267 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Dangerous",
271 action, WEBSITE_SETTINGS_COUNT); 268 action, PAGE_INFO_COUNT);
272 } else { 269 } else {
273 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral", 270 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpUrl.Neutral",
274 action, WEBSITE_SETTINGS_COUNT); 271 action, PAGE_INFO_COUNT);
275 } 272 }
276 } 273 }
277 274
278 void WebsiteSettings::OnSitePermissionChanged(ContentSettingsType type, 275 void PageInfo::OnSitePermissionChanged(ContentSettingsType type,
279 ContentSetting setting) { 276 ContentSetting setting) {
280 // Count how often a permission for a specific content type is changed using 277 // Count how often a permission for a specific content type is changed using
281 // the Website Settings UI. 278 // the Page Info UI.
282 size_t num_values; 279 size_t num_values;
283 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values); 280 int histogram_value = ContentSettingTypeToHistogramValue(type, &num_values);
284 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged", 281 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.OriginInfo.PermissionChanged",
285 histogram_value, num_values); 282 histogram_value, num_values);
286 283
287 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) { 284 if (setting == ContentSetting::CONTENT_SETTING_ALLOW) {
288 UMA_HISTOGRAM_ENUMERATION( 285 UMA_HISTOGRAM_ENUMERATION(
289 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value, 286 "WebsiteSettings.OriginInfo.PermissionChanged.Allowed", histogram_value,
290 num_values); 287 num_values);
291 288
292 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) { 289 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
293 rappor::SampleDomainAndRegistryFromGURL( 290 rappor::SampleDomainAndRegistryFromGURL(
294 g_browser_process->rappor_service(), 291 g_browser_process->rappor_service(),
295 "ContentSettings.Plugins.AddedAllowException", site_url_); 292 "ContentSettings.Plugins.AddedAllowException", site_url_);
296 } 293 }
297 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) { 294 } else if (setting == ContentSetting::CONTENT_SETTING_BLOCK) {
298 UMA_HISTOGRAM_ENUMERATION( 295 UMA_HISTOGRAM_ENUMERATION(
299 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value, 296 "WebsiteSettings.OriginInfo.PermissionChanged.Blocked", histogram_value,
300 num_values); 297 num_values);
301 } 298 }
302 299
303 // This is technically redundant given the histogram above, but putting the 300 // This is technically redundant given the histogram above, but putting the
304 // total count of permission changes in another histogram makes it easier to 301 // total count of permission changes in another histogram makes it easier to
305 // compare it against other kinds of actions in WebsiteSettings[PopupView]. 302 // compare it against other kinds of actions in PageInfo[PopupView].
306 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_CHANGED_PERMISSION); 303 RecordPageInfoAction(PAGE_INFO_CHANGED_PERMISSION);
307 304
308 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( 305 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
309 this->profile_, this->site_url_, this->site_url_, type, 306 this->profile_, this->site_url_, this->site_url_, type,
310 PermissionSourceUI::OIB); 307 PermissionSourceUI::OIB);
311 308
312 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type, 309 content_settings_->SetNarrowestContentSetting(site_url_, site_url_, type,
313 setting); 310 setting);
314 311
315 show_info_bar_ = true; 312 show_info_bar_ = true;
316 313
317 // Refresh the UI to reflect the new setting. 314 // Refresh the UI to reflect the new setting.
318 PresentSitePermissions(); 315 PresentSitePermissions();
319 } 316 }
320 317
321 void WebsiteSettings::OnSiteChosenObjectDeleted( 318 void PageInfo::OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info,
322 const ChooserUIInfo& ui_info, 319 const base::DictionaryValue& object) {
323 const base::DictionaryValue& object) {
324 // TODO(reillyg): Create metrics for revocations. crbug.com/556845 320 // TODO(reillyg): Create metrics for revocations. crbug.com/556845
325 ChooserContextBase* context = ui_info.get_context(profile_); 321 ChooserContextBase* context = ui_info.get_context(profile_);
326 const GURL origin = site_url_.GetOrigin(); 322 const GURL origin = site_url_.GetOrigin();
327 context->RevokeObjectPermission(origin, origin, object); 323 context->RevokeObjectPermission(origin, origin, object);
328 324
329 show_info_bar_ = true; 325 show_info_bar_ = true;
330 326
331 // Refresh the UI to reflect the changed settings. 327 // Refresh the UI to reflect the changed settings.
332 PresentSitePermissions(); 328 PresentSitePermissions();
333 } 329 }
334 330
335 void WebsiteSettings::OnSiteDataAccessed() { 331 void PageInfo::OnSiteDataAccessed() {
336 PresentSiteData(); 332 PresentSiteData();
337 } 333 }
338 334
339 void WebsiteSettings::OnUIClosing() { 335 void PageInfo::OnUIClosing() {
340 #if defined(OS_ANDROID) 336 #if defined(OS_ANDROID)
341 NOTREACHED(); 337 NOTREACHED();
342 #else 338 #else
343 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) { 339 if (show_info_bar_ && web_contents() && !web_contents()->IsBeingDestroyed()) {
344 InfoBarService* infobar_service = 340 InfoBarService* infobar_service =
345 InfoBarService::FromWebContents(web_contents()); 341 InfoBarService::FromWebContents(web_contents());
346 if (infobar_service) 342 if (infobar_service)
347 WebsiteSettingsInfoBarDelegate::Create(infobar_service); 343 PageInfoInfoBarDelegate::Create(infobar_service);
348 } 344 }
349 345
350 SSLCertificateDecisionsDidRevoke user_decision = 346 SSLCertificateDecisionsDidRevoke user_decision =
351 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED 347 did_revoke_user_ssl_decisions_ ? USER_CERT_DECISIONS_REVOKED
352 : USER_CERT_DECISIONS_NOT_REVOKED; 348 : USER_CERT_DECISIONS_NOT_REVOKED;
353 349
354 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions", 350 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.did_user_revoke_decisions",
355 user_decision, 351 user_decision,
356 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM); 352 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM);
357 #endif 353 #endif
358 } 354 }
359 355
360 void WebsiteSettings::OnRevokeSSLErrorBypassButtonPressed() { 356 void PageInfo::OnRevokeSSLErrorBypassButtonPressed() {
361 DCHECK(chrome_ssl_host_state_delegate_); 357 DCHECK(chrome_ssl_host_state_delegate_);
362 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard( 358 chrome_ssl_host_state_delegate_->RevokeUserAllowExceptionsHard(
363 site_url().host()); 359 site_url().host());
364 did_revoke_user_ssl_decisions_ = true; 360 did_revoke_user_ssl_decisions_ = true;
365 } 361 }
366 362
367 void WebsiteSettings::Init(const GURL& url, 363 void PageInfo::Init(const GURL& url,
368 const security_state::SecurityInfo& security_info) { 364 const security_state::SecurityInfo& security_info) {
369 #if !defined(OS_ANDROID) && !defined(OS_IOS) 365 #if !defined(OS_ANDROID) && !defined(OS_IOS)
370 // On desktop, internal URLs aren't handled by this class. Instead, a 366 // On desktop, internal URLs aren't handled by this class. Instead, a
371 // custom and simpler popup is shown. 367 // custom and simpler popup is shown.
372 DCHECK(!url.SchemeIs(content::kChromeUIScheme) && 368 DCHECK(!url.SchemeIs(content::kChromeUIScheme) &&
373 !url.SchemeIs(content::kChromeDevToolsScheme) && 369 !url.SchemeIs(content::kChromeDevToolsScheme) &&
374 !url.SchemeIs(content::kViewSourceScheme) && 370 !url.SchemeIs(content::kViewSourceScheme) &&
375 !url.SchemeIs(content_settings::kExtensionScheme)); 371 !url.SchemeIs(content_settings::kExtensionScheme));
376 #endif 372 #endif
377 373
378 bool isChromeUINativeScheme = false; 374 bool isChromeUINativeScheme = false;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 // Check if a user decision has been made to allow or deny certificates with 624 // Check if a user decision has been made to allow or deny certificates with
629 // errors on this site. 625 // errors on this site.
630 ChromeSSLHostStateDelegate* delegate = 626 ChromeSSLHostStateDelegate* delegate =
631 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_); 627 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_);
632 DCHECK(delegate); 628 DCHECK(delegate);
633 // Only show an SSL decision revoke button if the user has chosen to bypass 629 // Only show an SSL decision revoke button if the user has chosen to bypass
634 // SSL host errors for this host in the past. 630 // SSL host errors for this host in the past.
635 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()); 631 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host());
636 } 632 }
637 633
638 void WebsiteSettings::PresentSitePermissions() { 634 void PageInfo::PresentSitePermissions() {
639 PermissionInfoList permission_info_list; 635 PermissionInfoList permission_info_list;
640 ChosenObjectInfoList chosen_object_info_list; 636 ChosenObjectInfoList chosen_object_info_list;
641 637
642 WebsiteSettingsUI::PermissionInfo permission_info; 638 PageInfoUI::PermissionInfo permission_info;
643 for (size_t i = 0; i < arraysize(kPermissionType); ++i) { 639 for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
644 permission_info.type = kPermissionType[i]; 640 permission_info.type = kPermissionType[i];
645 641
646 if (!ShouldShowPermission(permission_info.type)) 642 if (!ShouldShowPermission(permission_info.type))
647 continue; 643 continue;
648 644
649 content_settings::SettingInfo info; 645 content_settings::SettingInfo info;
650 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting( 646 std::unique_ptr<base::Value> value = content_settings_->GetWebsiteSetting(
651 site_url_, site_url_, permission_info.type, std::string(), &info); 647 site_url_, site_url_, permission_info.type, std::string(), &info);
652 DCHECK(value.get()); 648 DCHECK(value.get());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 690
695 permission_info_list.push_back(permission_info); 691 permission_info_list.push_back(permission_info);
696 } 692 }
697 693
698 for (const ChooserUIInfo& ui_info : kChooserUIInfo) { 694 for (const ChooserUIInfo& ui_info : kChooserUIInfo) {
699 ChooserContextBase* context = ui_info.get_context(profile_); 695 ChooserContextBase* context = ui_info.get_context(profile_);
700 const GURL origin = site_url_.GetOrigin(); 696 const GURL origin = site_url_.GetOrigin();
701 auto chosen_objects = context->GetGrantedObjects(origin, origin); 697 auto chosen_objects = context->GetGrantedObjects(origin, origin);
702 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) { 698 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) {
703 chosen_object_info_list.push_back( 699 chosen_object_info_list.push_back(
704 base::MakeUnique<WebsiteSettingsUI::ChosenObjectInfo>( 700 base::MakeUnique<PageInfoUI::ChosenObjectInfo>(ui_info,
705 ui_info, std::move(object))); 701 std::move(object)));
706 } 702 }
707 } 703 }
708 704
709 ui_->SetPermissionInfo(permission_info_list, 705 ui_->SetPermissionInfo(permission_info_list,
710 std::move(chosen_object_info_list)); 706 std::move(chosen_object_info_list));
711 } 707 }
712 708
713 void WebsiteSettings::PresentSiteData() { 709 void PageInfo::PresentSiteData() {
714 CookieInfoList cookie_info_list; 710 CookieInfoList cookie_info_list;
715 const LocalSharedObjectsContainer& allowed_objects = 711 const LocalSharedObjectsContainer& allowed_objects =
716 tab_specific_content_settings()->allowed_local_shared_objects(); 712 tab_specific_content_settings()->allowed_local_shared_objects();
717 const LocalSharedObjectsContainer& blocked_objects = 713 const LocalSharedObjectsContainer& blocked_objects =
718 tab_specific_content_settings()->blocked_local_shared_objects(); 714 tab_specific_content_settings()->blocked_local_shared_objects();
719 715
720 // Add first party cookie and site data counts. 716 // Add first party cookie and site data counts.
721 WebsiteSettingsUI::CookieInfo cookie_info; 717 PageInfoUI::CookieInfo cookie_info;
722 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_); 718 cookie_info.allowed = allowed_objects.GetObjectCountForDomain(site_url_);
723 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_); 719 cookie_info.blocked = blocked_objects.GetObjectCountForDomain(site_url_);
724 cookie_info.is_first_party = true; 720 cookie_info.is_first_party = true;
725 cookie_info_list.push_back(cookie_info); 721 cookie_info_list.push_back(cookie_info);
726 722
727 // Add third party cookie counts. 723 // Add third party cookie counts.
728 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed; 724 cookie_info.allowed = allowed_objects.GetObjectCount() - cookie_info.allowed;
729 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked; 725 cookie_info.blocked = blocked_objects.GetObjectCount() - cookie_info.blocked;
730 cookie_info.is_first_party = false; 726 cookie_info.is_first_party = false;
731 cookie_info_list.push_back(cookie_info); 727 cookie_info_list.push_back(cookie_info);
732 728
733 ui_->SetCookieInfo(cookie_info_list); 729 ui_->SetCookieInfo(cookie_info_list);
734 } 730 }
735 731
736 void WebsiteSettings::PresentSiteIdentity() { 732 void PageInfo::PresentSiteIdentity() {
737 // After initialization the status about the site's connection and its 733 // After initialization the status about the site's connection and its
738 // identity must be available. 734 // identity must be available.
739 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); 735 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
740 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); 736 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
741 WebsiteSettingsUI::IdentityInfo info; 737 PageInfoUI::IdentityInfo info;
742 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) 738 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
743 info.site_identity = UTF16ToUTF8(organization_name()); 739 info.site_identity = UTF16ToUTF8(organization_name());
744 else 740 else
745 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); 741 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
746 742
747 info.connection_status = site_connection_status_; 743 info.connection_status = site_connection_status_;
748 info.connection_status_description = UTF16ToUTF8(site_connection_details_); 744 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
749 info.identity_status = site_identity_status_; 745 info.identity_status = site_identity_status_;
750 info.identity_status_description = UTF16ToUTF8(site_identity_details_); 746 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
751 info.certificate = certificate_; 747 info.certificate = certificate_;
752 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; 748 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
753 ui_->SetIdentityInfo(info); 749 ui_->SetIdentityInfo(info);
754 } 750 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/page_info/page_info.h ('k') | chrome/browser/ui/page_info/page_info_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698