Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / notifications / desktop_notification_service.h
blob8f1e167c2b3f8870ecfddd560bd7e93986a5fd4a
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/callback_forward.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/prefs/pref_member.h"
18 #include "base/scoped_observer.h"
19 #include "base/strings/string16.h"
20 #include "chrome/browser/content_settings/permission_context_base.h"
21 #include "components/content_settings/core/common/content_settings.h"
22 #include "components/keyed_service/core/keyed_service.h"
23 #include "ui/message_center/notifier_settings.h"
24 #include "url/gurl.h"
26 #if defined(ENABLE_EXTENSIONS)
27 #include "extensions/browser/extension_registry_observer.h"
28 #endif
30 class Profile;
32 #if defined(ENABLE_EXTENSIONS)
33 namespace extensions {
34 class ExtensionRegistry;
36 #endif
38 namespace user_prefs {
39 class PrefRegistrySyncable;
42 // The DesktopNotificationService is an object, owned by the Profile,
43 // which provides the creation of desktop "toasts" to web pages and workers.
44 class DesktopNotificationService : public PermissionContextBase
45 #if defined(ENABLE_EXTENSIONS)
47 public extensions::ExtensionRegistryObserver
48 #endif
50 public:
51 // Register profile-specific prefs of notifications.
52 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs);
54 explicit DesktopNotificationService(Profile* profile);
55 ~DesktopNotificationService() override;
57 // Requests Web Notification permission for |requesting_frame|. The |callback|
58 // will be invoked after the user has made a decision.
59 void RequestNotificationPermission(
60 content::WebContents* web_contents,
61 const PermissionRequestID& request_id,
62 const GURL& requesting_origin,
63 bool user_gesture,
64 const BrowserPermissionCallback& result_callback);
66 // Returns true if the notifier with |notifier_id| is allowed to send
67 // notifications.
68 bool IsNotifierEnabled(const message_center::NotifierId& notifier_id) const;
70 // Updates the availability of the notifier.
71 void SetNotifierEnabled(const message_center::NotifierId& notifier_id,
72 bool enabled);
74 private:
75 // Called when the string list pref has been changed.
76 void OnStringListPrefChanged(
77 const char* pref_name, std::set<std::string>* ids_field);
79 // Called when the disabled_extension_id pref has been changed.
80 void OnDisabledExtensionIdsChanged();
82 void FirePermissionLevelChangedEvent(
83 const message_center::NotifierId& notifier_id,
84 bool enabled);
86 #if defined(ENABLE_EXTENSIONS)
87 // extensions::ExtensionRegistryObserver:
88 void OnExtensionUninstalled(content::BrowserContext* browser_context,
89 const extensions::Extension* extension,
90 extensions::UninstallReason reason) override;
91 #endif
93 // PermissionContextBase:
94 void UpdateContentSetting(const GURL& requesting_origin,
95 const GURL& embedder_origin,
96 ContentSetting content_setting) override;
98 // The profile which owns this object.
99 Profile* profile_;
101 // Prefs listener for disabled_extension_id.
102 StringListPrefMember disabled_extension_id_pref_;
104 // Prefs listener for disabled_system_component_id.
105 StringListPrefMember disabled_system_component_id_pref_;
107 // On-memory data for the availability of extensions.
108 std::set<std::string> disabled_extension_ids_;
110 // On-memory data for the availability of system_component.
111 std::set<std::string> disabled_system_component_ids_;
113 #if defined(ENABLE_EXTENSIONS)
114 // An observer to listen when extension is uninstalled.
115 ScopedObserver<extensions::ExtensionRegistry,
116 extensions::ExtensionRegistryObserver>
117 extension_registry_observer_;
118 #endif
120 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService);
123 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_