OLD | NEW |
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/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/signin/account_tracker_service_factory.h" | 13 #include "chrome/browser/signin/account_tracker_service_factory.h" |
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
15 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
16 #include "chrome/browser/supervised_user/child_accounts/permission_request_creat
or_apiary.h" | 16 #include "chrome/browser/supervised_user/child_accounts/permission_request_creat
or_apiary.h" |
17 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 17 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
18 #include "chrome/browser/supervised_user/supervised_user_service.h" | 18 #include "chrome/browser/supervised_user/supervised_user_service.h" |
19 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 19 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
20 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 20 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
21 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" | 21 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" |
22 #include "chrome/browser/sync/profile_sync_service.h" | 22 #include "chrome/browser/sync/profile_sync_service.h" |
23 #include "chrome/browser/sync/profile_sync_service_factory.h" | 23 #include "chrome/browser/sync/profile_sync_service_factory.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
26 #include "components/pref_registry/pref_registry_syncable.h" | 26 #include "components/pref_registry/pref_registry_syncable.h" |
27 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 27 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
28 #include "components/signin/core/browser/signin_manager.h" | 28 #include "components/signin/core/browser/signin_manager.h" |
29 | 29 |
30 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) && !defined(USE_AURA) |
31 #include "base/android/jni_android.h" | 31 #include "base/android/jni_android.h" |
32 #include "chrome/browser/supervised_user/child_accounts/child_account_service_an
droid.h" | 32 #include "chrome/browser/supervised_user/child_accounts/child_account_service_an
droid.h" |
33 #endif | 33 #endif |
34 | 34 |
35 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
36 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 36 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
37 #include "components/user_manager/user_manager.h" | 37 #include "components/user_manager/user_manager.h" |
38 #endif | 38 #endif |
39 | 39 |
40 const char kChildAccountDetectionFieldTrialName[] = "ChildAccountDetection"; | 40 const char kChildAccountDetectionFieldTrialName[] = "ChildAccountDetection"; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 for (const auto& callback : status_received_callback_list_) | 118 for (const auto& callback : status_received_callback_list_) |
119 callback.Run(); | 119 callback.Run(); |
120 status_received_callback_list_.clear(); | 120 status_received_callback_list_.clear(); |
121 } | 121 } |
122 | 122 |
123 void ChildAccountService::Init() { | 123 void ChildAccountService::Init() { |
124 SupervisedUserServiceFactory::GetForProfile(profile_)->SetDelegate(this); | 124 SupervisedUserServiceFactory::GetForProfile(profile_)->SetDelegate(this); |
125 AccountTrackerServiceFactory::GetForProfile(profile_)->AddObserver(this); | 125 AccountTrackerServiceFactory::GetForProfile(profile_)->AddObserver(this); |
126 | 126 |
127 #if defined(OS_ANDROID) | 127 #if defined(OS_ANDROID) && !defined(USE_AURA) |
128 bool is_child_account = false; | 128 bool is_child_account = false; |
129 if (GetJavaChildAccountStatus(&is_child_account)) | 129 if (GetJavaChildAccountStatus(&is_child_account)) |
130 SetIsChildAccount(is_child_account); | 130 SetIsChildAccount(is_child_account); |
131 #endif | 131 #endif |
132 | 132 |
133 PropagateChildStatusToUser(profile_->IsChild()); | 133 PropagateChildStatusToUser(profile_->IsChild()); |
134 | 134 |
135 // If we're already signed in, check the account immediately just to be sure. | 135 // If we're already signed in, check the account immediately just to be sure. |
136 // (We might have missed an update before registering as an observer.) | 136 // (We might have missed an update before registering as an observer.) |
137 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); | 137 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 331 } |
332 | 332 |
333 void ChildAccountService::ClearSecondCustodianPrefs() { | 333 void ChildAccountService::ClearSecondCustodianPrefs() { |
334 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianName); | 334 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianName); |
335 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianEmail); | 335 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianEmail); |
336 profile_->GetPrefs()->ClearPref( | 336 profile_->GetPrefs()->ClearPref( |
337 prefs::kSupervisedUserSecondCustodianProfileURL); | 337 prefs::kSupervisedUserSecondCustodianProfileURL); |
338 profile_->GetPrefs()->ClearPref( | 338 profile_->GetPrefs()->ClearPref( |
339 prefs::kSupervisedUserSecondCustodianProfileImageURL); | 339 prefs::kSupervisedUserSecondCustodianProfileImageURL); |
340 } | 340 } |
OLD | NEW |