blob: 93995c8ae96674b3f275f8dda517976493e9621b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_
#define CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_
#pragma once
#include <string>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
class PrefService;
class TestingBrowserProcess;
class TokenService;
namespace net {
class URLRequestContextGetter;
}
namespace policy {
class CloudPolicySubsystem;
class ConfigurationPolicyProvider;
class DevicePolicyIdentityStrategy;
// Manages the lifecycle of browser-global policy infrastructure, such as the
// platform policy providers.
class BrowserPolicyConnector : public NotificationObserver {
public:
static const int kDefaultPolicyRefreshRateInMilliseconds =
3 * 60 * 60 * 1000; // 3 hours.
BrowserPolicyConnector();
~BrowserPolicyConnector();
ConfigurationPolicyProvider* GetManagedPlatformProvider() const;
ConfigurationPolicyProvider* GetManagedCloudProvider() const;
ConfigurationPolicyProvider* GetRecommendedPlatformProvider() const;
ConfigurationPolicyProvider* GetRecommendedCloudProvider() const;
// Returns a weak pointer to the CloudPolicySubsystem managed by this
// policy connector, or NULL if no such subsystem exists (i.e. when running
// outside ChromeOS).
CloudPolicySubsystem* cloud_policy_subsystem() {
return cloud_policy_subsystem_.get();
}
static void RegisterPrefs(PrefService* user_prefs);
// Used to set the credentials stored in the identity strategy associated
// with this policy connector.
void SetCredentials(const std::string& owner_email,
const std::string& gaia_token,
const std::string& machine_id);
// Returns true if this device is managed by an enterprise (as opposed to
// a local owner).
bool IsEnterpriseManaged();
// Exposes the StopAutoRetry() method of the CloudPolicySubsystem managed
// by this connector, which can be used to disable automatic
// retrying behavior.
void StopAutoRetry();
// NotificationObserver implementation:
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
private:
friend class ::TestingBrowserProcess;
static ConfigurationPolicyProvider* CreateManagedPlatformProvider();
static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider();
// Constructor for tests that allows tests to use fake platform policy
// providers instead of using the actual ones.
BrowserPolicyConnector(
ConfigurationPolicyProvider* managed_platform_provider,
ConfigurationPolicyProvider* recommended_platform_provider);
// Activates the cloud policy subsystem. Called when the default request
// context is available.
void Initialize(PrefService* local_state,
net::URLRequestContextGetter* request_context);
scoped_ptr<ConfigurationPolicyProvider> managed_platform_provider_;
scoped_ptr<ConfigurationPolicyProvider> recommended_platform_provider_;
#if defined(OS_CHROMEOS)
scoped_ptr<DevicePolicyIdentityStrategy> identity_strategy_;
#endif
scoped_ptr<CloudPolicySubsystem> cloud_policy_subsystem_;
NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector);
};
} // namespace policy
#endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_
|