| 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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/version.h" |
| 12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" | 14 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/profiles/profile_info_cache.h" | 16 #include "chrome/browser/profiles/profile_info_cache.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 18 #include "chrome/browser/signin/signin_manager_factory.h" | 19 #include "chrome/browser/signin/signin_manager_factory.h" |
| 19 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist_
downloader.h" | 20 #include "chrome/browser/supervised_user/experimental/supervised_user_blacklist_
downloader.h" |
| 20 #include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_ser
vice.h" | 21 #include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_ser
vice.h" |
| 21 #include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_ser
vice_factory.h" | 22 #include "chrome/browser/supervised_user/legacy/custodian_profile_downloader_ser
vice_factory.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 void CreateURLAccessRequest( | 82 void CreateURLAccessRequest( |
| 82 const GURL& url, | 83 const GURL& url, |
| 83 PermissionRequestCreator* creator, | 84 PermissionRequestCreator* creator, |
| 84 const SupervisedUserService::SuccessCallback& callback) { | 85 const SupervisedUserService::SuccessCallback& callback) { |
| 85 creator->CreateURLAccessRequest(url, callback); | 86 creator->CreateURLAccessRequest(url, callback); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void CreateExtensionUpdateRequest( | 89 void CreateExtensionUpdateRequest( |
| 89 const std::string& extension_id, | 90 const std::string& id, |
| 90 PermissionRequestCreator* creator, | 91 PermissionRequestCreator* creator, |
| 91 const SupervisedUserService::SuccessCallback& callback) { | 92 const SupervisedUserService::SuccessCallback& callback) { |
| 92 creator->CreateExtensionUpdateRequest(extension_id, callback); | 93 creator->CreateExtensionUpdateRequest(id, callback); |
| 93 } | 94 } |
| 94 | 95 |
| 95 #if defined(ENABLE_EXTENSIONS) | 96 #if defined(ENABLE_EXTENSIONS) |
| 96 enum ExtensionState { | 97 enum ExtensionState { |
| 97 EXTENSION_FORCED, | 98 EXTENSION_FORCED, |
| 98 EXTENSION_BLOCKED, | 99 EXTENSION_BLOCKED, |
| 99 EXTENSION_ALLOWED | 100 EXTENSION_ALLOWED |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 ExtensionState GetExtensionState(const extensions::Extension* extension) { | 103 ExtensionState GetExtensionState(const extensions::Extension* extension) { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 const GURL& url, | 651 const GURL& url, |
| 651 const SuccessCallback& callback) { | 652 const SuccessCallback& callback) { |
| 652 AddPermissionRequestInternal( | 653 AddPermissionRequestInternal( |
| 653 base::Bind(CreateURLAccessRequest, | 654 base::Bind(CreateURLAccessRequest, |
| 654 SupervisedUserURLFilter::Normalize(url)), | 655 SupervisedUserURLFilter::Normalize(url)), |
| 655 callback, 0); | 656 callback, 0); |
| 656 } | 657 } |
| 657 | 658 |
| 658 void SupervisedUserService::AddExtensionUpdateRequest( | 659 void SupervisedUserService::AddExtensionUpdateRequest( |
| 659 const std::string& extension_id, | 660 const std::string& extension_id, |
| 661 const base::Version& version, |
| 660 const SuccessCallback& callback) { | 662 const SuccessCallback& callback) { |
| 663 std::string id = extension_id + ":" + version.GetString(); |
| 661 AddPermissionRequestInternal( | 664 AddPermissionRequestInternal( |
| 662 base::Bind(CreateExtensionUpdateRequest, extension_id), | 665 base::Bind(CreateExtensionUpdateRequest, id), |
| 663 callback, 0); | 666 callback, 0); |
| 664 } | 667 } |
| 665 | 668 |
| 666 void SupervisedUserService::InitSync(const std::string& refresh_token) { | 669 void SupervisedUserService::InitSync(const std::string& refresh_token) { |
| 667 StartSetupSync(); | 670 StartSetupSync(); |
| 668 | 671 |
| 669 ProfileOAuth2TokenService* token_service = | 672 ProfileOAuth2TokenService* token_service = |
| 670 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 673 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| 671 token_service->UpdateCredentials(supervised_users::kSupervisedUserPseudoEmail, | 674 token_service->UpdateCredentials(supervised_users::kSupervisedUserPseudoEmail, |
| 672 refresh_token); | 675 refresh_token); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 // The active user can be NULL in unit tests. | 942 // The active user can be NULL in unit tests. |
| 940 if (user_manager::UserManager::Get()->GetActiveUser()) { | 943 if (user_manager::UserManager::Get()->GetActiveUser()) { |
| 941 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 944 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
| 942 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 945 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
| 943 } | 946 } |
| 944 return std::string(); | 947 return std::string(); |
| 945 #else | 948 #else |
| 946 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 949 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
| 947 #endif | 950 #endif |
| 948 } | 951 } |
| OLD | NEW |