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

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

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