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

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

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