OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_STATUS_SERVICE_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_STATUS_SERVICE_H_ |
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_STATUS_SERVICE_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_STATUS_SERVICE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // Starts listening for changes from the dependencies. |callback| will be | 45 // Starts listening for changes from the dependencies. |callback| will be |
46 // called when a significant change in state is detected. | 46 // called when a significant change in state is detected. |
47 void Init(const StatusChangeCallback& callback); | 47 void Init(const StatusChangeCallback& callback); |
48 | 48 |
49 // To be called when the signin state changed. Will compute the new | 49 // To be called when the signin state changed. Will compute the new |
50 // state considering the initialisation configuration and the preferences, | 50 // state considering the initialisation configuration and the preferences, |
51 // and notify via the registered callback if appropriate. | 51 // and notify via the registered callback if appropriate. |
52 void OnSignInStateChanged(); | 52 void OnSignInStateChanged(); |
53 | 53 |
54 private: | 54 private: |
| 55 // TODO(jkrcal): Rewrite the tests using the public API - observing status |
| 56 // changes instead of calling private GetStatusFromDeps() directly. |
| 57 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsStatusServiceTest, |
| 58 SigninNeededIfSpecifiedByParam); |
| 59 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsStatusServiceTest, NoSigninNeeded); |
55 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsStatusServiceTest, DisabledViaPref); | 60 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsStatusServiceTest, DisabledViaPref); |
56 | 61 |
57 // Callback for the PrefChangeRegistrar. | 62 // Callback for the PrefChangeRegistrar. |
58 void OnSnippetsEnabledChanged(); | 63 void OnSnippetsEnabledChanged(); |
59 | 64 |
60 void OnStateChanged(RemoteSuggestionsStatus new_status); | 65 void OnStateChanged(RemoteSuggestionsStatus new_status); |
61 | 66 |
62 bool IsSignedIn() const; | 67 bool IsSignedIn() const; |
63 | 68 |
64 RemoteSuggestionsStatus GetStatusFromDeps() const; | 69 RemoteSuggestionsStatus GetStatusFromDeps() const; |
65 | 70 |
66 RemoteSuggestionsStatus status_; | 71 RemoteSuggestionsStatus status_; |
67 StatusChangeCallback status_change_callback_; | 72 StatusChangeCallback status_change_callback_; |
68 | 73 |
69 bool require_signin_; | 74 bool require_signin_; |
70 SigninManagerBase* signin_manager_; | 75 SigninManagerBase* signin_manager_; |
71 PrefService* pref_service_; | 76 PrefService* pref_service_; |
72 | 77 |
73 PrefChangeRegistrar pref_change_registrar_; | 78 PrefChangeRegistrar pref_change_registrar_; |
74 | 79 |
75 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsStatusService); | 80 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsStatusService); |
76 }; | 81 }; |
77 | 82 |
78 } // namespace ntp_snippets | 83 } // namespace ntp_snippets |
79 | 84 |
80 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_STATUS_SERVICE_H_ | 85 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_STATUS_SERVICE_H_ |
OLD | NEW |