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

Side by Side Diff: chrome/browser/policy/device_management_policy_provider.h

Issue 4960003: Don't register gmail users at the device management server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_
6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ 6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/weak_ptr.h" 13 #include "base/weak_ptr.h"
14 #include "chrome/browser/policy/configuration_policy_provider.h" 14 #include "chrome/browser/policy/configuration_policy_provider.h"
15 #include "chrome/browser/policy/device_management_backend.h" 15 #include "chrome/browser/policy/device_management_backend.h"
16 #include "chrome/common/notification_details.h" 16 #include "chrome/common/notification_details.h"
17 #include "chrome/common/notification_observer.h" 17 #include "chrome/common/notification_observer.h"
18 #include "chrome/common/notification_registrar.h" 18 #include "chrome/common/notification_registrar.h"
19 #include "chrome/common/notification_source.h" 19 #include "chrome/common/notification_source.h"
20 20
21 class Profile;
21 class TokenService; 22 class TokenService;
22 23
23 namespace policy { 24 namespace policy {
24 25
25 class DeviceManagementBackend; 26 class DeviceManagementBackend;
26 class DeviceManagementPolicyCache; 27 class DeviceManagementPolicyCache;
27 class DeviceTokenFetcher; 28 class DeviceTokenFetcher;
28 29
29 // Provides policy fetched from the device management server. With the exception 30 // Provides policy fetched from the device management server. With the exception
30 // of the Provide method, which can be called on the FILE thread, all public 31 // of the Provide method, which can be called on the FILE thread, all public
31 // methods must be called on the UI thread. 32 // methods must be called on the UI thread.
32 class DeviceManagementPolicyProvider 33 class DeviceManagementPolicyProvider
33 : public ConfigurationPolicyProvider, 34 : public ConfigurationPolicyProvider,
34 public NotificationObserver, 35 public NotificationObserver,
35 public DeviceManagementBackend::DevicePolicyResponseDelegate, 36 public DeviceManagementBackend::DevicePolicyResponseDelegate,
36 public base::SupportsWeakPtr<DeviceManagementPolicyProvider> { 37 public base::SupportsWeakPtr<DeviceManagementPolicyProvider> {
37 public: 38 public:
38 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list, 39 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list,
39 DeviceManagementBackend* backend, 40 DeviceManagementBackend* backend,
40 TokenService* token_service, 41 Profile* profile);
41 const FilePath& storage_dir);
42 42
43 virtual ~DeviceManagementPolicyProvider(); 43 virtual ~DeviceManagementPolicyProvider();
44 44
45 // ConfigurationPolicyProvider implementation: 45 // ConfigurationPolicyProvider implementation:
46 virtual bool Provide(ConfigurationPolicyStoreInterface* store); 46 virtual bool Provide(ConfigurationPolicyStoreInterface* store);
47 47
48 // NotificationObserver implementation: 48 // NotificationObserver implementation:
49 virtual void Observe(NotificationType type, 49 virtual void Observe(NotificationType type,
50 const NotificationSource& source, 50 const NotificationSource& source,
51 const NotificationDetails& details); 51 const NotificationDetails& details);
52 52
53 // DevicePolicyResponseDelegate implementation: 53 // DevicePolicyResponseDelegate implementation:
54 virtual void HandlePolicyResponse( 54 virtual void HandlePolicyResponse(
55 const em::DevicePolicyResponse& response); 55 const em::DevicePolicyResponse& response);
56 virtual void OnError(DeviceManagementBackend::ErrorCode code); 56 virtual void OnError(DeviceManagementBackend::ErrorCode code);
57 57
58 // True if a policy request has been sent to the device management backend 58 // True if a policy request has been sent to the device management backend
59 // server and no response or error has yet been received. 59 // server and no response or error has yet been received.
60 bool IsPolicyRequestPending() const { return policy_request_pending_; } 60 bool IsPolicyRequestPending() const { return policy_request_pending_; }
61 61
62 // Tells the provider that the passed in token service reference is about to 62 // Tells the provider that the passed in token service reference is about to
63 // become invalid. 63 // become invalid.
64 void Shutdown(); 64 void Shutdown();
65 65
66 private: 66 private:
67 friend class DeviceManagementPolicyProviderTest;
68
69 // Used only in tests.
70 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list,
71 DeviceManagementBackend* backend,
72 Profile* profile,
73 DeviceTokenFetcher* token_fetcher);
74
67 class InitializeAfterIOThreadExistsTask; 75 class InitializeAfterIOThreadExistsTask;
68 76
69 // Called by constructors to perform shared initialization. Initialization 77 // Called by constructors to perform shared initialization. Initialization
70 // requiring the IOThread must not be performed directly in this method, 78 // requiring the IOThread must not be performed directly in this method,
71 // rather must be deferred until the IOThread is fully initialized. This is 79 // rather must be deferred until the IOThread is fully initialized. This is
72 // the case in InitializeAfterIOThreadExists. 80 // the case in InitializeAfterIOThreadExists.
73 void Initialize(); 81 void Initialize();
74 82
75 // Called by a deferred task posted to the UI thread to complete the portion 83 // Called by a deferred task posted to the UI thread to complete the portion
76 // of initialization that requires the IOThread. 84 // of initialization that requires the IOThread.
(...skipping 10 matching lines...) Expand all
87 // Provides the URL at which requests are sent to from the device management 95 // Provides the URL at which requests are sent to from the device management
88 // backend. 96 // backend.
89 static std::string GetDeviceManagementURL(); 97 static std::string GetDeviceManagementURL();
90 98
91 // Returns the path to the sub-directory in the user data directory 99 // Returns the path to the sub-directory in the user data directory
92 // in which device management persistent state is stored. 100 // in which device management persistent state is stored.
93 static FilePath GetOrCreateDeviceManagementDir( 101 static FilePath GetOrCreateDeviceManagementDir(
94 const FilePath& user_data_dir); 102 const FilePath& user_data_dir);
95 103
96 scoped_ptr<DeviceManagementBackend> backend_; 104 scoped_ptr<DeviceManagementBackend> backend_;
97 TokenService* token_service_; // weak 105 Profile* profile_; // weak
98 scoped_ptr<DeviceManagementPolicyCache> cache_; 106 scoped_ptr<DeviceManagementPolicyCache> cache_;
99 scoped_refptr<DeviceTokenFetcher> token_fetcher_; 107 scoped_refptr<DeviceTokenFetcher> token_fetcher_;
100 NotificationRegistrar registrar_; 108 NotificationRegistrar registrar_;
101 FilePath storage_dir_; 109 FilePath storage_dir_;
102 bool policy_request_pending_; 110 bool policy_request_pending_;
103 111
104 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider); 112 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider);
105 }; 113 };
106 114
107 } // namespace policy 115 } // namespace policy
108 116
109 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ 117 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698