Index: chrome/browser/policy/device_management_policy_provider.cc |
diff --git a/chrome/browser/policy/device_management_policy_provider.cc b/chrome/browser/policy/device_management_policy_provider.cc |
index fbf36ce952650e50e923ec11880733bfbb4a6286..26407259fbe9a26317307902ae722a8c1cefcc80 100644 |
--- a/chrome/browser/policy/device_management_policy_provider.cc |
+++ b/chrome/browser/policy/device_management_policy_provider.cc |
@@ -10,6 +10,7 @@ |
#include "base/task.h" |
#include "base/time.h" |
#include "chrome/browser/browser_thread.h" |
+#include "chrome/browser/profile.h" |
#include "chrome/browser/policy/device_management_backend.h" |
#include "chrome/browser/policy/device_management_backend_impl.h" |
#include "chrome/browser/policy/device_management_policy_cache.h" |
@@ -56,12 +57,25 @@ class DeviceManagementPolicyProvider::InitializeAfterIOThreadExistsTask |
DeviceManagementPolicyProvider::DeviceManagementPolicyProvider( |
const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, |
DeviceManagementBackend* backend, |
- TokenService* token_service, |
- const FilePath& storage_dir) |
+ Profile* profile) |
: ConfigurationPolicyProvider(policy_list), |
backend_(backend), |
- token_service_(token_service), |
- storage_dir_(GetOrCreateDeviceManagementDir(storage_dir)), |
+ profile_(profile), |
+ storage_dir_(GetOrCreateDeviceManagementDir(profile_->GetPath())), |
+ policy_request_pending_(false) { |
+ Initialize(); |
+} |
+ |
+DeviceManagementPolicyProvider::DeviceManagementPolicyProvider( |
+ const ConfigurationPolicyProvider::PolicyDefinitionList* policy_list, |
+ DeviceManagementBackend* backend, |
+ Profile* profile, |
+ DeviceTokenFetcher* token_fetcher) |
+ : ConfigurationPolicyProvider(policy_list), |
+ backend_(backend), |
+ profile_(profile), |
+ token_fetcher_(token_fetcher), |
+ storage_dir_(GetOrCreateDeviceManagementDir(profile_->GetPath())), |
policy_request_pending_(false) { |
Initialize(); |
} |
@@ -106,7 +120,7 @@ void DeviceManagementPolicyProvider::OnError( |
} |
void DeviceManagementPolicyProvider::Shutdown() { |
- token_service_ = NULL; |
+ profile_ = NULL; |
if (token_fetcher_) |
token_fetcher_->Shutdown(); |
} |
@@ -138,9 +152,11 @@ void DeviceManagementPolicyProvider::Initialize() { |
void DeviceManagementPolicyProvider::InitializeAfterIOThreadExists() { |
const FilePath token_path = storage_dir_.Append( |
FILE_PATH_LITERAL("Token")); |
- if (token_service_) { |
- token_fetcher_ = |
- new DeviceTokenFetcher(GetBackend(), token_service_, token_path); |
+ if (profile_) { |
+ if (!token_fetcher_) { |
+ token_fetcher_ = |
+ new DeviceTokenFetcher(GetBackend(), profile_, token_path); |
+ } |
token_fetcher_->StartFetching(); |
} |
} |