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

Side by Side Diff: chrome/browser/chromeos/authpolicy/auth_policy_credentials_manager.h

Issue 2860443002: Chromad: Create AuthPolicyCredentialsManager (Closed)
Patch Set: Rebase, Update after review Created 3 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_AUTHPOLICY_AUTH_POLICY_CREDENTIALS_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_AUTHPOLICY_AUTH_POLICY_CREDENTIALS_MANAGER_H_
7
8 #include "base/cancelable_callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chromeos/dbus/authpolicy/active_directory_info.pb.h"
11 #include "chromeos/network/network_state_handler_observer.h"
12 #include "components/keyed_service/content/browser_context_keyed_service_factory .h"
13 #include "components/keyed_service/core/keyed_service.h"
14 #include "components/signin/core/account_id/account_id.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h"
16
17 class Profile;
18
19 namespace authpolicy {
20 class ActiveDirectoryUserStatus;
21 }
22
23 namespace base {
24 template <typename T>
25 struct DefaultSingletonTraits;
26 } // namespace base
27
28 // A service responsible to track user credential status. Created for each
ljusten (tachyonic) 2017/05/19 16:06:13 "for tracking" - "to" can only be used with a pers
Roman Sorokin (ftl) 2017/05/22 12:35:27 Done.
29 // Active Directory user profile.
30 class AuthPolicyCredentialsManager
31 : public KeyedService,
32 public chromeos::NetworkStateHandlerObserver {
33 public:
34 explicit AuthPolicyCredentialsManager(Profile* profile);
35 ~AuthPolicyCredentialsManager() override;
36
37 // KeyedService overrides.
38 void Shutdown() override;
39
40 // chromeos::NetworkStateHandlerObserver overrides.
41 void DefaultNetworkChanged(const chromeos::NetworkState* network) override;
42 void NetworkConnectionStateChanged(
43 const chromeos::NetworkState* network) override;
44 void OnShuttingDown() override;
45
46 private:
47 // Calls AuthPolicyClient::GetUserStatus method.
48 void GetUserStatus();
49 // See AuthPolicyClient::GetUserStatusCallback.
50 void OnGetUserStatusCallback(
51 authpolicy::ErrorType error,
52 const authpolicy::ActiveDirectoryUserStatus& user_status);
53 // Post delayed task to call GetUserStatus in the future.
54 void ScheduleGetUserStatus();
55
56 // Add itself as network observer.
57 void StartObserveNetwork();
58 // Remove itself as network observer.
59 void StopObserveNetwork();
60
61 // Update display and given name in case it has changed.
62 void UpdateDisplayAndGivenName(
63 const authpolicy::ActiveDirectoryAccountInfo& account_info);
64
65 // Shows user notification to sign out/sign in.
66 void ShowNotification(int message_id) const;
67
68 // Call GetUserStatus if |network_state| is connected and previous call
ljusten (tachyonic) 2017/05/19 16:06:13 *the* previous call
Roman Sorokin (ftl) 2017/05/22 12:35:27 Done.
69 // failed.
70 void GetUserStatusIfConnected(const chromeos::NetworkState* network_state);
71
72 Profile* profile_;
73 AccountId account_id_;
74 std::string display_name_, given_name_;
75 bool should_call_get_status_again_ = false;
76 authpolicy::ErrorType last_error_ = authpolicy::ERROR_UNKNOWN;
77 base::CancelableClosure scheduled_get_user_status_call_;
78
79 base::WeakPtrFactory<AuthPolicyCredentialsManager> weak_factory_;
80 DISALLOW_COPY_AND_ASSIGN(AuthPolicyCredentialsManager);
81 };
82
83 // Singleton that owns all AuthPolicyCredentialsManagers and associates them
84 // with BrowserContexts.
85 class AuthPolicyCredentialsManagerFactory
86 : public BrowserContextKeyedServiceFactory {
87 public:
88 static AuthPolicyCredentialsManagerFactory* GetInstance();
89
90 static void BuildForProfileIfActiveDirectory(Profile* profile);
91
92 private:
93 friend struct base::DefaultSingletonTraits<
94 AuthPolicyCredentialsManagerFactory>;
95
96 AuthPolicyCredentialsManagerFactory();
97 ~AuthPolicyCredentialsManagerFactory() override;
98
99 KeyedService* BuildServiceInstanceFor(
100 content::BrowserContext* context) const override;
101
102 DISALLOW_COPY_AND_ASSIGN(AuthPolicyCredentialsManagerFactory);
103 };
104
105 #endif // CHROME_BROWSER_CHROMEOS_AUTHPOLICY_AUTH_POLICY_CREDENTIALS_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/BUILD.gn ('k') | chrome/browser/chromeos/authpolicy/auth_policy_credentials_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698