| 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_NTP_SNIPPETS_STATUS_SERVICE_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_STATUS_SERVICE_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_STATUS_SERVICE_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_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 SnippetsStatusChangeCallback& callback); | 47 void Init(const SnippetsStatusChangeCallback& 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 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsStatusServiceTest, |
| 56 SigninStateCompatibility); |
| 55 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsStatusServiceTest, DisabledViaPref); | 57 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsStatusServiceTest, DisabledViaPref); |
| 56 | 58 |
| 57 // Callback for the PrefChangeRegistrar. | 59 // Callback for the PrefChangeRegistrar. |
| 58 void OnSnippetsEnabledChanged(); | 60 void OnSnippetsEnabledChanged(); |
| 59 | 61 |
| 60 void OnStateChanged(SnippetsStatus new_snippets_status); | 62 void OnStateChanged(SnippetsStatus new_snippets_status); |
| 61 | 63 |
| 62 bool IsSignedIn() const; | 64 bool IsSignedIn() const; |
| 63 | 65 |
| 64 SnippetsStatus GetSnippetsStatusFromDeps() const; | 66 SnippetsStatus GetSnippetsStatusFromDeps() const; |
| 65 | 67 |
| 66 SnippetsStatus snippets_status_; | 68 SnippetsStatus snippets_status_; |
| 67 SnippetsStatusChangeCallback snippets_status_change_callback_; | 69 SnippetsStatusChangeCallback snippets_status_change_callback_; |
| 68 | 70 |
| 69 bool require_signin_; | 71 bool require_signin_; |
| 70 SigninManagerBase* signin_manager_; | 72 SigninManagerBase* signin_manager_; |
| 71 PrefService* pref_service_; | 73 PrefService* pref_service_; |
| 72 | 74 |
| 73 PrefChangeRegistrar pref_change_registrar_; | 75 PrefChangeRegistrar pref_change_registrar_; |
| 74 | 76 |
| 75 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsStatusService); | 77 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsStatusService); |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 } // namespace ntp_snippets | 80 } // namespace ntp_snippets |
| 79 | 81 |
| 80 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_STATUS_SERVICE_H_ | 82 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_STATUS_SERVICE_H_ |
| OLD | NEW |