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

Side by Side Diff: chrome/browser/ui/website_settings/website_settings_ui.cc

Issue 2262223002: Material Page Info (all desktop): Introduce new strings and styling info for the security section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explicitly mention that the colors are fixed due to a light background, and rename semantically. Created 4 years, 3 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/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/color_palette.h"
15 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
16 17
17 namespace { 18 namespace {
18 19
19 const int kInvalidResourceID = -1; 20 const int kInvalidResourceID = -1;
20 21
22 // Dummy value.
23 const SkColor COLOR_UNSTYLED = gfx::kPlaceholderColor;
24
25 // Chrome Material colors for security summary. We use fixed colors, since
26 // the summary is always shown on a white/light background.
27 const SkColor COLOR_SECURE = gfx::kGoogleGreen700;
28 const SkColor COLOR_INSECURE = gfx::kGoogleRed700;
29
21 // The resource IDs for the strings that are displayed on the permissions 30 // The resource IDs for the strings that are displayed on the permissions
22 // button if the permission setting is managed by policy. 31 // button if the permission setting is managed by policy.
23 const int kPermissionButtonTextIDPolicyManaged[] = { 32 const int kPermissionButtonTextIDPolicyManaged[] = {
24 kInvalidResourceID, 33 kInvalidResourceID,
25 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_ALLOWED_BY_POLICY, 34 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_ALLOWED_BY_POLICY,
26 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_BLOCKED_BY_POLICY, 35 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_BLOCKED_BY_POLICY,
27 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_ASK_BY_POLICY, 36 IDS_WEBSITE_SETTINGS_BUTTON_TEXT_ASK_BY_POLICY,
28 kInvalidResourceID, 37 kInvalidResourceID,
29 kInvalidResourceID}; 38 kInvalidResourceID};
30 static_assert(arraysize(kPermissionButtonTextIDPolicyManaged) == 39 static_assert(arraysize(kPermissionButtonTextIDPolicyManaged) ==
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 IDR_ALLOWED_DOWNLOADS}, 118 IDR_ALLOWED_DOWNLOADS},
110 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_WEBSITE_SETTINGS_TYPE_MIDI_SYSEX, 119 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_WEBSITE_SETTINGS_TYPE_MIDI_SYSEX,
111 IDR_BLOCKED_MIDI_SYSEX, IDR_ALLOWED_MIDI_SYSEX}, 120 IDR_BLOCKED_MIDI_SYSEX, IDR_ALLOWED_MIDI_SYSEX},
112 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_WEBSITE_SETTINGS_TYPE_KEYGEN, 121 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_WEBSITE_SETTINGS_TYPE_KEYGEN,
113 IDR_BLOCKED_KEYGEN, IDR_ALLOWED_KEYGEN}, 122 IDR_BLOCKED_KEYGEN, IDR_ALLOWED_KEYGEN},
114 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, 123 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
115 IDS_WEBSITE_SETTINGS_TYPE_BACKGROUND_SYNC, IDR_BLOCKED_BACKGROUND_SYNC, 124 IDS_WEBSITE_SETTINGS_TYPE_BACKGROUND_SYNC, IDR_BLOCKED_BACKGROUND_SYNC,
116 IDR_ALLOWED_BACKGROUND_SYNC}, 125 IDR_ALLOWED_BACKGROUND_SYNC},
117 }; 126 };
118 127
128 std::unique_ptr<WebsiteSettingsUI::SecurityDescription>
129 CreateSecurityDescription(int summary_id,
130 WebsiteSettingsUI::SecuritySummaryStyle summary_style,
131 SkColor summary_color,
132 int details_id) {
133 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description(
134 new WebsiteSettingsUI::SecurityDescription());
135 security_description->summary = l10n_util::GetStringUTF16(summary_id);
136 security_description->summary_style = summary_style;
137 security_description->summary_color = summary_color;
138 security_description->details = l10n_util::GetStringUTF16(details_id);
139 return security_description;
140 }
119 } // namespace 141 } // namespace
120 142
121 WebsiteSettingsUI::CookieInfo::CookieInfo() 143 WebsiteSettingsUI::CookieInfo::CookieInfo()
122 : allowed(-1), blocked(-1) { 144 : allowed(-1), blocked(-1) {
123 } 145 }
124 146
125 WebsiteSettingsUI::PermissionInfo::PermissionInfo() 147 WebsiteSettingsUI::PermissionInfo::PermissionInfo()
126 : type(CONTENT_SETTINGS_TYPE_DEFAULT), 148 : type(CONTENT_SETTINGS_TYPE_DEFAULT),
127 setting(CONTENT_SETTING_DEFAULT), 149 setting(CONTENT_SETTING_DEFAULT),
128 default_setting(CONTENT_SETTING_DEFAULT), 150 default_setting(CONTENT_SETTING_DEFAULT),
129 source(content_settings::SETTING_SOURCE_NONE), 151 source(content_settings::SETTING_SOURCE_NONE),
130 is_incognito(false) {} 152 is_incognito(false) {}
131 153
132 WebsiteSettingsUI::ChosenObjectInfo::ChosenObjectInfo( 154 WebsiteSettingsUI::ChosenObjectInfo::ChosenObjectInfo(
133 const WebsiteSettings::ChooserUIInfo& ui_info, 155 const WebsiteSettings::ChooserUIInfo& ui_info,
134 std::unique_ptr<base::DictionaryValue> object) 156 std::unique_ptr<base::DictionaryValue> object)
135 : ui_info(ui_info), object(std::move(object)) {} 157 : ui_info(ui_info), object(std::move(object)) {}
136 158
137 WebsiteSettingsUI::ChosenObjectInfo::~ChosenObjectInfo() {} 159 WebsiteSettingsUI::ChosenObjectInfo::~ChosenObjectInfo() {}
138 160
139 WebsiteSettingsUI::IdentityInfo::IdentityInfo() 161 WebsiteSettingsUI::IdentityInfo::IdentityInfo()
140 : identity_status(WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN), 162 : identity_status(WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN),
141 cert_id(0), 163 cert_id(0),
142 connection_status(WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN), 164 connection_status(WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN),
143 show_ssl_decision_revoke_button(false) { 165 show_ssl_decision_revoke_button(false) {
144 } 166 }
145 167
146 WebsiteSettingsUI::IdentityInfo::~IdentityInfo() {} 168 WebsiteSettingsUI::IdentityInfo::~IdentityInfo() {}
147 169
148 base::string16 WebsiteSettingsUI::IdentityInfo::GetSecuritySummary() const { 170 std::unique_ptr<WebsiteSettingsUI::SecurityDescription>
171 WebsiteSettingsUI::IdentityInfo::GetSecurityDescription() const {
172 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description(
173 new WebsiteSettingsUI::SecurityDescription());
174
149 switch (identity_status) { 175 switch (identity_status) {
176 case WebsiteSettings::SITE_IDENTITY_STATUS_INTERNAL_PAGE:
177 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_INTERNAL_PAGE,
178 STYLE_UNSTYLED, COLOR_UNSTYLED,
179 IDS_WEBSITE_SETTINGS_INTERNAL_PAGE);
150 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: 180 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT:
151 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: 181 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT:
152 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN: 182 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN:
183 case WebsiteSettings::SITE_IDENTITY_STATUS_CT_ERROR:
184 case WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT:
153 switch (connection_status) { 185 switch (connection_status) {
154 case WebsiteSettings:: 186 case WebsiteSettings::
187 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE:
188 return CreateSecurityDescription(
189 IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY, STYLE_COLOR,
190 COLOR_INSECURE, IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS);
191 case WebsiteSettings::
155 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE: 192 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE:
156 return l10n_util::GetStringUTF16( 193 return CreateSecurityDescription(
157 IDS_WEBSITE_SETTINGS_INSECURE_PASSIVE_CONTENT); 194 IDS_WEBSITE_SETTINGS_MIXED_CONTENT_SUMMARY, STYLE_COLOR,
158 case WebsiteSettings:: 195 COLOR_INSECURE, 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: 196 default:
163 return l10n_util::GetStringUTF16( 197 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_SECURE_SUMMARY,
164 IDS_WEBSITE_SETTINGS_SECURE_TRANSPORT); 198 STYLE_COLOR, COLOR_SECURE,
199 IDS_WEBSITE_SETTINGS_SECURE_DETAILS);
165 } 200 }
166 case WebsiteSettings:: 201 case WebsiteSettings::
167 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR: 202 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR:
168 case WebsiteSettings:: 203 case WebsiteSettings::
169 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR: 204 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: 205 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: 206 case WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT:
181 default: 207 default:
182 return l10n_util::GetStringUTF16( 208 return CreateSecurityDescription(IDS_WEBSITE_SETTINGS_NOT_SECURE_SUMMARY,
183 IDS_WEBSITE_SETTINGS_NON_SECURE_TRANSPORT); 209 STYLE_COLOR, COLOR_INSECURE,
210 IDS_WEBSITE_SETTINGS_NOT_SECURE_DETAILS);
184 } 211 }
185 } 212 }
186 213
214 base::string16 WebsiteSettingsUI::IdentityInfo::GetSecuritySummary() const {
215 std::unique_ptr<WebsiteSettingsUI::SecurityDescription> security_description =
216 GetSecurityDescription();
217 return security_description->summary;
218 }
219
187 WebsiteSettingsUI::~WebsiteSettingsUI() { 220 WebsiteSettingsUI::~WebsiteSettingsUI() {
188 } 221 }
189 222
190 // static 223 // static
191 base::string16 WebsiteSettingsUI::PermissionTypeToUIString( 224 base::string16 WebsiteSettingsUI::PermissionTypeToUIString(
192 ContentSettingsType type) { 225 ContentSettingsType type) {
193 for (const PermissionsUIInfo& info : kPermissionsUIInfo) { 226 for (const PermissionsUIInfo& info : kPermissionsUIInfo) {
194 if (info.type == type) 227 if (info.type == type)
195 return l10n_util::GetStringUTF16(info.string_id); 228 return l10n_util::GetStringUTF16(info.string_id);
196 } 229 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 398 }
366 return resource_id; 399 return resource_id;
367 } 400 }
368 401
369 // static 402 // static
370 const gfx::Image& WebsiteSettingsUI::GetConnectionIcon( 403 const gfx::Image& WebsiteSettingsUI::GetConnectionIcon(
371 WebsiteSettings::SiteConnectionStatus status) { 404 WebsiteSettings::SiteConnectionStatus status) {
372 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 405 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
373 return rb.GetNativeImageNamed(GetConnectionIconID(status)); 406 return rb.GetNativeImageNamed(GetConnectionIconID(status));
374 } 407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698