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

Side by Side Diff: components/ntp_snippets/ntp_snippets_status_service.h

Issue 2061803002: 📰 The Status card reports disabled sync states (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplifyBridge
Patch Set: yolo: another big bag of changes Created 4 years, 5 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 2016 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 COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_STATUS_SERVICE_H_
6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_STATUS_SERVICE_H_
7
8 #include "base/callback.h"
9 #include "base/gtest_prod_util.h"
10 #include "base/scoped_observer.h"
11 #include "components/sync_driver/sync_service_observer.h"
12
13 class SigninManagerBase;
14
15 namespace sync_driver {
16 class SyncService;
17 }
18
19 namespace ntp_snippets {
20
21 // On Android builds, a Java counterpart will be generated for this enum.
22 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp.snippets
23 enum class DisabledReason : int {
24 // Snippets are enabled
25 NONE,
26 // Snippets have been disabled as part of the service configuration.
27 EXPLICITLY_DISABLED,
28 // The user is not signed in, and the service requires it to be enabled.
29 SIGNED_OUT,
30 // Sync is not enabled, and the service requires it to be enabled.
31 SYNC_DISABLED,
32 // The service requires passphrase encryption to be disabled.
33 PASSPHRASE_ENCRYPTION_ENABLED,
34 // History sync is not enabled, and the service requires it to be enabled.
35 HISTORY_SYNC_DISABLED,
36 // The sync service is not completely initialized, and the status is unknown.
37 HISTORY_SYNC_STATE_UNKNOWN
38 };
39
40 // Aggregates data from sync and signin to notify the snippet service of
41 // relevant changes in their states.
42 class NTPSnippetsStatusService : public sync_driver::SyncServiceObserver {
43 public:
44 typedef base::Callback<void(DisabledReason)> DisabledReasonChangeCallback;
45
46 NTPSnippetsStatusService(SigninManagerBase* signin_manager,
47 sync_driver::SyncService* sync_service);
48
49 ~NTPSnippetsStatusService() override;
50
51 // Starts listening for changes from the dependencies. |callback| will be
52 // called when a significant change in state is detected.
53 void Init(const DisabledReasonChangeCallback& callback);
54
55 DisabledReason disabled_reason() const { return disabled_reason_; }
56
57 private:
58 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsStatusServiceTest,
59 SyncStateCompatibility);
60
61 // sync_driver::SyncServiceObserver implementation
62 void OnStateChanged() override;
63
64 DisabledReason GetDisabledReasonFromDeps() const;
65
66 DisabledReason disabled_reason_;
67 DisabledReasonChangeCallback disabled_reason_change_callback_;
68
69 SigninManagerBase* signin_manager_;
70 sync_driver::SyncService* sync_service_;
71
72 // The observer for the SyncService. When the sync state changes,
73 // SyncService will call |OnStateChanged|.
74 ScopedObserver<sync_driver::SyncService, sync_driver::SyncServiceObserver>
75 sync_service_observer_;
76
77 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsStatusService);
78 };
79
80 } // namespace ntp_snippets
81
82 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_STATUS_SERVICE_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service_unittest.cc ('k') | components/ntp_snippets/ntp_snippets_status_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698