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

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

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

Powered by Google App Engine
This is Rietveld 408576698