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

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

Issue 495003003: Supervised user interstitial: Handle missing custodian profile URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_TITLE)); 141 l10n_util::GetStringUTF16(IDS_BLOCK_INTERSTITIAL_TITLE));
142 142
143 Profile* profile = 143 Profile* profile =
144 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 144 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
145 SupervisedUserService* supervised_user_service = 145 SupervisedUserService* supervised_user_service =
146 SupervisedUserServiceFactory::GetForProfile(profile); 146 SupervisedUserServiceFactory::GetForProfile(profile);
147 147
148 bool allow_access_requests = supervised_user_service->AccessRequestsEnabled(); 148 bool allow_access_requests = supervised_user_service->AccessRequestsEnabled();
149 strings.SetBoolean("allowAccessRequests", allow_access_requests); 149 strings.SetBoolean("allowAccessRequests", allow_access_requests);
150 150
151 GURL profile_url = GURL(profile->GetPrefs()->GetString( 151 GURL base_url = GURL(profile->GetPrefs()->GetString(
152 prefs::kSupervisedUserCustodianProfileURL)); 152 prefs::kSupervisedUserCustodianProfileURL));
153 if (!base_url.is_valid())
154 base_url = GURL("https://dummy.url");
155 DCHECK(base_url.is_valid());
153 std::string profile_image_url = profile->GetPrefs()->GetString( 156 std::string profile_image_url = profile->GetPrefs()->GetString(
154 prefs::kSupervisedUserCustodianProfileImageURL); 157 prefs::kSupervisedUserCustodianProfileImageURL);
155 strings.SetString("avatarURL1x", BuildAvatarImageUrl(profile_image_url, 158 strings.SetString("avatarURL1x", BuildAvatarImageUrl(profile_image_url,
156 profile_url, 159 base_url,
157 kAvatarSize1x)); 160 kAvatarSize1x));
158 strings.SetString("avatarURL2x", BuildAvatarImageUrl(profile_image_url, 161 strings.SetString("avatarURL2x", BuildAvatarImageUrl(profile_image_url,
159 profile_url, 162 base_url,
160 kAvatarSize2x)); 163 kAvatarSize2x));
161 164
162 GURL profile_url2 = GURL(profile->GetPrefs()->GetString( 165 GURL base_url2 = GURL(profile->GetPrefs()->GetString(
163 prefs::kSupervisedUserSecondCustodianProfileURL)); 166 prefs::kSupervisedUserSecondCustodianProfileURL));
167 if (!base_url2.is_valid())
168 base_url2 = GURL("https://dummy.url");
169 DCHECK(base_url2.is_valid());
164 std::string profile_image_url2 = profile->GetPrefs()->GetString( 170 std::string profile_image_url2 = profile->GetPrefs()->GetString(
165 prefs::kSupervisedUserSecondCustodianProfileImageURL); 171 prefs::kSupervisedUserSecondCustodianProfileImageURL);
166 strings.SetString("secondAvatarURL1x", BuildAvatarImageUrl(profile_image_url2, 172 strings.SetString("secondAvatarURL1x", BuildAvatarImageUrl(profile_image_url2,
167 profile_url2, 173 base_url2,
168 kAvatarSize1x)); 174 kAvatarSize1x));
169 strings.SetString("secondAvatarURL2x", BuildAvatarImageUrl(profile_image_url2, 175 strings.SetString("secondAvatarURL2x", BuildAvatarImageUrl(profile_image_url2,
170 profile_url2, 176 base_url2,
171 kAvatarSize2x)); 177 kAvatarSize2x));
172 178
173 base::string16 custodian = 179 base::string16 custodian =
174 base::UTF8ToUTF16(supervised_user_service->GetCustodianName()); 180 base::UTF8ToUTF16(supervised_user_service->GetCustodianName());
175 strings.SetString( 181 strings.SetString(
176 "blockPageMessage", 182 "blockPageMessage",
177 allow_access_requests 183 allow_access_requests
178 ? l10n_util::GetStringFUTF16(IDS_BLOCK_INTERSTITIAL_MESSAGE, 184 ? l10n_util::GetStringFUTF16(IDS_BLOCK_INTERSTITIAL_MESSAGE,
179 custodian) 185 custodian)
180 : l10n_util::GetStringUTF16( 186 : l10n_util::GetStringUTF16(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 void SupervisedUserInterstitial::DispatchContinueRequest( 271 void SupervisedUserInterstitial::DispatchContinueRequest(
266 bool continue_request) { 272 bool continue_request) {
267 // If there is no history entry to go back to, close the tab instead. 273 // If there is no history entry to go back to, close the tab instead.
268 int nav_entry_count = web_contents_->GetController().GetEntryCount(); 274 int nav_entry_count = web_contents_->GetController().GetEntryCount();
269 if (!continue_request && nav_entry_count == 0) 275 if (!continue_request && nav_entry_count == 0)
270 web_contents_->Close(); 276 web_contents_->Close();
271 277
272 BrowserThread::PostTask( 278 BrowserThread::PostTask(
273 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); 279 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request));
274 } 280 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698