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

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: Manual rebase to fix merge problem 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
« no previous file with comments | « chrome/browser/supervised_user/supervised_user_interstitial.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 base::string16 custodian_email = 235 base::string16 custodian_email =
233 base::UTF8ToUTF16(supervised_user_service->GetCustodianEmailAddress()); 236 base::UTF8ToUTF16(supervised_user_service->GetCustodianEmailAddress());
234 base::string16 second_custodian_email = base::UTF8ToUTF16( 237 base::string16 second_custodian_email = base::UTF8ToUTF16(
235 supervised_user_service->GetSecondCustodianEmailAddress()); 238 supervised_user_service->GetSecondCustodianEmailAddress());
236 strings.SetString("custodianName", custodian); 239 strings.SetString("custodianName", custodian);
(...skipping 12 matching lines...) Expand all
249 block_message = l10n_util::GetStringFUTF16( 252 block_message = l10n_util::GetStringFUTF16(
250 IDS_BLOCK_INTERSTITIAL_MESSAGE, custodian); 253 IDS_BLOCK_INTERSTITIAL_MESSAGE, custodian);
251 } 254 }
252 } else { 255 } else {
253 block_message = l10n_util::GetStringUTF16( 256 block_message = l10n_util::GetStringUTF16(
254 IDS_BLOCK_INTERSTITIAL_MESSAGE_ACCESS_REQUESTS_DISABLED); 257 IDS_BLOCK_INTERSTITIAL_MESSAGE_ACCESS_REQUESTS_DISABLED);
255 } 258 }
256 strings.SetString("blockPageMessage", block_message); 259 strings.SetString("blockPageMessage", block_message);
257 strings.SetString("blockReasonMessage", l10n_util::GetStringUTF16( 260 strings.SetString("blockReasonMessage", l10n_util::GetStringUTF16(
258 SupervisedUserURLFilter::GetBlockMessageID( 261 SupervisedUserURLFilter::GetBlockMessageID(
259 reason_, is_child_account, second_custodian.empty()))); 262 reason, is_child_account, second_custodian.empty())));
260 strings.SetString("blockReasonHeader", l10n_util::GetStringUTF16( 263 strings.SetString("blockReasonHeader", l10n_util::GetStringUTF16(
261 SupervisedUserURLFilter::GetBlockHeaderID(reason_))); 264 SupervisedUserURLFilter::GetBlockHeaderID(reason)));
262
263 bool show_feedback = false; 265 bool show_feedback = false;
264 #if defined(GOOGLE_CHROME_BUILD) 266 #if defined(GOOGLE_CHROME_BUILD)
265 show_feedback = is_child_account && 267 show_feedback =
266 SupervisedUserURLFilter::ReasonIsAutomatic(reason_); 268 is_child_account && SupervisedUserURLFilter::ReasonIsAutomatic(reason);
267 #endif 269 #endif
268 strings.SetBoolean("showFeedbackLink", show_feedback); 270 strings.SetBoolean("showFeedbackLink", show_feedback);
269 strings.SetString("feedbackLink", 271 strings.SetString("feedbackLink",
270 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK)); 272 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_SEND_FEEDBACK));
271 273
272 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON)); 274 strings.SetString("backButton", l10n_util::GetStringUTF16(IDS_BACK_BUTTON));
273 strings.SetString("requestAccessButton", l10n_util::GetStringUTF16( 275 strings.SetString("requestAccessButton", l10n_util::GetStringUTF16(
274 IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON)); 276 IDS_BLOCK_INTERSTITIAL_REQUEST_ACCESS_BUTTON));
275 277
276 strings.SetString("showDetailsLink", l10n_util::GetStringUTF16( 278 strings.SetString("showDetailsLink", l10n_util::GetStringUTF16(
(...skipping 29 matching lines...) Expand all
306 308
307 std::string html = 309 std::string html =
308 ResourceBundle::GetSharedInstance() 310 ResourceBundle::GetSharedInstance()
309 .GetRawDataResource(IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML) 311 .GetRawDataResource(IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML)
310 .as_string(); 312 .as_string();
311 webui::AppendWebUiCssTextDefaults(&html); 313 webui::AppendWebUiCssTextDefaults(&html);
312 314
313 return webui::GetI18nTemplateHtml(html, &strings); 315 return webui::GetI18nTemplateHtml(html, &strings);
314 } 316 }
315 317
318 std::string SupervisedUserInterstitial::GetHTMLContents() {
319 return GetHTMLContents(profile_, reason_);
320 }
321
316 void SupervisedUserInterstitial::CommandReceived(const std::string& command) { 322 void SupervisedUserInterstitial::CommandReceived(const std::string& command) {
317 // For use in histograms. 323 // For use in histograms.
318 enum Commands { 324 enum Commands {
319 PREVIEW, 325 PREVIEW,
320 BACK, 326 BACK,
321 NTP, 327 NTP,
322 ACCESS_REQUEST, 328 ACCESS_REQUEST,
323 HISTOGRAM_BOUNDING_VALUE 329 HISTOGRAM_BOUNDING_VALUE
324 }; 330 };
325 331
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 supervised_user_service->RemoveObserver(this); 429 supervised_user_service->RemoveObserver(this);
424 430
425 if (!callback_.is_null()) 431 if (!callback_.is_null())
426 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 432 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
427 base::Bind(callback_, continue_request)); 433 base::Bind(callback_, continue_request));
428 434
429 // After this, the WebContents may be destroyed. Make sure we don't try to use 435 // After this, the WebContents may be destroyed. Make sure we don't try to use
430 // it again. 436 // it again.
431 web_contents_ = NULL; 437 web_contents_ = NULL;
432 } 438 }
OLDNEW
« no previous file with comments | « chrome/browser/supervised_user/supervised_user_interstitial.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698