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

Unified Diff: chrome/browser/profile_impl.cc

Issue 5153002: Use a service to create device management backends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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/profile_impl.cc
diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc
index 8b62962ee07cfb12dc35cca2d93259779650d27c..baaa07552617b354f851e0bfef783f8144baa4f7 100644
--- a/chrome/browser/profile_impl.cc
+++ b/chrome/browser/profile_impl.cc
@@ -56,7 +56,7 @@
#include "chrome/browser/password_manager/password_store_default.h"
#include "chrome/browser/policy/configuration_policy_provider.h"
#include "chrome/browser/policy/configuration_policy_pref_store.h"
-#include "chrome/browser/policy/device_management_backend_impl.h"
+#include "chrome/browser/policy/device_management_service.h"
#include "chrome/browser/policy/device_management_policy_provider.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_value_store.h"
@@ -355,6 +355,11 @@ ProfileImpl::ProfileImpl(const FilePath& path)
extension_info_map_ = new ExtensionInfoMap();
+ policy::DeviceManagementService* device_management_service =
+ GetDeviceManagementService();
+ if (device_management_service)
+ device_management_service->Initialize(GetRequestContext());
+
// Log the profile size after a reasonable startup delay.
BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE,
new ProfileSizeTask(path_), 112000);
@@ -489,6 +494,9 @@ ProfileImpl::~ProfileImpl() {
Source<Profile>(this),
NotificationService::NoDetails());
+ if (device_management_service_.get())
+ device_management_service_->Shutdown();
+
tab_restore_service_ = NULL;
StopCreateSessionServiceTimer();
@@ -1319,10 +1327,25 @@ ExtensionInfoMap* ProfileImpl::GetExtensionInfoMap() {
return extension_info_map_.get();
}
+policy::DeviceManagementService*
+ProfileImpl::GetDeviceManagementService() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (device_management_service_.get())
+ return device_management_service_.get();
+
+ if (!command_line->HasSwitch(switches::kDeviceManagementUrl));
+ return NULL;
+
+ device_management_service_.reset(
+ new policy::DeviceManagementService(
+ command_line->GetSwitchValueASCII(switches::kDeviceManagementUrl)));
+ return device_management_service_.get();
+}
+
policy::DeviceManagementPolicyProvider*
ProfileImpl::GetDeviceManagementPolicyProvider() {
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (!command_line->HasSwitch(switches::kDeviceManagementUrl))
+ policy::DeviceManagementService* service = GetDeviceManagementService();
+ if (!service)
return NULL;
if (!device_management_policy_provider_.get()) {
@@ -1330,9 +1353,7 @@ ProfileImpl::GetDeviceManagementPolicyProvider() {
new policy::DeviceManagementPolicyProvider(
policy::ConfigurationPolicyPrefStore::
GetChromePolicyDefinitionList(),
- new policy::DeviceManagementBackendImpl(
- command_line->GetSwitchValueASCII(
- switches::kDeviceManagementUrl)),
+ service->CreateBackend(),
GetTokenService(),
GetPath()));
}

Powered by Google App Engine
This is Rietveld 408576698