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

Side by Side Diff: components/supervised_user_error_page/supervised_user_error_page.cc

Issue 2739473006: Update supervised user interstitial pages. (Closed)
Patch Set: fix Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/supervised_user_error_page/supervised_user_error_page.h" 5 #include "components/supervised_user_error_page/supervised_user_error_page.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "components/grit/components_resources.h" 12 #include "components/grit/components_resources.h"
13 #include "components/strings/grit/components_strings.h" 13 #include "components/strings/grit/components_strings.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/base/webui/jstemplate_builder.h" 16 #include "ui/base/webui/jstemplate_builder.h"
17 #include "ui/base/webui/web_ui_util.h" 17 #include "ui/base/webui/web_ui_util.h"
18 18
19 namespace supervised_user_error_page { 19 namespace supervised_user_error_page {
20 20
21 namespace { 21 namespace {
22 22
23 static const int kAvatarSize1x = 45; 23 static const int kAvatarSize1x = 45;
24 static const int kAvatarSize2x = 90; 24 static const int kAvatarSize2x = 90;
25 25
26 #if defined(GOOGLE_CHROME_BUILD)
27 bool ReasonIsAutomatic(FilteringBehaviorReason reason) { 26 bool ReasonIsAutomatic(FilteringBehaviorReason reason) {
28 return reason == ASYNC_CHECKER || reason == BLACKLIST; 27 return reason == ASYNC_CHECKER || reason == BLACKLIST;
29 } 28 }
30 #endif
31 29
32 std::string BuildAvatarImageUrl(const std::string& url, int size) { 30 std::string BuildAvatarImageUrl(const std::string& url, int size) {
33 std::string result = url; 31 std::string result = url;
34 size_t slash = result.rfind('/'); 32 size_t slash = result.rfind('/');
35 if (slash != std::string::npos) 33 if (slash != std::string::npos)
36 result.insert(slash, "/s" + base::IntToString(size)); 34 result.insert(slash, "/s" + base::IntToString(size));
37 return result; 35 return result;
38 } 36 }
39 37
40 } // namespace 38 } // namespace
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 IDS_BLOCK_INTERSTITIAL_HEADER_ACCESS_REQUESTS_DISABLED); 115 IDS_BLOCK_INTERSTITIAL_HEADER_ACCESS_REQUESTS_DISABLED);
118 // If access requests are disabled, there is no block message. 116 // If access requests are disabled, there is no block message.
119 } 117 }
120 strings.SetString("blockPageHeader", block_header); 118 strings.SetString("blockPageHeader", block_header);
121 strings.SetString("blockPageMessage", block_message); 119 strings.SetString("blockPageMessage", block_message);
122 strings.SetString("blockReasonMessage", 120 strings.SetString("blockReasonMessage",
123 l10n_util::GetStringUTF16(GetBlockMessageID( 121 l10n_util::GetStringUTF16(GetBlockMessageID(
124 reason, is_child_account, second_custodian.empty()))); 122 reason, is_child_account, second_custodian.empty())));
125 strings.SetString("blockReasonHeader", l10n_util::GetStringUTF16( 123 strings.SetString("blockReasonHeader", l10n_util::GetStringUTF16(
126 IDS_SUPERVISED_USER_BLOCK_HEADER)); 124 IDS_SUPERVISED_USER_BLOCK_HEADER));
127 bool show_feedback = false; 125 bool show_feedback = ReasonIsAutomatic(reason);
128 #if defined(GOOGLE_CHROME_BUILD) 126 DCHECK(is_child_account || !show_feedback);
129 show_feedback = is_child_account && ReasonIsAutomatic(reason); 127
130 #endif
131 strings.SetBoolean("showFeedbackLink", show_feedback); 128 strings.SetBoolean("showFeedbackLink", show_feedback);
132 strings.SetString("feedbackLink", l10n_util::GetStringUTF16( 129 strings.SetString("feedbackLink", l10n_util::GetStringUTF16(
133 IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK)); 130 IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK));
134 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON)); 131 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON));
135 strings.SetString( 132 strings.SetString(
136 "requestAccessButton", 133 "requestAccessButton",
137 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON)); 134 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON));
138 strings.SetString( 135 strings.SetString(
139 "showDetailsLink", 136 "showDetailsLink",
140 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SHOW_DETAILS)); 137 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SHOW_DETAILS));
(...skipping 26 matching lines...) Expand all
167 std::string html = 164 std::string html =
168 ResourceBundle::GetSharedInstance() 165 ResourceBundle::GetSharedInstance()
169 .GetRawDataResource(IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML) 166 .GetRawDataResource(IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML)
170 .as_string(); 167 .as_string();
171 webui::AppendWebUiCssTextDefaults(&html); 168 webui::AppendWebUiCssTextDefaults(&html);
172 std::string error_html = webui::GetI18nTemplateHtml(html, &strings); 169 std::string error_html = webui::GetI18nTemplateHtml(html, &strings);
173 return error_html; 170 return error_html;
174 } 171 }
175 172
176 } // namespace supervised_user_error_page 173 } // namespace supervised_user_error_page
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698