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

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

Issue 2860443002: Chromad: Create AuthPolicyCredentialsManager (Closed)
Patch Set: 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_
ljusten (tachyonic) 2017/05/03 10:12:17 Suggest to use 'authpolicy' instead of 'auth_polic
Roman Sorokin (ftl) 2017/05/19 12:13:48 Yes, we don't have consistency now. But it should
ljusten (tachyonic) 2017/05/19 16:06:13 Meh. I'd rather rename the classes Authpolicy* tha
Roman Sorokin (ftl) 2017/05/22 12:35:27 Acknowledged.
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
ljusten (tachyonic) 2017/05/03 10:12:17 Please add class-level comment.
Roman Sorokin (ftl) 2017/05/19 12:13:48 Done.
28 class AuthPolicyCredentialsManager
29 : public KeyedService,
30 public chromeos::NetworkStateHandlerObserver {
31 public:
32 explicit AuthPolicyCredentialsManager(Profile* profile);
33 ~AuthPolicyCredentialsManager() override;
34
35 // KeyedService overrides.
36 void Shutdown() override;
37
38 // chromeos::NetworkStateHandlerObserver overrides.
39 void DefaultNetworkChanged(const chromeos::NetworkState* network) override;
40 void NetworkConnectionStateChanged(
41 const chromeos::NetworkState* network) override;
42 void OnShuttingDown() override;
43
44 private:
45 // Calls AuthPolicyClient::GetUserStatus method.
46 void GetUserStatus();
47 // See AuthPolicyClient::GetUserStatusCallback.
48 void OnGetUserStatusCallback(
49 authpolicy::ErrorType error,
50 const authpolicy::ActiveDirectoryUserStatus& user_status);
51 // Post delayed task to call GetUserStatus in the future.
52 void ScheduleGetUserStatus();
53
54 // Add itself as network observer.
55 void StartObserveNetwork();
56 // Remove itself as network observer.
57 void StopObserveNetwork();
58
59 // Update display and given name in case it has changed.
60 void UpdateDisplayAndGivenName(
61 const authpolicy::ActiveDirectoryAccountInfo& account_info);
62
63 // Shows user notification to sign out/sign in.
64 void ShowNotification(int message_id) const;
65
66 // Call GetUserStatus if |network_state| is connected and previous call
67 // failed.
ljusten (tachyonic) 2017/05/03 10:12:17 The comment contradicts the implementation. It cal
Roman Sorokin (ftl) 2017/05/19 12:13:48 Done.
68 void CallGetStatusIfConnected(const chromeos::NetworkState* network_state);
ljusten (tachyonic) 2017/05/03 10:12:17 CallGetUserStatusIfConnected?
Roman Sorokin (ftl) 2017/05/19 12:13:48 Done.
69
70 Profile* profile_;
71 AccountId account_id_;
72 std::string display_name_, given_name_;
73 bool should_call_get_status_again_ = false;
74 authpolicy::ErrorType last_error_ = authpolicy::ERROR_UNKNOWN;
ljusten (tachyonic) 2017/05/03 10:12:17 ERROR_NONE? ERROR_UNKNOWN is an actual error, defa
Roman Sorokin (ftl) 2017/05/19 12:13:48 Not sure about it. Could be the case when network
ljusten (tachyonic) 2017/05/19 16:06:13 With what we discussed offline, this case will be
Roman Sorokin (ftl) 2017/05/22 12:35:27 Done.
75 base::CancelableClosure scheduled_get_user_status_call_;
76
77 base::WeakPtrFactory<AuthPolicyCredentialsManager> weak_factory_;
78 DISALLOW_COPY_AND_ASSIGN(AuthPolicyCredentialsManager);
79 };
80
ljusten (tachyonic) 2017/05/03 10:12:17 Please add class-level comment.
Roman Sorokin (ftl) 2017/05/19 12:13:48 Done.
81 class AuthPolicyCredentialsManagerFactory
82 : public BrowserContextKeyedServiceFactory {
83 public:
84 static AuthPolicyCredentialsManagerFactory* GetInstance();
85
86 static void BuildForProfileIfActiveDirectory(Profile* profile);
87
88 private:
89 friend struct base::DefaultSingletonTraits<
90 AuthPolicyCredentialsManagerFactory>;
91
92 AuthPolicyCredentialsManagerFactory();
93 ~AuthPolicyCredentialsManagerFactory() override;
94
95 KeyedService* BuildServiceInstanceFor(
96 content::BrowserContext* context) const override;
97
98 DISALLOW_COPY_AND_ASSIGN(AuthPolicyCredentialsManagerFactory);
99 };
100
101 #endif // CHROME_BROWSER_CHROMEOS_AUTHPOLICY_AUTH_POLICY_CREDENTIALS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698