| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/policy/profile_policy_connector_factory.h" | 5 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/policy/profile_policy_connector.h" | 8 #include "chrome/browser/policy/profile_policy_connector.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 ProfilePolicyConnector* ProfilePolicyConnectorFactory::GetForProfile( | 31 ProfilePolicyConnector* ProfilePolicyConnectorFactory::GetForProfile( |
| 32 Profile* profile) { | 32 Profile* profile) { |
| 33 return GetInstance()->GetForProfileInternal(profile); | 33 return GetInstance()->GetForProfileInternal(profile); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 scoped_ptr<ProfilePolicyConnector> | 37 scoped_ptr<ProfilePolicyConnector> |
| 38 ProfilePolicyConnectorFactory::CreateForProfile( | 38 ProfilePolicyConnectorFactory::CreateForProfile( |
| 39 Profile* profile, | 39 Profile* profile, |
| 40 bool force_immediate_load, | 40 bool force_immediate_load, |
| 41 CloudPolicyManager* user_cloud_policy_manager, |
| 41 base::SequencedTaskRunner* sequenced_task_runner) { | 42 base::SequencedTaskRunner* sequenced_task_runner) { |
| 42 return GetInstance()->CreateForProfileInternal( | 43 return GetInstance()->CreateForProfileInternal(profile, |
| 43 profile, force_immediate_load, sequenced_task_runner); | 44 force_immediate_load, |
| 45 user_cloud_policy_manager, |
| 46 sequenced_task_runner); |
| 44 } | 47 } |
| 45 | 48 |
| 46 void ProfilePolicyConnectorFactory::SetServiceForTesting( | 49 void ProfilePolicyConnectorFactory::SetServiceForTesting( |
| 47 Profile* profile, | 50 Profile* profile, |
| 48 ProfilePolicyConnector* connector) { | 51 ProfilePolicyConnector* connector) { |
| 49 ProfilePolicyConnector*& map_entry = connectors_[profile]; | 52 ProfilePolicyConnector*& map_entry = connectors_[profile]; |
| 50 CHECK(!map_entry); | 53 CHECK(!map_entry); |
| 51 map_entry = connector; | 54 map_entry = connector; |
| 52 } | 55 } |
| 53 | 56 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 75 ConnectorMap::const_iterator it = | 78 ConnectorMap::const_iterator it = |
| 76 connectors_.find(profile->GetOriginalProfile()); | 79 connectors_.find(profile->GetOriginalProfile()); |
| 77 CHECK(it != connectors_.end()); | 80 CHECK(it != connectors_.end()); |
| 78 return it->second; | 81 return it->second; |
| 79 } | 82 } |
| 80 | 83 |
| 81 scoped_ptr<ProfilePolicyConnector> | 84 scoped_ptr<ProfilePolicyConnector> |
| 82 ProfilePolicyConnectorFactory::CreateForProfileInternal( | 85 ProfilePolicyConnectorFactory::CreateForProfileInternal( |
| 83 Profile* profile, | 86 Profile* profile, |
| 84 bool force_immediate_load, | 87 bool force_immediate_load, |
| 88 CloudPolicyManager* user_cloud_policy_manager, |
| 85 base::SequencedTaskRunner* sequenced_task_runner) { | 89 base::SequencedTaskRunner* sequenced_task_runner) { |
| 86 DCHECK(connectors_.find(profile) == connectors_.end()); | 90 DCHECK(connectors_.find(profile) == connectors_.end()); |
| 87 ProfilePolicyConnector* connector = new ProfilePolicyConnector(profile); | 91 ProfilePolicyConnector* connector = new ProfilePolicyConnector(); |
| 88 connector->Init(force_immediate_load, sequenced_task_runner); | 92 connector->Init(force_immediate_load, |
| 93 user_cloud_policy_manager, |
| 94 profile, |
| 95 sequenced_task_runner); |
| 89 connectors_[profile] = connector; | 96 connectors_[profile] = connector; |
| 90 return scoped_ptr<ProfilePolicyConnector>(connector); | 97 return make_scoped_ptr(connector); |
| 91 } | 98 } |
| 92 | 99 |
| 93 void ProfilePolicyConnectorFactory::BrowserContextShutdown( | 100 void ProfilePolicyConnectorFactory::BrowserContextShutdown( |
| 94 content::BrowserContext* context) { | 101 content::BrowserContext* context) { |
| 95 Profile* profile = static_cast<Profile*>(context); | 102 Profile* profile = static_cast<Profile*>(context); |
| 96 if (profile->IsOffTheRecord()) | 103 if (profile->IsOffTheRecord()) |
| 97 return; | 104 return; |
| 98 ConnectorMap::iterator it = connectors_.find(profile); | 105 ConnectorMap::iterator it = connectors_.find(profile); |
| 99 if (it != connectors_.end()) | 106 if (it != connectors_.end()) |
| 100 it->second->Shutdown(); | 107 it->second->Shutdown(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 123 #endif | 130 #endif |
| 124 } | 131 } |
| 125 | 132 |
| 126 void ProfilePolicyConnectorFactory::SetEmptyTestingFactory( | 133 void ProfilePolicyConnectorFactory::SetEmptyTestingFactory( |
| 127 content::BrowserContext* context) {} | 134 content::BrowserContext* context) {} |
| 128 | 135 |
| 129 void ProfilePolicyConnectorFactory::CreateServiceNow( | 136 void ProfilePolicyConnectorFactory::CreateServiceNow( |
| 130 content::BrowserContext* context) {} | 137 content::BrowserContext* context) {} |
| 131 | 138 |
| 132 } // namespace policy | 139 } // namespace policy |
| OLD | NEW |