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" |
| 11 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
| 12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const int kInvalidResourceID = -1; | 19 const int kInvalidResourceID = -1; |
| 20 | 20 |
| 21 // Dummy value. | |
| 22 const SkColor COLOR_UNSTYLED = SkColorSetRGB(0x00, 0x00, 0x00); | |
|
msw
2016/08/25 03:57:01
The way these colors are set seems wrong; see my c
lgarron
2016/08/25 04:18:24
Also see my comment there. :-)
Anyhow, I have jus
| |
| 23 | |
| 24 // Chrome Material colors for text on light background. | |
| 25 const SkColor COLOR_MATERIAL_GREEN = SkColorSetRGB(0x0B, 0x80, 0x43); | |
| 26 const SkColor COLOR_MATERIAL_RED = SkColorSetRGB(0xC5, 0x39, 0x29); | |
| 27 | |
| 21 // The resource IDs for the strings that are displayed on the permissions | 28 // The resource IDs for the strings that are displayed on the permissions |
| 22 // button if the permission setting is managed by policy. | 29 // button if the permission setting is managed by policy. |
| 23 const int kPermissionButtonTextIDPolicyManaged[] = { | 30 const int kPermissionButtonTextIDPolicyManaged[] = { |
| 24 kInvalidResourceID, | 31 kInvalidResourceID, |
| 25 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_ALLOWED_BY_POLICY, | 32 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_ALLOWED_BY_POLICY, |
| 26 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_BLOCKED_BY_POLICY, | 33 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_BLOCKED_BY_POLICY, |
| 27 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_ASK_BY_POLICY, | 34 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_ASK_BY_POLICY, |
| 28 kInvalidResourceID, | 35 kInvalidResourceID, |
| 29 kInvalidResourceID}; | 36 kInvalidResourceID}; |
| 30 static_assert(arraysize(kPermissionButtonTextIDPolicyManaged) == | 37 static_assert(arraysize(kPermissionButtonTextIDPolicyManaged) == |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 IDR_ALLOWED_DOWNLOADS}, | 116 IDR_ALLOWED_DOWNLOADS}, |
| 110 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_WEBSITE_SETTINGS_TYPE_MIDI_SYSEX, | 117 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_WEBSITE_SETTINGS_TYPE_MIDI_SYSEX, |
| 111 IDR_BLOCKED_MIDI_SYSEX, IDR_ALLOWED_MIDI_SYSEX}, | 118 IDR_BLOCKED_MIDI_SYSEX, IDR_ALLOWED_MIDI_SYSEX}, |
| 112 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_WEBSITE_SETTINGS_TYPE_KEYGEN, | 119 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_WEBSITE_SETTINGS_TYPE_KEYGEN, |
| 113 IDR_BLOCKED_KEYGEN, IDR_ALLOWED_KEYGEN}, | 120 IDR_BLOCKED_KEYGEN, IDR_ALLOWED_KEYGEN}, |
| 114 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, | 121 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, |
| 115 IDS_WEBSITE_SETTINGS_TYPE_BACKGROUND_SYNC, IDR_BLOCKED_BACKGROUND_SYNC, | 122 IDS_WEBSITE_SETTINGS_TYPE_BACKGROUND_SYNC, IDR_BLOCKED_BACKGROUND_SYNC, |
| 116 IDR_ALLOWED_BACKGROUND_SYNC}, | 123 IDR_ALLOWED_BACKGROUND_SYNC}, |
| 117 }; | 124 }; |
| 118 | 125 |
| 126 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> | |
| 127 CreateSecurityDescription(int summary_id, | |
| 128 WebsiteSettingsUI::SecuritySummaryStyle summary_style, | |
| 129 SkColor summary_color, | |
| 130 int details_id) { | |
| 131 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description( | |
| 132 new WebsiteSettingsUI::SecurityDescription()); | |
| 133 security_description->summary = l10n_util::GetStringUTF16(summary_id); | |
| 134 security_description->summary_style = summary_style; | |
| 135 security_description->summary_color = summary_color; | |
| 136 security_description->details = l10n_util::GetStringUTF16(details_id); | |
| 137 return security_description; | |
| 138 } | |
| 119 } // namespace | 139 } // namespace |
| 120 | 140 |
| 121 WebsiteSettingsUI::CookieInfo::CookieInfo() | 141 WebsiteSettingsUI::CookieInfo::CookieInfo() |
| 122 : allowed(-1), blocked(-1) { | 142 : allowed(-1), blocked(-1) { |
| 123 } | 143 } |
| 124 | 144 |
| 125 WebsiteSettingsUI::PermissionInfo::PermissionInfo() | 145 WebsiteSettingsUI::PermissionInfo::PermissionInfo() |
| 126 : type(CONTENT_SETTINGS_TYPE_DEFAULT), | 146 : type(CONTENT_SETTINGS_TYPE_DEFAULT), |
| 127 setting(CONTENT_SETTING_DEFAULT), | 147 setting(CONTENT_SETTING_DEFAULT), |
| 128 default_setting(CONTENT_SETTING_DEFAULT), | 148 default_setting(CONTENT_SETTING_DEFAULT), |
| 129 source(content_settings::SETTING_SOURCE_NONE), | 149 source(content_settings::SETTING_SOURCE_NONE), |
| 130 is_incognito(false) {} | 150 is_incognito(false) {} |
| 131 | 151 |
| 132 WebsiteSettingsUI::ChosenObjectInfo::ChosenObjectInfo( | 152 WebsiteSettingsUI::ChosenObjectInfo::ChosenObjectInfo( |
| 133 const WebsiteSettings::ChooserUIInfo& ui_info, | 153 const WebsiteSettings::ChooserUIInfo& ui_info, |
| 134 std::unique_ptr<base::DictionaryValue> object) | 154 std::unique_ptr<base::DictionaryValue> object) |
| 135 : ui_info(ui_info), object(std::move(object)) {} | 155 : ui_info(ui_info), object(std::move(object)) {} |
| 136 | 156 |
| 137 WebsiteSettingsUI::ChosenObjectInfo::~ChosenObjectInfo() {} | 157 WebsiteSettingsUI::ChosenObjectInfo::~ChosenObjectInfo() {} |
| 138 | 158 |
| 139 WebsiteSettingsUI::IdentityInfo::IdentityInfo() | 159 WebsiteSettingsUI::IdentityInfo::IdentityInfo() |
| 140 : identity_status(WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN), | 160 : identity_status(WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN), |
| 141 cert_id(0), | 161 cert_id(0), |
| 142 connection_status(WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN), | 162 connection_status(WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN), |
| 143 show_ssl_decision_revoke_button(false) { | 163 show_ssl_decision_revoke_button(false) { |
| 144 } | 164 } |
| 145 | 165 |
| 146 WebsiteSettingsUI::IdentityInfo::~IdentityInfo() {} | 166 WebsiteSettingsUI::IdentityInfo::~IdentityInfo() {} |
| 147 | 167 |
| 148 base::string16 WebsiteSettingsUI::IdentityInfo::GetSecuritySummary() const { | 168 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> |
| 169 WebsiteSettingsUI::IdentityInfo::GetSecurityDescription() const { | |
| 170 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description( | |
| 171 new WebsiteSettingsUI::SecurityDescription()); | |
| 172 | |
| 149 switch (identity_status) { | 173 switch (identity_status) { |
| 174 case WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE: | |
| 175 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_INTERNAL_PAGE, | |
| 176 STYLE_UNSTYLED, COLOR_UNSTYLED, | |
| 177 IDS_WEBSITE_SETTINGS_INTERNAL_PAGE); | |
| 150 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: | 178 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: |
| 151 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: | 179 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: |
| 152 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN: | 180 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN: |
| 181 case WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR: | |
| 182 case WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT: | |
| 153 switch (connection_status) { | 183 switch (connection_status) { |
| 154 case WebsiteSettings:: | 184 case WebsiteSettings:: |
| 185 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE: | |
| 186 return CreateSecurityDescription( | |
| 187 IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, STYLE_COLOR, | |
| 188 COLOR_MATERIAL_RED, IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 189 case WebsiteSettings:: | |
| 155 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE: | 190 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE: |
| 156 return l10n_util::GetStringUTF16( | 191 return CreateSecurityDescription( |
| 157 IDS_WEBSITE_SETTINGS_INSECURE_PASSIVE_CONTENT); | 192 IDS_WEBSITE_SETTINGS_MIXED_CONTENT_SUMMARY, STYLE_COLOR, |
| 158 case WebsiteSettings:: | 193 COLOR_MATERIAL_RED, IDS_WEBSITE_SETTINGS_MIXED_CONTENT_DETAILS); |
| 159 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE: | |
| 160 return l10n_util::GetStringUTF16( | |
| 161 IDS_WEBSITE_SETTINGS_INSECURE_ACTIVE_CONTENT); | |
| 162 default: | 194 default: |
| 163 return l10n_util::GetStringUTF16( | 195 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_SECURE_SUMMARY, |
| 164 IDS_WEBSITE_SETTINGS_SECURE_TRANSPORT); | 196 STYLE_COLOR, COLOR_MATERIAL_GREEN, |
| 197 IDS_WEBSITE_SETTINGS_SECURE_DETAILS); | |
| 165 } | 198 } |
| 166 case WebsiteSettings:: | 199 case WebsiteSettings:: |
| 167 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR: | 200 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR: |
| 168 case WebsiteSettings:: | 201 case WebsiteSettings:: |
| 169 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR: | 202 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR: |
| 170 return l10n_util::GetStringUTF16( | |
| 171 IDS_WEBSITE_DEPRECATED_SIGNATURE_ALGORITHM); | |
| 172 case WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT: | |
| 173 return l10n_util::GetStringUTF16(IDS_CERT_POLICY_PROVIDED_CERT_HEADER); | |
| 174 case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN: | 203 case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN: |
| 175 return l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_UNKNOWN_TRANSPORT); | |
| 176 case WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR: | |
| 177 return l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_CT_ERROR); | |
| 178 case WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE: | |
| 179 return l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_INTERNAL_PAGE); | |
| 180 case WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT: | 204 case WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT: |
| 181 default: | 205 default: |
| 182 return l10n_util::GetStringUTF16( | 206 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, |
| 183 IDS_WEBSITE_SETTINGS_NON_SECURE_TRANSPORT); | 207 STYLE_COLOR, COLOR_MATERIAL_RED, |
| 208 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS); | |
| 184 } | 209 } |
| 185 } | 210 } |
| 186 | 211 |
| 212 base::string16 WebsiteSettingsUI::IdentityInfo::GetSecuritySummary() const { | |
| 213 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description = | |
| 214 GetSecurityDescription(); | |
| 215 return security_description->summary; | |
| 216 } | |
| 217 | |
| 187 WebsiteSettingsUI::~WebsiteSettingsUI() { | 218 WebsiteSettingsUI::~WebsiteSettingsUI() { |
| 188 } | 219 } |
| 189 | 220 |
| 190 // static | 221 // static |
| 191 base::string16 WebsiteSettingsUI::PermissionTypeToUIString( | 222 base::string16 WebsiteSettingsUI::PermissionTypeToUIString( |
| 192 ContentSettingsType type) { | 223 ContentSettingsType type) { |
| 193 for (const PermissionsUIInfo& info : kPermissionsUIInfo) { | 224 for (const PermissionsUIInfo& info : kPermissionsUIInfo) { |
| 194 if (info.type == type) | 225 if (info.type == type) |
| 195 return l10n_util::GetStringUTF16(info.string_id); | 226 return l10n_util::GetStringUTF16(info.string_id); |
| 196 } | 227 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 } | 396 } |
| 366 return resource_id; | 397 return resource_id; |
| 367 } | 398 } |
| 368 | 399 |
| 369 // static | 400 // static |
| 370 const gfx::Image& WebsiteSettingsUI::GetConnectionIcon( | 401 const gfx::Image& WebsiteSettingsUI::GetConnectionIcon( |
| 371 WebsiteSettings::SiteConnectionStatus status) { | 402 WebsiteSettings::SiteConnectionStatus status) { |
| 372 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 403 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 373 return rb.GetNativeImageNamed(GetConnectionIconID(status)); | 404 return rb.GetNativeImageNamed(GetConnectionIconID(status)); |
| 374 } | 405 } |
| OLD | NEW |