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

Side by Side Diff: chrome/browser/notifications/notification_channels_provider_android.h

Issue 2886433002: [Android] Adding content settings provider for notification channels (Closed)
Patch Set: Added unit tests (refactored out a class for jni calls) Created 3 years, 7 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 2017 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_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "components/content_settings/core/browser/content_settings_observable_p rovider.h"
12 #include "components/content_settings/core/browser/content_settings_observer.h"
13 #include "components/content_settings/core/browser/content_settings_rule.h"
14 #include "components/content_settings/core/common/content_settings.h"
15 #include "components/content_settings/core/common/content_settings_types.h"
16 #include "components/keyed_service/core/keyed_service.h"
17
18 namespace {
raymes 2017/05/24 00:59:51 nit: newline after this
awdf 2017/06/01 15:11:22 Done.
19 // A Java counterpart will be generated for this enum.
20 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.notifications
21 enum NotificationChannelStatus { ENABLED, BLOCKED, UNAVAILABLE };
22
23 } // anonymous namespace
24
25 // This class provides notification content settings from system notification
26 // channels on Android O+. This provider takes precedence over pref-provided
27 // content settings, but defers to supervised user and policy settings - see
28 // ordering of the ProviderType enum values in HostContentSettingsMap.
29 class NotificationChannelsProviderAndroid
30 : public content_settings::ObservableProvider {
31 public:
32 // Helper class to make the JNI calls.
33 class NotificationChannelsBridge {
34 public:
35 virtual ~NotificationChannelsBridge() = default;
36 virtual bool ShouldUseChannelSettings() = 0;
37 virtual void CreateChannel(const std::string& origin, bool enabled) = 0;
38 virtual NotificationChannelStatus GetChannelStatus(
39 const std::string& origin) = 0;
40 virtual void DeleteChannel(const std::string& origin) = 0;
41 };
42
43 NotificationChannelsProviderAndroid();
44 explicit NotificationChannelsProviderAndroid(
45 std::unique_ptr<NotificationChannelsBridge> bridge);
Peter Beverloo 2017/05/24 10:57:42 Consider making this private with a friends declar
awdf 2017/06/01 15:11:21 Done.
46 ~NotificationChannelsProviderAndroid() override;
47
48 // ProviderInterface methods:
49 std::unique_ptr<content_settings::RuleIterator> GetRuleIterator(
50 ContentSettingsType content_type,
51 const content_settings::ResourceIdentifier& resource_identifier,
52 bool incognito) const override;
53
Peter Beverloo 2017/05/24 10:57:42 nit: no blank lines
awdf 2017/06/01 15:11:22 Done.
54 bool SetWebsiteSetting(
55 const ContentSettingsPattern& primary_pattern,
56 const ContentSettingsPattern& secondary_pattern,
57 ContentSettingsType content_type,
58 const content_settings::ResourceIdentifier& resource_identifier,
59 base::Value* value) override;
60
61 void ClearAllContentSettingsRules(ContentSettingsType content_type) override;
62
63 void ShutdownOnUIThread() override;
64
65 private:
66 std::unique_ptr<NotificationChannelsBridge> bridge_;
67 bool should_use_channels_;
68
69 DISALLOW_COPY_AND_ASSIGN(NotificationChannelsProviderAndroid);
70 };
71
72 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698