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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_interstitial.cc

Issue 1552333002: Resubmit Supervised user web restrictions content provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Copy of original CL (base for comparison) Created 4 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/supervised_user/supervised_user_interstitial.h" 5 #include "chrome/browser/supervised_user/supervised_user_interstitial.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 SupervisedUserServiceFactory::GetForProfile(profile_); 191 SupervisedUserServiceFactory::GetForProfile(profile_);
192 supervised_user_service->AddObserver(this); 192 supervised_user_service->AddObserver(this);
193 193
194 interstitial_page_ = 194 interstitial_page_ =
195 content::InterstitialPage::Create(web_contents_, true, url_, this); 195 content::InterstitialPage::Create(web_contents_, true, url_, this);
196 interstitial_page_->Show(); 196 interstitial_page_->Show();
197 197
198 return true; 198 return true;
199 } 199 }
200 200
201 std::string SupervisedUserInterstitial::GetHTMLContents() { 201 // static
202 std::string SupervisedUserInterstitial::GetHTMLContents(
203 Profile* profile,
204 SupervisedUserURLFilter::FilteringBehaviorReason reason) {
202 base::DictionaryValue strings; 205 base::DictionaryValue strings;
203 strings.SetString("blockPageTitle", 206 strings.SetString("blockPageTitle",
204 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_TITLE)); 207 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_TITLE));
205 208
206 SupervisedUserService* supervised_user_service = 209 SupervisedUserService* supervised_user_service =
207 SupervisedUserServiceFactory::GetForProfile(profile_); 210 SupervisedUserServiceFactory::GetForProfile(profile);
208 211
209 bool allow_access_requests = supervised_user_service->AccessRequestsEnabled(); 212 bool allow_access_requests = supervised_user_service->AccessRequestsEnabled();
210 strings.SetBoolean("allowAccessRequests", allow_access_requests); 213 strings.SetBoolean("allowAccessRequests", allow_access_requests);
211 214
212 std::string profile_image_url = profile_->GetPrefs()->GetString( 215 std::string profile_image_url = profile->GetPrefs()->GetString(
213 prefs::kSupervisedUserCustodianProfileImageURL); 216 prefs::kSupervisedUserCustodianProfileImageURL);
214 strings.SetString("avatarURL1x", BuildAvatarImageUrl(profile_image_url, 217 strings.SetString("avatarURL1x", BuildAvatarImageUrl(profile_image_url,
215 kAvatarSize1x)); 218 kAvatarSize1x));
216 strings.SetString("avatarURL2x", BuildAvatarImageUrl(profile_image_url, 219 strings.SetString("avatarURL2x", BuildAvatarImageUrl(profile_image_url,
217 kAvatarSize2x)); 220 kAvatarSize2x));
218 221
219 std::string profile_image_url2 = profile_->GetPrefs()->GetString( 222 std::string profile_image_url2 = profile->GetPrefs()->GetString(
220 prefs::kSupervisedUserSecondCustodianProfileImageURL); 223 prefs::kSupervisedUserSecondCustodianProfileImageURL);
221 strings.SetString("secondAvatarURL1x", BuildAvatarImageUrl(profile_image_url2, 224 strings.SetString("secondAvatarURL1x", BuildAvatarImageUrl(profile_image_url2,
222 kAvatarSize1x)); 225 kAvatarSize1x));
223 strings.SetString("secondAvatarURL2x", BuildAvatarImageUrl(profile_image_url2, 226 strings.SetString("secondAvatarURL2x", BuildAvatarImageUrl(profile_image_url2,
224 kAvatarSize2x)); 227 kAvatarSize2x));
225 228
226 bool is_child_account = profile_->IsChild(); 229 bool is_child_account = profile->IsChild();
227 230
228 base::string16 custodian = 231 base::string16 custodian =
229 base::UTF8ToUTF16(supervised_user_service->GetCustodianName()); 232 base::UTF8ToUTF16(supervised_user_service->GetCustodianName());
230 base::string16 second_custodian = 233 base::string16 second_custodian =
231 base::UTF8ToUTF16(supervised_user_service->GetSecondCustodianName()); 234 base::UTF8ToUTF16(supervised_user_service->GetSecondCustodianName());
232 235
233 base::string16 block_message; 236 base::string16 block_message;
234 if (allow_access_requests) { 237 if (allow_access_requests) {
235 if (is_child_account) { 238 if (is_child_account) {
236 block_message = l10n_util::GetStringUTF16( 239 block_message = l10n_util::GetStringUTF16(
237 second_custodian.empty() 240 second_custodian.empty()
238 ? IDS_CHILD_BLOCK_INTERSTITIAL_MESSAGE_SINGLE_PARENT 241 ? IDS_CHILD_BLOCK_INTERSTITIAL_MESSAGE_SINGLE_PARENT
239 : IDS_CHILD_BLOCK_INTERSTITIAL_MESSAGE_MULTI_PARENT); 242 : IDS_CHILD_BLOCK_INTERSTITIAL_MESSAGE_MULTI_PARENT);
240 } else { 243 } else {
241 block_message = l10n_util::GetStringFUTF16( 244 block_message = l10n_util::GetStringFUTF16(
242 IDS_BLOCK_INTERSTITIAL_MESSAGE, custodian); 245 IDS_BLOCK_INTERSTITIAL_MESSAGE, custodian);
243 } 246 }
244 } else { 247 } else {
245 block_message = l10n_util::GetStringUTF16( 248 block_message = l10n_util::GetStringUTF16(
246 IDS_BLOCK_INTERSTITIAL_MESSAGE_ACCESS_REQUESTS_DISABLED); 249 IDS_BLOCK_INTERSTITIAL_MESSAGE_ACCESS_REQUESTS_DISABLED);
247 } 250 }
248 strings.SetString("blockPageMessage", block_message); 251 strings.SetString("blockPageMessage", block_message);
249 strings.SetString("blockReasonMessage", is_child_account 252 strings.SetString(
250 ? l10n_util::GetStringUTF16( 253 "blockReasonMessage",
251 SupervisedUserURLFilter::GetBlockMessageID(reason_)) 254 is_child_account ? l10n_util::GetStringUTF16(
252 : base::string16()); 255 SupervisedUserURLFilter::GetBlockMessageID(reason))
256 : base::string16());
253 257
254 bool show_feedback = false; 258 bool show_feedback = false;
255 #if defined(GOOGLE_CHROME_BUILD) 259 #if defined(GOOGLE_CHROME_BUILD)
256 show_feedback = is_child_account && 260 show_feedback =
257 SupervisedUserURLFilter::ReasonIsAutomatic(reason_); 261 is_child_account && SupervisedUserURLFilter::ReasonIsAutomatic(reason);
258 #endif 262 #endif
259 strings.SetBoolean("showFeedbackLink", show_feedback); 263 strings.SetBoolean("showFeedbackLink", show_feedback);
260 strings.SetString("feedbackLink", 264 strings.SetString("feedbackLink",
261 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK)); 265 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK));
262 266
263 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON)); 267 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON));
264 strings.SetString("requestAccessButton", l10n_util::GetStringUTF16( 268 strings.SetString("requestAccessButton", l10n_util::GetStringUTF16(
265 is_child_account 269 is_child_account
266 ? IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON 270 ? IDS_CHILD_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON
267 : IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON)); 271 : IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON));
(...skipping 26 matching lines...) Expand all
294 298
295 std::string html = 299 std::string html =
296 ResourceBundle::GetSharedInstance() 300 ResourceBundle::GetSharedInstance()
297 .GetRawDataResource(IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML) 301 .GetRawDataResource(IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML)
298 .as_string(); 302 .as_string();
299 webui::AppendWebUiCssTextDefaults(&html); 303 webui::AppendWebUiCssTextDefaults(&html);
300 304
301 return webui::GetI18nTemplateHtml(html, &strings); 305 return webui::GetI18nTemplateHtml(html, &strings);
302 } 306 }
303 307
308 std::string SupervisedUserInterstitial::GetHTMLContents() {
309 return GetHTMLContents(profile_, reason_);
310 }
311
304 void SupervisedUserInterstitial::CommandReceived(const std::string& command) { 312 void SupervisedUserInterstitial::CommandReceived(const std::string& command) {
305 // For use in histograms. 313 // For use in histograms.
306 enum Commands { 314 enum Commands {
307 PREVIEW, 315 PREVIEW,
308 BACK, 316 BACK,
309 NTP, 317 NTP,
310 ACCESS_REQUEST, 318 ACCESS_REQUEST,
311 HISTOGRAM_BOUNDING_VALUE 319 HISTOGRAM_BOUNDING_VALUE
312 }; 320 };
313 321
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 supervised_user_service->RemoveObserver(this); 413 supervised_user_service->RemoveObserver(this);
406 414
407 if (!callback_.is_null()) 415 if (!callback_.is_null())
408 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 416 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
409 base::Bind(callback_, continue_request)); 417 base::Bind(callback_, continue_request));
410 418
411 // After this, the WebContents may be destroyed. Make sure we don't try to use 419 // After this, the WebContents may be destroyed. Make sure we don't try to use
412 // it again. 420 // it again.
413 web_contents_ = NULL; 421 web_contents_ = NULL;
414 } 422 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698