Chromium Code Reviews| 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/supervised_user_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 creator->CreateURLAccessRequest(url, callback); | 102 creator->CreateURLAccessRequest(url, callback); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void CreateExtensionUpdateRequest( | 105 void CreateExtensionUpdateRequest( |
| 106 const std::string& id, | 106 const std::string& id, |
| 107 PermissionRequestCreator* creator, | 107 PermissionRequestCreator* creator, |
| 108 const SupervisedUserService::SuccessCallback& callback) { | 108 const SupervisedUserService::SuccessCallback& callback) { |
| 109 creator->CreateExtensionUpdateRequest(id, callback); | 109 creator->CreateExtensionUpdateRequest(id, callback); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Default callback for AddExtensionUpdateRequest. | |
| 113 void ExtensionUpdateRequestSent(const std::string& id, bool success) { | |
| 114 LOG_IF(WARNING, !success) << "Failed sending update request for " << id; | |
|
Devlin
2015/10/16 02:40:24
LOGs are annoying. We never read them, except whe
Marc Treib
2015/10/16 09:22:20
It can happen when the server we talk to is down,
| |
| 115 } | |
| 116 | |
| 112 base::FilePath GetBlacklistPath() { | 117 base::FilePath GetBlacklistPath() { |
| 113 base::FilePath blacklist_dir; | 118 base::FilePath blacklist_dir; |
| 114 PathService::Get(chrome::DIR_USER_DATA, &blacklist_dir); | 119 PathService::Get(chrome::DIR_USER_DATA, &blacklist_dir); |
| 115 return blacklist_dir.AppendASCII(kBlacklistFilename); | 120 return blacklist_dir.AppendASCII(kBlacklistFilename); |
| 116 } | 121 } |
| 117 | 122 |
| 118 #if defined(ENABLE_EXTENSIONS) | 123 #if defined(ENABLE_EXTENSIONS) |
| 119 enum ExtensionState { | 124 enum ExtensionState { |
| 120 EXTENSION_FORCED, | 125 EXTENSION_FORCED, |
| 121 EXTENSION_BLOCKED, | 126 EXTENSION_BLOCKED, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 void SupervisedUserService::AddExtensionUpdateRequest( | 250 void SupervisedUserService::AddExtensionUpdateRequest( |
| 246 const std::string& extension_id, | 251 const std::string& extension_id, |
| 247 const base::Version& version, | 252 const base::Version& version, |
| 248 const SuccessCallback& callback) { | 253 const SuccessCallback& callback) { |
| 249 std::string id = extension_id + ":" + version.GetString(); | 254 std::string id = extension_id + ":" + version.GetString(); |
| 250 AddPermissionRequestInternal( | 255 AddPermissionRequestInternal( |
| 251 base::Bind(CreateExtensionUpdateRequest, id), | 256 base::Bind(CreateExtensionUpdateRequest, id), |
| 252 callback, 0); | 257 callback, 0); |
| 253 } | 258 } |
| 254 | 259 |
| 260 void SupervisedUserService::AddExtensionUpdateRequest( | |
| 261 const std::string& extension_id, | |
| 262 const base::Version& version) { | |
| 263 AddExtensionUpdateRequest( | |
| 264 extension_id, version, | |
| 265 base::Bind(ExtensionUpdateRequestSent, | |
| 266 extension_id + ":" + version.GetString())); | |
|
Devlin
2015/10/16 02:40:24
nitty nit: prefer base::StringPrintf for times lik
Marc Treib
2015/10/16 09:22:20
Done.
| |
| 267 } | |
| 268 | |
| 255 std::string SupervisedUserService::GetCustodianEmailAddress() const { | 269 std::string SupervisedUserService::GetCustodianEmailAddress() const { |
| 256 std::string email = profile_->GetPrefs()->GetString( | 270 std::string email = profile_->GetPrefs()->GetString( |
| 257 prefs::kSupervisedUserCustodianEmail); | 271 prefs::kSupervisedUserCustodianEmail); |
| 258 #if defined(OS_CHROMEOS) | 272 #if defined(OS_CHROMEOS) |
| 259 // |GetActiveUser()| can return null in unit tests. | 273 // |GetActiveUser()| can return null in unit tests. |
| 260 if (email.empty() && !!user_manager::UserManager::Get()->GetActiveUser()) { | 274 if (email.empty() && !!user_manager::UserManager::Get()->GetActiveUser()) { |
| 261 email = chromeos::ChromeUserManager::Get() | 275 email = chromeos::ChromeUserManager::Get() |
| 262 ->GetSupervisedUserManager() | 276 ->GetSupervisedUserManager() |
| 263 ->GetManagerDisplayEmail( | 277 ->GetManagerDisplayEmail( |
| 264 user_manager::UserManager::Get()->GetActiveUser()->email()); | 278 user_manager::UserManager::Get()->GetActiveUser()->email()); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 974 | 988 |
| 975 is_profile_active_ = profile_became_active; | 989 is_profile_active_ = profile_became_active; |
| 976 } | 990 } |
| 977 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 991 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 978 | 992 |
| 979 void SupervisedUserService::OnSiteListUpdated() { | 993 void SupervisedUserService::OnSiteListUpdated() { |
| 980 FOR_EACH_OBSERVER( | 994 FOR_EACH_OBSERVER( |
| 981 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); | 995 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); |
| 982 } | 996 } |
| 983 | 997 |
| OLD | NEW |