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

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

Issue 2922473003: [Android] Implement GetRuleIterator for channels provider (Closed)
Patch Set: Created 3 years, 6 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/content_settings/core/browser/content_settings_observable_p rovider.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" 12 #include "components/content_settings/core/browser/content_settings_observer.h"
13 #include "components/content_settings/core/browser/content_settings_rule.h" 13 #include "components/content_settings/core/browser/content_settings_rule.h"
14 #include "components/content_settings/core/common/content_settings.h" 14 #include "components/content_settings/core/common/content_settings.h"
15 #include "components/content_settings/core/common/content_settings_types.h" 15 #include "components/content_settings/core/common/content_settings_types.h"
16 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
17 17
18 namespace { 18 namespace {
19 19
20 // A Java counterpart will be generated for this enum. 20 // A Java counterpart will be generated for this enum.
21 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.notifications 21 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.notifications
22 enum NotificationChannelStatus { ENABLED, BLOCKED, UNAVAILABLE }; 22 enum NotificationChannelStatus { ENABLED, BLOCKED, UNAVAILABLE };
23 23
24 struct Channel {
25 std::string origin;
26 NotificationChannelStatus status;
Peter Beverloo 2017/06/02 15:14:26 nit: give a default value
awdf 2017/06/02 16:59:48 Done.
27 };
28
24 } // anonymous namespace 29 } // anonymous namespace
Peter Beverloo 2017/06/02 15:14:26 Sorry that I missed this earlier - we shouldn't be
awdf 2017/06/02 16:59:48 Done.
25 30
26 // This class provides notification content settings from system notification 31 // This class provides notification content settings from system notification
27 // channels on Android O+. This provider takes precedence over pref-provided 32 // channels on Android O+. This provider takes precedence over pref-provided
28 // content settings, but defers to supervised user and policy settings - see 33 // content settings, but defers to supervised user and policy settings - see
29 // ordering of the ProviderType enum values in HostContentSettingsMap. 34 // ordering of the ProviderType enum values in HostContentSettingsMap.
30 class NotificationChannelsProviderAndroid 35 class NotificationChannelsProviderAndroid
31 : public content_settings::ObservableProvider { 36 : public content_settings::ObservableProvider {
32 public: 37 public:
33 // Helper class to make the JNI calls. 38 // Helper class to make the JNI calls.
34 class NotificationChannelsBridge { 39 class NotificationChannelsBridge {
35 public: 40 public:
36 virtual ~NotificationChannelsBridge() = default; 41 virtual ~NotificationChannelsBridge() = default;
37 virtual bool ShouldUseChannelSettings() = 0; 42 virtual bool ShouldUseChannelSettings() = 0;
38 virtual void CreateChannel(const std::string& origin, bool enabled) = 0; 43 virtual void CreateChannel(const std::string& origin, bool enabled) = 0;
39 virtual NotificationChannelStatus GetChannelStatus( 44 virtual NotificationChannelStatus GetChannelStatus(
40 const std::string& origin) = 0; 45 const std::string& origin) = 0;
41 virtual void DeleteChannel(const std::string& origin) = 0; 46 virtual void DeleteChannel(const std::string& origin) = 0;
47 virtual std::vector<Channel> GetChannels() = 0;
42 }; 48 };
43 49
44 NotificationChannelsProviderAndroid(); 50 NotificationChannelsProviderAndroid();
45 ~NotificationChannelsProviderAndroid() override; 51 ~NotificationChannelsProviderAndroid() override;
46 52
47 // ProviderInterface methods: 53 // ProviderInterface methods:
48 std::unique_ptr<content_settings::RuleIterator> GetRuleIterator( 54 std::unique_ptr<content_settings::RuleIterator> GetRuleIterator(
49 ContentSettingsType content_type, 55 ContentSettingsType content_type,
50 const content_settings::ResourceIdentifier& resource_identifier, 56 const content_settings::ResourceIdentifier& resource_identifier,
51 bool incognito) const override; 57 bool incognito) const override;
(...skipping 11 matching lines...) Expand all
63 std::unique_ptr<NotificationChannelsBridge> bridge); 69 std::unique_ptr<NotificationChannelsBridge> bridge);
64 friend class NotificationChannelsProviderAndroidTest; 70 friend class NotificationChannelsProviderAndroidTest;
65 71
66 std::unique_ptr<NotificationChannelsBridge> bridge_; 72 std::unique_ptr<NotificationChannelsBridge> bridge_;
67 bool should_use_channels_; 73 bool should_use_channels_;
68 74
69 DISALLOW_COPY_AND_ASSIGN(NotificationChannelsProviderAndroid); 75 DISALLOW_COPY_AND_ASSIGN(NotificationChannelsProviderAndroid);
70 }; 76 };
71 77
72 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H _ 78 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CHANNELS_PROVIDER_ANDROID_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698