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

Unified Diff: chrome/browser/supervised_user/supervised_user_interstitial.cc

Issue 483703002: Supervised users: Use custodian avatar image(s) in the block interstitial if they're available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/supervised_user_block_interstitial.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/supervised_user/supervised_user_interstitial.cc
diff --git a/chrome/browser/supervised_user/supervised_user_interstitial.cc b/chrome/browser/supervised_user/supervised_user_interstitial.cc
index 2fa3ca23b2d2b741222f13d287b7343a0cdc0f9c..484ebf382239cd4ea3fcf66bde81c20f3d662e65 100644
--- a/chrome/browser/supervised_user/supervised_user_interstitial.cc
+++ b/chrome/browser/supervised_user/supervised_user_interstitial.cc
@@ -7,6 +7,7 @@
#include "base/i18n/rtl.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/infobars/infobar_service.h"
@@ -33,10 +34,28 @@
using content::BrowserThread;
+namespace {
+
+static const int kAvatarSize1x = 45;
+static const int kAvatarSize2x = 90;
+
+std::string BuildAvatarImageUrl(const std::string& url,
+ const GURL& base_url,
+ int size) {
+ std::string result = url;
+ size_t slash = result.rfind('/');
+ if (slash != std::string::npos)
+ result.insert(slash, "/s" + base::IntToString(size));
+ return base_url.Resolve(result).spec();
+}
+
+} // namespace
+
// static
-void SupervisedUserInterstitial::Show(content::WebContents* web_contents,
- const GURL& url,
- const base::Callback<void(bool)>& callback) {
+void SupervisedUserInterstitial::Show(
+ content::WebContents* web_contents,
+ const GURL& url,
+ const base::Callback<void(bool)>& callback) {
SupervisedUserInterstitial* interstitial =
new SupervisedUserInterstitial(web_contents, url, callback);
@@ -132,6 +151,28 @@ std::string SupervisedUserInterstitial::GetHTMLContents() {
bool allow_access_requests = supervised_user_service->AccessRequestsEnabled();
strings.SetBoolean("allowAccessRequests", allow_access_requests);
+ GURL profile_url = GURL(profile->GetPrefs()->GetString(
+ prefs::kSupervisedUserCustodianProfileURL));
+ std::string profile_image_url = profile->GetPrefs()->GetString(
+ prefs::kSupervisedUserCustodianProfileImageURL);
+ strings.SetString("avatarURL1x", BuildAvatarImageUrl(profile_image_url,
+ profile_url,
+ kAvatarSize1x));
+ strings.SetString("avatarURL2x", BuildAvatarImageUrl(profile_image_url,
+ profile_url,
+ kAvatarSize2x));
+
+ GURL profile_url2 = GURL(profile->GetPrefs()->GetString(
+ prefs::kSupervisedUserSecondCustodianProfileURL));
+ std::string profile_image_url2 = profile->GetPrefs()->GetString(
+ prefs::kSupervisedUserSecondCustodianProfileImageURL);
+ strings.SetString("secondAvatarURL1x", BuildAvatarImageUrl(profile_image_url2,
+ profile_url2,
+ kAvatarSize1x));
+ strings.SetString("secondAvatarURL2x", BuildAvatarImageUrl(profile_image_url2,
+ profile_url2,
+ kAvatarSize2x));
+
base::string16 custodian =
base::UTF8ToUTF16(supervised_user_service->GetCustodianName());
strings.SetString(
« no previous file with comments | « chrome/browser/resources/supervised_user_block_interstitial.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698