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

Side by Side Diff: chrome/browser/supervised_user/child_accounts/child_account_service.h

Issue 783083002: Add support for child accounts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove CrOS for now Created 6 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
OLDNEW
(Empty)
1 // Copyright 2014 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_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/supervised_user/child_accounts/family_info_fetcher.h"
15 #include "chrome/browser/supervised_user/supervised_user_service.h"
16 #include "components/keyed_service/core/keyed_service.h"
17 #include "components/signin/core/browser/account_service_flag_fetcher.h"
18 #include "components/signin/core/browser/signin_manager_base.h"
19
20 namespace base {
21 class FilePath;
22 }
23
24 class Profile;
25
26 // This class handles detection of child accounts (on sign-in as well as on
27 // browser restart), and triggers the appropriate behavior (e.g. enable the
28 // supervised user experience, fetch information about the parent(s)).
29 class ChildAccountService : public KeyedService,
30 public FamilyInfoFetcher::Consumer,
31 public SigninManagerBase::Observer,
32 public SupervisedUserService::Delegate {
33 public:
34 virtual ~ChildAccountService();
35
36 void Init();
37
38 // KeyedService:
39 virtual void Shutdown() override;
40
41 private:
42 friend class ChildAccountServiceFactory;
43 // Use |ChildAccountServiceFactory::GetForProfile(...)| to get an instance of
44 // this service.
45 explicit ChildAccountService(Profile* profile);
46
47 // SupervisedUserService::Delegate implementation.
48 virtual bool SetActive(bool active) override;
49 virtual bool IsChildAccount() const override;
50 virtual base::FilePath GetBlacklistPath() const override;
51 virtual GURL GetBlacklistURL() const override;
52 virtual std::string GetSafeSitesCx() const override;
53
54 // SigninManagerBase::Observer implementation.
55 virtual void GoogleSigninSucceeded(const std::string& account_id,
56 const std::string& username,
57 const std::string& password) override;
58 virtual void GoogleSignedOut(const std::string& account_id,
59 const std::string& username) override;
60
61 // FamilyInfoFetcher::Consumer implementation.
62 virtual void OnGetFamilyMembersSuccess(
63 const std::vector<FamilyInfoFetcher::FamilyMember>& members) override;
64 virtual void OnFailure(FamilyInfoFetcher::ErrorCode error) override;
65
66 void StartFetchingServiceFlags(const std::string& account_id);
67 void CancelFetchingServiceFlags();
68 void OnFlagsFetched(AccountServiceFlagFetcher::ResultCode,
69 const std::vector<std::string>& flags);
70
71 void SetIsChildAccount(bool is_child_account);
72
73 void PropagateChildStatusToUser(bool is_child);
74
75 // Owns us via the KeyedService mechanism.
76 Profile* profile_;
77
78 bool active_;
79
80 // The user for which we are currently trying to fetch the child account flag.
81 // Empty when we are not currently fetching.
82 std::string account_id_;
83
84 scoped_ptr<AccountServiceFlagFetcher> flag_fetcher_;
85
86 scoped_ptr<FamilyInfoFetcher> family_fetcher_;
87
88 base::WeakPtrFactory<ChildAccountService> weak_ptr_factory_;
89
90 DISALLOW_COPY_AND_ASSIGN(ChildAccountService);
91 };
92
93 #endif // CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698