Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/website_settings/website_settings.h" | 5 #include "chrome/browser/ui/website_settings/website_settings.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/feature_list.h" | |
| 14 #include "base/i18n/time_formatting.h" | 15 #include "base/i18n/time_formatting.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 17 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
| 18 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h " | 77 #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h " |
| 77 #endif | 78 #endif |
| 78 | 79 |
| 79 using base::ASCIIToUTF16; | 80 using base::ASCIIToUTF16; |
| 80 using base::UTF8ToUTF16; | 81 using base::UTF8ToUTF16; |
| 81 using base::UTF16ToUTF8; | 82 using base::UTF16ToUTF8; |
| 82 using content::BrowserThread; | 83 using content::BrowserThread; |
| 83 | 84 |
| 84 namespace { | 85 namespace { |
| 85 | 86 |
| 87 // TODO(crbug.com/698469): Remove kPageInfoAlwaysShowAllPermissions | |
| 88 const base::Feature kPageInfoAlwaysShowAllPermissions{ | |
| 89 "PageInfoAlwaysShowAllPermissions", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 90 | |
| 86 // Events for UMA. Do not reorder or change! | 91 // Events for UMA. Do not reorder or change! |
| 87 enum SSLCertificateDecisionsDidRevoke { | 92 enum SSLCertificateDecisionsDidRevoke { |
| 88 USER_CERT_DECISIONS_NOT_REVOKED = 0, | 93 USER_CERT_DECISIONS_NOT_REVOKED = 0, |
| 89 USER_CERT_DECISIONS_REVOKED, | 94 USER_CERT_DECISIONS_REVOKED, |
| 90 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM | 95 END_OF_SSL_CERTIFICATE_DECISIONS_DID_REVOKE_ENUM |
| 91 }; | 96 }; |
| 92 | 97 |
| 93 // The list of content settings types to display on the Website Settings UI. THE | 98 // The list of content settings types to display on the Website Settings UI. THE |
| 94 // ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email | 99 // ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, email |
| 95 // security-dev@chromium.org. | 100 // security-dev@chromium.org. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 202 |
| 198 // The list of chooser types that need to display entries in the Website | 203 // 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, | 204 // Settings UI. THE ORDER OF THESE ITEMS IS IMPORTANT. To propose changing it, |
| 200 // email security-dev@chromium.org. | 205 // email security-dev@chromium.org. |
| 201 WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = { | 206 WebsiteSettings::ChooserUIInfo kChooserUIInfo[] = { |
| 202 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, | 207 {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext, |
| 203 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL, | 208 IDR_BLOCKED_USB, IDR_ALLOWED_USB, IDS_WEBSITE_SETTINGS_USB_DEVICE_LABEL, |
| 204 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"}, | 209 IDS_WEBSITE_SETTINGS_DELETE_USB_DEVICE, "name"}, |
| 205 }; | 210 }; |
| 206 | 211 |
| 212 // Show a permission unless the following conditions hold: | |
| 213 // - Its current value is "Ask" (or the the value representing the default). | |
|
raymes
2017/03/05 23:47:11
nit: I don't think the parentheses here make this
elawrence
2017/03/06 19:28:02
Also a repeated word: "the the"
lgarron
2017/03/09 02:41:24
Updated.
| |
| 214 // - Its built-in default value is "Ask". | |
| 215 bool ShouldShowPermission(WebsiteSettingsUI::PermissionInfo permission_info) { | |
| 216 if (base::FeatureList::IsEnabled(kPageInfoAlwaysShowAllPermissions)) { | |
|
raymes
2017/03/05 23:47:11
nit: other single-line if-statements in this file
lgarron
2017/03/09 02:41:24
Fine, but: https://bugs.chromium.org/p/chromium/is
raymes
2017/03/09 03:25:19
I agree, I don't feel strongly which way, it's jus
| |
| 217 return true; | |
| 218 } | |
| 219 | |
| 220 if (permission_info.default_setting != CONTENT_SETTING_ASK) { | |
|
raymes
2017/03/05 23:47:11
Should this be comparing to the user-specified def
lgarron
2017/03/09 02:41:24
Chrome-specified.
I thought that was what was hap
raymes
2017/03/09 03:25:19
To be clear by Chrome-specified default I mean the
| |
| 221 return true; | |
| 222 } | |
| 223 | |
| 224 switch (permission_info.setting) { | |
| 225 case CONTENT_SETTING_DEFAULT: | |
| 226 case CONTENT_SETTING_ASK: | |
| 227 return false; | |
| 228 default: | |
| 229 return true; | |
| 230 } | |
|
raymes
2017/03/05 23:47:11
Do you think we really want to hide settings that
lgarron
2017/03/09 02:41:24
Because of line 220, we always show permissions wh
raymes
2017/03/09 03:25:19
Yeah I guess I'm thinking in theory if the value w
| |
| 231 } | |
| 232 | |
| 207 } // namespace | 233 } // namespace |
| 208 | 234 |
| 209 WebsiteSettings::WebsiteSettings( | 235 WebsiteSettings::WebsiteSettings( |
| 210 WebsiteSettingsUI* ui, | 236 WebsiteSettingsUI* ui, |
| 211 Profile* profile, | 237 Profile* profile, |
| 212 TabSpecificContentSettings* tab_specific_content_settings, | 238 TabSpecificContentSettings* tab_specific_content_settings, |
| 213 content::WebContents* web_contents, | 239 content::WebContents* web_contents, |
| 214 const GURL& url, | 240 const GURL& url, |
| 215 const security_state::SecurityInfo& security_info) | 241 const security_state::SecurityInfo& security_info) |
| 216 : TabSpecificContentSettings::SiteDataObserver( | 242 : TabSpecificContentSettings::SiteDataObserver( |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 if (info.primary_pattern == ContentSettingsPattern::Wildcard() && | 693 if (info.primary_pattern == ContentSettingsPattern::Wildcard() && |
| 668 info.secondary_pattern == ContentSettingsPattern::Wildcard()) { | 694 info.secondary_pattern == ContentSettingsPattern::Wildcard()) { |
| 669 permission_info.default_setting = permission_info.setting; | 695 permission_info.default_setting = permission_info.setting; |
| 670 permission_info.setting = CONTENT_SETTING_DEFAULT; | 696 permission_info.setting = CONTENT_SETTING_DEFAULT; |
| 671 } else { | 697 } else { |
| 672 permission_info.default_setting = | 698 permission_info.default_setting = |
| 673 content_settings_->GetDefaultContentSetting(permission_info.type, | 699 content_settings_->GetDefaultContentSetting(permission_info.type, |
| 674 NULL); | 700 NULL); |
| 675 } | 701 } |
| 676 | 702 |
| 677 permission_info_list.push_back(permission_info); | 703 if (ShouldShowPermission(permission_info)) { |
| 704 permission_info_list.push_back(permission_info); | |
| 705 } | |
| 678 } | 706 } |
| 679 | 707 |
| 680 for (const ChooserUIInfo& ui_info : kChooserUIInfo) { | 708 for (const ChooserUIInfo& ui_info : kChooserUIInfo) { |
| 681 ChooserContextBase* context = ui_info.get_context(profile_); | 709 ChooserContextBase* context = ui_info.get_context(profile_); |
| 682 const GURL origin = site_url_.GetOrigin(); | 710 const GURL origin = site_url_.GetOrigin(); |
| 683 auto chosen_objects = context->GetGrantedObjects(origin, origin); | 711 auto chosen_objects = context->GetGrantedObjects(origin, origin); |
| 684 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) { | 712 for (std::unique_ptr<base::DictionaryValue>& object : chosen_objects) { |
| 685 chosen_object_info_list.push_back( | 713 chosen_object_info_list.push_back( |
| 686 base::MakeUnique<WebsiteSettingsUI::ChosenObjectInfo>( | 714 base::MakeUnique<WebsiteSettingsUI::ChosenObjectInfo>( |
| 687 ui_info, std::move(object))); | 715 ui_info, std::move(object))); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 info.connection_status = site_connection_status_; | 757 info.connection_status = site_connection_status_; |
| 730 info.connection_status_description = | 758 info.connection_status_description = |
| 731 UTF16ToUTF8(site_connection_details_); | 759 UTF16ToUTF8(site_connection_details_); |
| 732 info.identity_status = site_identity_status_; | 760 info.identity_status = site_identity_status_; |
| 733 info.identity_status_description = | 761 info.identity_status_description = |
| 734 UTF16ToUTF8(site_identity_details_); | 762 UTF16ToUTF8(site_identity_details_); |
| 735 info.certificate = certificate_; | 763 info.certificate = certificate_; |
| 736 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; | 764 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
| 737 ui_->SetIdentityInfo(info); | 765 ui_->SetIdentityInfo(info); |
| 738 } | 766 } |
| OLD | NEW |