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

Unified Diff: chrome/browser/notifications/desktop_notification_service.cc

Issue 432005: Make notifications permission available in the extension manifest and hook up... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/desktop_notification_service.cc
===================================================================
--- chrome/browser/notifications/desktop_notification_service.cc (revision 32803)
+++ chrome/browser/notifications/desktop_notification_service.cc (working copy)
@@ -191,6 +191,11 @@
: profile_(profile),
ui_manager_(ui_manager) {
InitPrefs();
+
+ // Listen for new extension installations so we can cache permissions.
+ notification_registrar_.Add(this,
+ NotificationType::EXTENSION_LOADED,
+ Source<Profile>(profile_));
}
DesktopNotificationService::~DesktopNotificationService() {
@@ -212,8 +217,33 @@
denied_sites = prefs->GetList(prefs::kDesktopNotificationDeniedOrigins);
prefs_cache_ = new NotificationsPrefsCache(allowed_sites, denied_sites);
+
+ ExtensionsService* ext_service = profile_->GetExtensionsService();
+ if (ext_service) {
+ const ExtensionList* extensions = ext_service->extensions();
+ for (ExtensionList::const_iterator iter = extensions->begin();
+ iter != extensions->end(); ++iter) {
+ if ((*iter)->HasApiPermission(Extension::kNotificationPermission)) {
+ prefs_cache_->CacheAllowedOrigin((*iter)->url());
Aaron Boodman 2009/11/24 20:38:14 Why do you need to store this state again? It is a
John Gregg 2009/11/24 20:52:44 I need this state on the IO thread to respond to a
+ }
+ }
+ }
}
+void DesktopNotificationService::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type != NotificationType::EXTENSION_LOADED) {
+ NOTREACHED();
+ return;
+ }
+
+ Details<Extension> extension = static_cast<Details<Extension> >(details);
+ if (extension->HasApiPermission(Extension::kNotificationPermission)) {
+ GrantPermission(extension->url());
+ }
+}
+
void DesktopNotificationService::GrantPermission(const GURL& origin) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
PrefService* prefs = profile_->GetPrefs();
@@ -292,7 +322,7 @@
bool DesktopNotificationService::ShowDesktopNotification(
const GURL& origin, const GURL& url, int process_id, int route_id,
- NotificationSource source, int notification_id) {
+ DesktopNotificationSource source, int notification_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
NotificationObjectProxy* proxy =
new NotificationObjectProxy(process_id, route_id,
@@ -306,7 +336,7 @@
bool DesktopNotificationService::ShowDesktopNotificationText(
const GURL& origin, const GURL& icon, const string16& title,
const string16& text, int process_id, int route_id,
- NotificationSource source, int notification_id) {
+ DesktopNotificationSource source, int notification_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
NotificationObjectProxy* proxy =
new NotificationObjectProxy(process_id, route_id,
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698