OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H_ |
6 #define CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/observer_list.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
16 #include "chrome/browser/supervised_user/child_accounts/family_info_fetcher.h" | 17 #include "chrome/browser/supervised_user/child_accounts/family_info_fetcher.h" |
| 18 #include "chrome/browser/supervised_user/child_accounts/flags_fetching_observer.
h" |
17 #include "chrome/browser/supervised_user/supervised_user_service.h" | 19 #include "chrome/browser/supervised_user/supervised_user_service.h" |
18 #include "components/keyed_service/core/keyed_service.h" | 20 #include "components/keyed_service/core/keyed_service.h" |
19 #include "components/signin/core/browser/account_service_flag_fetcher.h" | 21 #include "components/signin/core/browser/account_service_flag_fetcher.h" |
20 #include "components/signin/core/browser/signin_manager_base.h" | 22 #include "components/signin/core/browser/signin_manager_base.h" |
21 #include "net/base/backoff_entry.h" | 23 #include "net/base/backoff_entry.h" |
22 | 24 |
23 namespace base { | 25 namespace base { |
24 class FilePath; | 26 class FilePath; |
25 } | 27 } |
26 | 28 |
(...skipping 12 matching lines...) Expand all Loading... |
39 void Init(); | 41 void Init(); |
40 | 42 |
41 // Sets whether the signed-in account is a child account. | 43 // Sets whether the signed-in account is a child account. |
42 // Public so it can be called on platforms where child account detection | 44 // Public so it can be called on platforms where child account detection |
43 // happens outside of this class (like Android). | 45 // happens outside of this class (like Android). |
44 void SetIsChildAccount(bool is_child_account); | 46 void SetIsChildAccount(bool is_child_account); |
45 | 47 |
46 // KeyedService: | 48 // KeyedService: |
47 void Shutdown() override; | 49 void Shutdown() override; |
48 | 50 |
| 51 // Adds/removes observer. |
| 52 void AddFlagFetchingObserver(FlagsFetchingObserver* observer); |
| 53 void RemoveFlagFetchingObserver(FlagsFetchingObserver* observer); |
| 54 |
49 private: | 55 private: |
50 friend class ChildAccountServiceFactory; | 56 friend class ChildAccountServiceFactory; |
51 // Use |ChildAccountServiceFactory::GetForProfile(...)| to get an instance of | 57 // Use |ChildAccountServiceFactory::GetForProfile(...)| to get an instance of |
52 // this service. | 58 // this service. |
53 explicit ChildAccountService(Profile* profile); | 59 explicit ChildAccountService(Profile* profile); |
54 | 60 |
55 // SupervisedUserService::Delegate implementation. | 61 // SupervisedUserService::Delegate implementation. |
56 bool SetActive(bool active) override; | 62 bool SetActive(bool active) override; |
57 base::FilePath GetBlacklistPath() const override; | 63 base::FilePath GetBlacklistPath() const override; |
58 GURL GetBlacklistURL() const override; | 64 GURL GetBlacklistURL() const override; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 scoped_ptr<AccountServiceFlagFetcher> flag_fetcher_; | 108 scoped_ptr<AccountServiceFlagFetcher> flag_fetcher_; |
103 // If fetching the account service flag fails, retry with exponential backoff. | 109 // If fetching the account service flag fails, retry with exponential backoff. |
104 base::OneShotTimer<ChildAccountService> flag_fetch_timer_; | 110 base::OneShotTimer<ChildAccountService> flag_fetch_timer_; |
105 net::BackoffEntry flag_fetch_backoff_; | 111 net::BackoffEntry flag_fetch_backoff_; |
106 | 112 |
107 scoped_ptr<FamilyInfoFetcher> family_fetcher_; | 113 scoped_ptr<FamilyInfoFetcher> family_fetcher_; |
108 // If fetching the family info fails, retry with exponential backoff. | 114 // If fetching the family info fails, retry with exponential backoff. |
109 base::OneShotTimer<ChildAccountService> family_fetch_timer_; | 115 base::OneShotTimer<ChildAccountService> family_fetch_timer_; |
110 net::BackoffEntry family_fetch_backoff_; | 116 net::BackoffEntry family_fetch_backoff_; |
111 | 117 |
| 118 ObserverList<FlagsFetchingObserver> observer_list_; |
| 119 |
112 base::WeakPtrFactory<ChildAccountService> weak_ptr_factory_; | 120 base::WeakPtrFactory<ChildAccountService> weak_ptr_factory_; |
113 | 121 |
114 DISALLOW_COPY_AND_ASSIGN(ChildAccountService); | 122 DISALLOW_COPY_AND_ASSIGN(ChildAccountService); |
115 }; | 123 }; |
116 | 124 |
117 #endif // CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H
_ | 125 #endif // CHROME_BROWSER_SUPERVISED_USER_CHILD_ACCOUNTS_CHILD_ACCOUNT_SERVICE_H
_ |
OLD | NEW |