Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1675)

Unified Diff: chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc

Issue 52343002: policy: Register OffTheRecordProfile at UserCloudPolicyManagerFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc
diff --git a/chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc b/chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc
index 02793284461a164b8911409468ea4ab334a0b327..3ac8cb2ad66241a0ff0a3043d69666fc5de20381 100644
--- a/chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc
+++ b/chrome/browser/policy/cloud/user_cloud_policy_manager_factory.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/policy/cloud/user_cloud_policy_store.h"
#include "chrome/browser/profiles/profile.h"
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
+#include "content/public/browser/browser_context.h"
namespace policy {
@@ -28,14 +29,24 @@ UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetForProfile(
// static
scoped_ptr<UserCloudPolicyManager>
-UserCloudPolicyManagerFactory::CreateForProfile(
+UserCloudPolicyManagerFactory::CreateForOriginalProfile(
Profile* profile,
bool force_immediate_load,
scoped_refptr<base::SequencedTaskRunner> background_task_runner) {
- return GetInstance()->CreateManagerForProfile(
+ return GetInstance()->CreateManagerForOriginalProfile(
profile, force_immediate_load, background_task_runner);
}
+// static
+UserCloudPolicyManager*
+UserCloudPolicyManagerFactory::RegisterForOffTheRecordProfile(
+ Profile* original_profile,
+ Profile* off_the_record_profile) {
+ return GetInstance()->RegisterManagerForOffTheRecordProfile(
+ original_profile, off_the_record_profile);
+}
+
+
UserCloudPolicyManagerFactory::UserCloudPolicyManagerFactory()
: BrowserContextKeyedBaseFactory(
"UserCloudPolicyManager",
@@ -44,18 +55,18 @@ UserCloudPolicyManagerFactory::UserCloudPolicyManagerFactory()
UserCloudPolicyManagerFactory::~UserCloudPolicyManagerFactory() {}
UserCloudPolicyManager* UserCloudPolicyManagerFactory::GetManagerForProfile(
- Profile* profile) {
+ content::BrowserContext* context) {
// Get the manager for the original profile, since the PolicyService is
// also shared between the incognito Profile and the original Profile.
Joao da Silva 2013/11/04 09:53:38 Update this comment.
pneubeck (no reviews) 2013/11/04 12:38:50 Done.
- ManagerMap::const_iterator it = managers_.find(profile->GetOriginalProfile());
+ ManagerMap::const_iterator it = managers_.find(context);
return it != managers_.end() ? it->second : NULL;
}
scoped_ptr<UserCloudPolicyManager>
- UserCloudPolicyManagerFactory::CreateManagerForProfile(
- Profile* profile,
- bool force_immediate_load,
- scoped_refptr<base::SequencedTaskRunner> background_task_runner) {
+UserCloudPolicyManagerFactory::CreateManagerForOriginalProfile(
+ Profile* profile,
+ bool force_immediate_load,
+ scoped_refptr<base::SequencedTaskRunner> background_task_runner) {
scoped_ptr<UserCloudPolicyStore> store(
UserCloudPolicyStore::Create(profile, background_task_runner));
if (force_immediate_load)
@@ -69,35 +80,43 @@ scoped_ptr<UserCloudPolicyManager>
return manager.Pass();
}
+UserCloudPolicyManager*
+UserCloudPolicyManagerFactory::RegisterManagerForOffTheRecordProfile(
+ Profile* original_profile,
+ Profile* off_the_record_profile) {
+ UserCloudPolicyManager* manager = GetManagerForProfile(original_profile);
+ Register(off_the_record_profile, manager);
+ return manager;
+}
+
void UserCloudPolicyManagerFactory::BrowserContextShutdown(
content::BrowserContext* context) {
- Profile* profile = static_cast<Profile*>(context);
- if (profile->IsOffTheRecord())
+ if (context->IsOffTheRecord())
return;
- UserCloudPolicyManager* manager = GetManagerForProfile(profile);
+ UserCloudPolicyManager* manager = GetManagerForProfile(context);
if (manager)
manager->Shutdown();
}
void UserCloudPolicyManagerFactory::SetEmptyTestingFactory(
- content::BrowserContext* profile) {
+ content::BrowserContext* context) {
}
void UserCloudPolicyManagerFactory::CreateServiceNow(
- content::BrowserContext* profile) {
+ content::BrowserContext* context) {
}
-void UserCloudPolicyManagerFactory::Register(Profile* profile,
+void UserCloudPolicyManagerFactory::Register(content::BrowserContext* context,
UserCloudPolicyManager* instance) {
- UserCloudPolicyManager*& entry = managers_[profile];
+ UserCloudPolicyManager*& entry = managers_[context];
DCHECK(!entry);
entry = instance;
}
void UserCloudPolicyManagerFactory::Unregister(
- Profile* profile,
+ content::BrowserContext* context,
UserCloudPolicyManager* instance) {
- ManagerMap::iterator entry = managers_.find(profile);
+ ManagerMap::iterator entry = managers_.find(context);
if (entry != managers_.end()) {
DCHECK_EQ(instance, entry->second);
managers_.erase(entry);

Powered by Google App Engine
This is Rietveld 408576698