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

Side by Side Diff: chrome/browser/supervised_user/child_accounts/child_account_service.cc

Issue 986303002: Re-enable child account detection, now behind a flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: strings Created 5 years, 9 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
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/child_accounts/child_account_service.h" 5 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 ScheduleNextFamilyInfoUpdate( 231 ScheduleNextFamilyInfoUpdate(
232 base::TimeDelta::FromSeconds(kUpdateIntervalSeconds)); 232 base::TimeDelta::FromSeconds(kUpdateIntervalSeconds));
233 } 233 }
234 234
235 void ChildAccountService::OnFailure(FamilyInfoFetcher::ErrorCode error) { 235 void ChildAccountService::OnFailure(FamilyInfoFetcher::ErrorCode error) {
236 DLOG(WARNING) << "GetFamilyMembers failed with code " << error; 236 DLOG(WARNING) << "GetFamilyMembers failed with code " << error;
237 family_fetch_backoff_.InformOfRequest(false); 237 family_fetch_backoff_.InformOfRequest(false);
238 ScheduleNextFamilyInfoUpdate(family_fetch_backoff_.GetTimeUntilRelease()); 238 ScheduleNextFamilyInfoUpdate(family_fetch_backoff_.GetTimeUntilRelease());
239 } 239 }
240 240
241 bool ChildAccountService::IsChildAccountDetectionEnabled() const {
242 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
243 bool is_enabled =
244 command_line->HasSwitch(switches::kEnableChildAccountDetection);
245 bool is_disabled =
246 command_line->HasSwitch(switches::kDisableChildAccountDetection);
247 return is_enabled && !is_disabled;
248 }
249
241 void ChildAccountService::StartFetchingFamilyInfo() { 250 void ChildAccountService::StartFetchingFamilyInfo() {
242 family_fetcher_.reset(new FamilyInfoFetcher( 251 family_fetcher_.reset(new FamilyInfoFetcher(
243 this, 252 this,
244 SigninManagerFactory::GetForProfile(profile_) 253 SigninManagerFactory::GetForProfile(profile_)
245 ->GetAuthenticatedAccountId(), 254 ->GetAuthenticatedAccountId(),
246 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), 255 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
247 profile_->GetRequestContext())); 256 profile_->GetRequestContext()));
248 family_fetcher_->StartGetFamilyMembers(); 257 family_fetcher_->StartGetFamilyMembers();
249 } 258 }
250 259
251 void ChildAccountService::CancelFetchingFamilyInfo() { 260 void ChildAccountService::CancelFetchingFamilyInfo() {
252 family_fetcher_.reset(); 261 family_fetcher_.reset();
253 family_fetch_timer_.Stop(); 262 family_fetch_timer_.Stop();
254 } 263 }
255 264
256 void ChildAccountService::ScheduleNextFamilyInfoUpdate(base::TimeDelta delay) { 265 void ChildAccountService::ScheduleNextFamilyInfoUpdate(base::TimeDelta delay) {
257 family_fetch_timer_.Start( 266 family_fetch_timer_.Start(
258 FROM_HERE, delay, this, &ChildAccountService::StartFetchingFamilyInfo); 267 FROM_HERE, delay, this, &ChildAccountService::StartFetchingFamilyInfo);
259 } 268 }
260 269
261 void ChildAccountService::StartFetchingServiceFlags() { 270 void ChildAccountService::StartFetchingServiceFlags() {
271 if (!IsChildAccountDetectionEnabled()) {
272 SetIsChildAccount(false);
273 return;
274 }
262 account_id_ = SigninManagerFactory::GetForProfile(profile_) 275 account_id_ = SigninManagerFactory::GetForProfile(profile_)
263 ->GetAuthenticatedAccountId(); 276 ->GetAuthenticatedAccountId();
277 flag_fetcher_.reset(new AccountServiceFlagFetcher(
278 account_id_,
279 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
280 profile_->GetRequestContext(),
281 base::Bind(&ChildAccountService::OnFlagsFetched,
282 weak_ptr_factory_.GetWeakPtr())));
264 } 283 }
265 284
266 void ChildAccountService::CancelFetchingServiceFlags() { 285 void ChildAccountService::CancelFetchingServiceFlags() {
267 flag_fetcher_.reset(); 286 flag_fetcher_.reset();
268 account_id_.clear(); 287 account_id_.clear();
269 flag_fetch_timer_.Stop(); 288 flag_fetch_timer_.Stop();
270 } 289 }
271 290
272 void ChildAccountService::OnFlagsFetched( 291 void ChildAccountService::OnFlagsFetched(
273 AccountServiceFlagFetcher::ResultCode result, 292 AccountServiceFlagFetcher::ResultCode result,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 command_line->AppendSwitch(switches::kEnableSupervisedUserBlacklist); 394 command_line->AppendSwitch(switches::kEnableSupervisedUserBlacklist);
376 395
377 // Query-based filtering also defaults to enabled. 396 // Query-based filtering also defaults to enabled.
378 bool has_enable_safesites = 397 bool has_enable_safesites =
379 command_line->HasSwitch(switches::kEnableSupervisedUserSafeSites); 398 command_line->HasSwitch(switches::kEnableSupervisedUserSafeSites);
380 bool has_disable_safesites = 399 bool has_disable_safesites =
381 command_line->HasSwitch(switches::kDisableSupervisedUserSafeSites); 400 command_line->HasSwitch(switches::kDisableSupervisedUserSafeSites);
382 if (!has_enable_safesites && !has_disable_safesites) 401 if (!has_enable_safesites && !has_disable_safesites)
383 command_line->AppendSwitch(switches::kEnableSupervisedUserSafeSites); 402 command_line->AppendSwitch(switches::kEnableSupervisedUserSafeSites);
384 } 403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698