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_ui.h" | 5 #include "chrome/browser/ui/website_settings/website_settings_ui.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/grit/chromium_strings.h" | 8 #include "chrome/grit/chromium_strings.h" |
| 9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "components/content_settings/core/browser/plugins_field_trial.h" | 10 #include "components/content_settings/core/browser/plugins_field_trial.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 IDR_ALLOWED_DOWNLOADS}, | 111 IDR_ALLOWED_DOWNLOADS}, |
| 112 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_WEBSITE_SETTINGS_TYPE_MIDI_SYSEX, | 112 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_WEBSITE_SETTINGS_TYPE_MIDI_SYSEX, |
| 113 IDR_BLOCKED_MIDI_SYSEX, IDR_ALLOWED_MIDI_SYSEX}, | 113 IDR_BLOCKED_MIDI_SYSEX, IDR_ALLOWED_MIDI_SYSEX}, |
| 114 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_WEBSITE_SETTINGS_TYPE_KEYGEN, | 114 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_WEBSITE_SETTINGS_TYPE_KEYGEN, |
| 115 IDR_BLOCKED_KEYGEN, IDR_ALLOWED_KEYGEN}, | 115 IDR_BLOCKED_KEYGEN, IDR_ALLOWED_KEYGEN}, |
| 116 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, | 116 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, |
| 117 IDS_WEBSITE_SETTINGS_TYPE_BACKGROUND_SYNC, IDR_BLOCKED_BACKGROUND_SYNC, | 117 IDS_WEBSITE_SETTINGS_TYPE_BACKGROUND_SYNC, IDR_BLOCKED_BACKGROUND_SYNC, |
| 118 IDR_ALLOWED_BACKGROUND_SYNC}, | 118 IDR_ALLOWED_BACKGROUND_SYNC}, |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> | |
| 122 CreateSecurityDescription(int summary_id, | |
| 123 WebsiteSettingsUI::SecuritySummaryStyle summary_style, | |
| 124 int details_id) { | |
| 125 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description( | |
| 126 new WebsiteSettingsUI::SecurityDescription()); | |
| 127 security_description->summary = l10n_util::GetStringUTF16(summary_id); | |
| 128 security_description->summary_style = summary_style; | |
|
felt
2016/06/30 05:39:24
I'm a little confused, where is the summary_style
lgarron
2016/07/08 17:47:08
In the OS-specific code (website_settings_bubble_c
| |
| 129 security_description->details = l10n_util::GetStringUTF16(details_id); | |
| 130 return security_description; | |
| 131 } | |
| 121 } // namespace | 132 } // namespace |
| 122 | 133 |
| 123 WebsiteSettingsUI::CookieInfo::CookieInfo() | 134 WebsiteSettingsUI::CookieInfo::CookieInfo() |
| 124 : allowed(-1), blocked(-1) { | 135 : allowed(-1), blocked(-1) { |
| 125 } | 136 } |
| 126 | 137 |
| 127 WebsiteSettingsUI::PermissionInfo::PermissionInfo() | 138 WebsiteSettingsUI::PermissionInfo::PermissionInfo() |
| 128 : type(CONTENT_SETTINGS_TYPE_DEFAULT), | 139 : type(CONTENT_SETTINGS_TYPE_DEFAULT), |
| 129 setting(CONTENT_SETTING_DEFAULT), | 140 setting(CONTENT_SETTING_DEFAULT), |
| 130 default_setting(CONTENT_SETTING_DEFAULT), | 141 default_setting(CONTENT_SETTING_DEFAULT), |
| 131 source(content_settings::SETTING_SOURCE_NONE), | 142 source(content_settings::SETTING_SOURCE_NONE), |
| 132 is_incognito(false) {} | 143 is_incognito(false) {} |
| 133 | 144 |
| 134 WebsiteSettingsUI::ChosenObjectInfo::ChosenObjectInfo( | 145 WebsiteSettingsUI::ChosenObjectInfo::ChosenObjectInfo( |
| 135 const WebsiteSettings::ChooserUIInfo& ui_info, | 146 const WebsiteSettings::ChooserUIInfo& ui_info, |
| 136 std::unique_ptr<base::DictionaryValue> object) | 147 std::unique_ptr<base::DictionaryValue> object) |
| 137 : ui_info(ui_info), object(std::move(object)) {} | 148 : ui_info(ui_info), object(std::move(object)) {} |
| 138 | 149 |
| 139 WebsiteSettingsUI::ChosenObjectInfo::~ChosenObjectInfo() {} | 150 WebsiteSettingsUI::ChosenObjectInfo::~ChosenObjectInfo() {} |
| 140 | 151 |
| 141 WebsiteSettingsUI::IdentityInfo::IdentityInfo() | 152 WebsiteSettingsUI::IdentityInfo::IdentityInfo() |
| 142 : identity_status(WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN), | 153 : identity_status(WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN), |
| 143 cert_id(0), | 154 cert_id(0), |
| 144 connection_status(WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN), | 155 connection_status(WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN), |
| 145 show_ssl_decision_revoke_button(false) { | 156 show_ssl_decision_revoke_button(false) { |
| 146 } | 157 } |
| 147 | 158 |
| 148 WebsiteSettingsUI::IdentityInfo::~IdentityInfo() {} | 159 WebsiteSettingsUI::IdentityInfo::~IdentityInfo() {} |
| 149 | 160 |
| 150 base::string16 WebsiteSettingsUI::IdentityInfo::GetSecuritySummary() const { | 161 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> |
| 162 WebsiteSettingsUI::IdentityInfo::GetSecurityDescription() const { | |
| 163 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description( | |
| 164 new WebsiteSettingsUI::SecurityDescription()); | |
| 165 | |
| 151 switch (identity_status) { | 166 switch (identity_status) { |
| 152 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: | 167 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: |
| 153 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: | 168 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: |
| 154 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN: | 169 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN: |
| 155 switch (connection_status) { | 170 switch (connection_status) { |
| 156 case WebsiteSettings::SITE_CONNECTION_STATUS_MIXED_CONTENT: | 171 case WebsiteSettings::SITE_CONNECTION_STATUS_MIXED_CONTENT: |
| 157 return l10n_util::GetStringUTF16( | 172 return CreateSecurityDescription( |
| 158 IDS_WEBSITE_SETTINGS_MIXED_PASSIVE_CONTENT); | 173 IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, STYLE_YELLOW, |
| 174 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 159 case WebsiteSettings::SITE_CONNECTION_STATUS_MIXED_SCRIPT: | 175 case WebsiteSettings::SITE_CONNECTION_STATUS_MIXED_SCRIPT: |
| 160 return l10n_util::GetStringUTF16( | 176 return CreateSecurityDescription( |
| 161 IDS_WEBSITE_SETTINGS_MIXED_ACTIVE_CONTENT); | 177 IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, STYLE_RED, |
| 178 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 162 default: | 179 default: |
| 163 return l10n_util::GetStringUTF16( | 180 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_SECURE_SUMMARY, |
| 164 IDS_WEBSITE_SETTINGS_SECURE_TRANSPORT); | 181 STYLE_GREEN, |
| 182 IDS_WEBSITE_SETTINGS_SECURE_DETAILS); | |
| 165 } | 183 } |
| 166 case WebsiteSettings:: | 184 case WebsiteSettings:: |
| 167 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR: | 185 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR: |
| 186 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, | |
| 187 STYLE_YELLOW, | |
| 188 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 168 case WebsiteSettings:: | 189 case WebsiteSettings:: |
| 169 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR: | 190 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR: |
| 170 return l10n_util::GetStringUTF16( | 191 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, |
|
felt
2016/06/30 05:39:24
Since some of these now share strings and styles,
lgarron
2016/07/08 17:47:08
I was planning to collapse these once the strings
| |
| 171 IDS_WEBSITE_DEPRECATED_SIGNATURE_ALGORITHM); | 192 STYLE_RED, |
| 193 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 172 case WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT: | 194 case WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT: |
| 173 return l10n_util::GetStringUTF16(IDS_CERT_POLICY_PROVIDED_CERT_HEADER); | 195 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, |
| 196 STYLE_RED, | |
| 197 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 174 case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN: | 198 case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN: |
| 175 return l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_UNKNOWN_TRANSPORT); | 199 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, |
| 200 STYLE_RED, | |
| 201 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 176 case WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR: | 202 case WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR: |
| 177 return l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_CT_ERROR); | 203 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_SECURE_SUMMARY, |
| 204 STYLE_RED, | |
| 205 IDS_WEBSITE_SETTINGS_SECURE_DETAILS); | |
| 178 case WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE: | 206 case WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE: |
| 179 return l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_INTERNAL_PAGE); | 207 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_INTERNAL_PAGE, |
| 208 STYLE_DEFAULT, | |
| 209 IDS_WEBSITE_SETTINGS_INTERNAL_PAGE); | |
| 180 case WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT: | 210 case WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT: |
| 181 default: | 211 default: |
| 182 return l10n_util::GetStringUTF16( | 212 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, |
| 183 IDS_WEBSITE_SETTINGS_NON_SECURE_TRANSPORT); | 213 STYLE_RED, |
| 214 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 184 } | 215 } |
| 185 } | 216 } |
| 186 | 217 |
| 218 base::string16 WebsiteSettingsUI::IdentityInfo::GetSecuritySummary() const { | |
| 219 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = | |
| 220 GetSecurityDescription(); | |
| 221 return security_description->summary; | |
| 222 } | |
| 223 | |
| 187 WebsiteSettingsUI::~WebsiteSettingsUI() { | 224 WebsiteSettingsUI::~WebsiteSettingsUI() { |
| 188 } | 225 } |
| 189 | 226 |
| 190 // static | 227 // static |
| 191 base::string16 WebsiteSettingsUI::PermissionTypeToUIString( | 228 base::string16 WebsiteSettingsUI::PermissionTypeToUIString( |
| 192 ContentSettingsType type) { | 229 ContentSettingsType type) { |
| 193 for (const PermissionsUIInfo& info : kPermissionsUIInfo) { | 230 for (const PermissionsUIInfo& info : kPermissionsUIInfo) { |
| 194 if (info.type == type) | 231 if (info.type == type) |
| 195 return l10n_util::GetStringUTF16(info.string_id); | 232 return l10n_util::GetStringUTF16(info.string_id); |
| 196 } | 233 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 } | 402 } |
| 366 return resource_id; | 403 return resource_id; |
| 367 } | 404 } |
| 368 | 405 |
| 369 // static | 406 // static |
| 370 const gfx::Image& WebsiteSettingsUI::GetConnectionIcon( | 407 const gfx::Image& WebsiteSettingsUI::GetConnectionIcon( |
| 371 WebsiteSettings::SiteConnectionStatus status) { | 408 WebsiteSettings::SiteConnectionStatus status) { |
| 372 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 409 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 373 return rb.GetNativeImageNamed(GetConnectionIconID(status)); | 410 return rb.GetNativeImageNamed(GetConnectionIconID(status)); |
| 374 } | 411 } |
| OLD | NEW |