| 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 } | 831 } |
| 833 | 832 |
| 834 void SupervisedUserService::LoadBlacklistFromFile(const base::FilePath& path) { | 833 void SupervisedUserService::LoadBlacklistFromFile(const base::FilePath& path) { |
| 835 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); | 834 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); |
| 836 blacklist_.ReadFromFile( | 835 blacklist_.ReadFromFile( |
| 837 path, | 836 path, |
| 838 base::Bind(&SupervisedUserService::OnBlacklistLoaded, | 837 base::Bind(&SupervisedUserService::OnBlacklistLoaded, |
| 839 base::Unretained(this))); | 838 base::Unretained(this))); |
| 840 } | 839 } |
| 841 | 840 |
| 842 void SupervisedUserService::OnBlacklistDownloadDone(const base::FilePath& path, | 841 void SupervisedUserService::OnBlacklistDownloadDone( |
| 843 bool success) { | 842 const base::FilePath& path, |
| 843 FileDownloader::Result result) { |
| 844 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); | 844 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); |
| 845 if (success) { | 845 if (FileDownloader::IsSuccess(result)) { |
| 846 LoadBlacklistFromFile(path); | 846 LoadBlacklistFromFile(path); |
| 847 } else { | 847 } else { |
| 848 LOG(WARNING) << "Blacklist download failed"; | 848 LOG(WARNING) << "Blacklist download failed"; |
| 849 // TODO(treib): Retry downloading after some time? | 849 // TODO(treib): Retry downloading after some time? |
| 850 } | 850 } |
| 851 blacklist_downloader_.reset(); | 851 blacklist_downloader_.reset(); |
| 852 } | 852 } |
| 853 | 853 |
| 854 void SupervisedUserService::OnBlacklistLoaded() { | 854 void SupervisedUserService::OnBlacklistLoaded() { |
| 855 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); | 855 DCHECK(blacklist_state_ == BlacklistLoadState::LOAD_STARTED); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); | 1044 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); |
| 1045 | 1045 |
| 1046 is_profile_active_ = profile_became_active; | 1046 is_profile_active_ = profile_became_active; |
| 1047 } | 1047 } |
| 1048 #endif // !defined(OS_ANDROID) | 1048 #endif // !defined(OS_ANDROID) |
| 1049 | 1049 |
| 1050 void SupervisedUserService::OnSiteListUpdated() { | 1050 void SupervisedUserService::OnSiteListUpdated() { |
| 1051 FOR_EACH_OBSERVER( | 1051 FOR_EACH_OBSERVER( |
| 1052 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); | 1052 SupervisedUserServiceObserver, observer_list_, OnURLFilterChanged()); |
| 1053 } | 1053 } |
| OLD | NEW |