| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/task_runner_util.h" | 16 #include "base/task_runner_util.h" |
| 17 #include "base/version.h" | 17 #include "base/version.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" | 20 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" |
| 21 #include "chrome/browser/net/file_downloader.h" | |
| 22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/profiles/profile_attributes_entry.h" | 22 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 24 #include "chrome/browser/profiles/profile_attributes_storage.h" | 23 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 27 #include "chrome/browser/signin/signin_manager_factory.h" | 26 #include "chrome/browser/signin/signin_manager_factory.h" |
| 28 #include "chrome/browser/supervised_user/experimental/supervised_user_filtering_
switches.h" | 27 #include "chrome/browser/supervised_user/experimental/supervised_user_filtering_
switches.h" |
| 29 #include "chrome/browser/supervised_user/permission_request_creator.h" | 28 #include "chrome/browser/supervised_user/permission_request_creator.h" |
| 30 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 29 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
| 31 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" | 30 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 } | 845 } |
| 847 | 846 |
| 848 void SupervisedUserService::LoadBlacklistFromFile(const base::FilePath& path) { | 847 void SupervisedUserService::LoadBlacklistFromFile(const base::FilePath& path) { |
| 849 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); | 848 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); |
| 850 blacklist_.ReadFromFile( | 849 blacklist_.ReadFromFile( |
| 851 path, | 850 path, |
| 852 base::Bind(&SupervisedUserService::OnBlacklistLoaded, | 851 base::Bind(&SupervisedUserService::OnBlacklistLoaded, |
| 853 base::Unretained(this))); | 852 base::Unretained(this))); |
| 854 } | 853 } |
| 855 | 854 |
| 856 void SupervisedUserService::OnBlacklistDownloadDone(const base::FilePath& path, | 855 void SupervisedUserService::OnBlacklistDownloadDone( |
| 857 bool success) { | 856 const base::FilePath& path, |
| 857 FileDownloader::Result result) { |
| 858 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); | 858 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); |
| 859 if (success) { | 859 if (FileDownloader::IsSuccess(result)) { |
| 860 LoadBlacklistFromFile(path); | 860 LoadBlacklistFromFile(path); |
| 861 } else { | 861 } else { |
| 862 LOG(WARNING) << "Blacklist download failed"; | 862 LOG(WARNING) << "Blacklist download failed"; |
| 863 // TODO(treib): Retry downloading after some time? | 863 // TODO(treib): Retry downloading after some time? |
| 864 } | 864 } |
| 865 blacklist_downloader_.reset(); | 865 blacklist_downloader_.reset(); |
| 866 } | 866 } |
| 867 | 867 |
| 868 void SupervisedUserService::OnBlacklistLoaded() { | 868 void SupervisedUserService::OnBlacklistLoaded() { |
| 869 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); | 869 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); | 1058 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); |
| 1059 | 1059 |
| 1060 is_profile_active_ = profile_became_active; | 1060 is_profile_active_ = profile_became_active; |
| 1061 } | 1061 } |
| 1062 #endif // !defined(OS_ANDROID) | 1062 #endif // !defined(OS_ANDROID) |
| 1063 | 1063 |
| 1064 void SupervisedUserService::OnSiteListUpdated() { | 1064 void SupervisedUserService::OnSiteListUpdated() { |
| 1065 FOR_EACH_OBSERVER( | 1065 FOR_EACH_OBSERVER( |
| 1066 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); | 1066 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); |
| 1067 } | 1067 } |
| OLD | NEW |