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

Side by Side Diff: chrome/browser/notifications/desktop_notification_service.cc

Issue 102103005: Move c/c/e/extension_set to top-level extensions/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/notifications/desktop_notification_service.h" 5 #include "chrome/browser/notifications/desktop_notification_service.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/scoped_user_pref_update.h" 8 #include "base/prefs/scoped_user_pref_update.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
34 #include "components/user_prefs/pref_registry_syncable.h" 34 #include "components/user_prefs/pref_registry_syncable.h"
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
38 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
39 #include "content/public/common/show_desktop_notification_params.h" 39 #include "content/public/common/show_desktop_notification_params.h"
40 #include "extensions/browser/event_router.h" 40 #include "extensions/browser/event_router.h"
41 #include "extensions/browser/info_map.h" 41 #include "extensions/browser/info_map.h"
42 #include "extensions/common/constants.h" 42 #include "extensions/common/constants.h"
43 #include "extensions/common/extension.h"
44 #include "extensions/common/extension_set.h"
43 #include "grit/browser_resources.h" 45 #include "grit/browser_resources.h"
44 #include "grit/chromium_strings.h" 46 #include "grit/chromium_strings.h"
45 #include "grit/generated_resources.h" 47 #include "grit/generated_resources.h"
46 #include "grit/theme_resources.h" 48 #include "grit/theme_resources.h"
47 #include "net/base/escape.h" 49 #include "net/base/escape.h"
48 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
49 #include "ui/base/resource/resource_bundle.h" 51 #include "ui/base/resource/resource_bundle.h"
50 #include "ui/base/webui/web_ui_util.h" 52 #include "ui/base/webui/web_ui_util.h"
51 #include "ui/message_center/message_center_util.h" 53 #include "ui/message_center/message_center_util.h"
52 #include "ui/message_center/notifier_settings.h" 54 #include "ui/message_center/notifier_settings.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 base::string16 DesktopNotificationService::DisplayNameForOriginInProcessId( 509 base::string16 DesktopNotificationService::DisplayNameForOriginInProcessId(
508 const GURL& origin, int process_id) { 510 const GURL& origin, int process_id) {
509 // If the source is an extension, lookup the display name. 511 // If the source is an extension, lookup the display name.
510 // Message center prefers to use extension name if the notification 512 // Message center prefers to use extension name if the notification
511 // is allowed by an extension. 513 // is allowed by an extension.
512 if (NotificationUIManager::DelegatesToMessageCenter() || 514 if (NotificationUIManager::DelegatesToMessageCenter() ||
513 origin.SchemeIs(extensions::kExtensionScheme)) { 515 origin.SchemeIs(extensions::kExtensionScheme)) {
514 extensions::InfoMap* extension_info_map = 516 extensions::InfoMap* extension_info_map =
515 extensions::ExtensionSystem::Get(profile_)->info_map(); 517 extensions::ExtensionSystem::Get(profile_)->info_map();
516 if (extension_info_map) { 518 if (extension_info_map) {
517 ExtensionSet extensions; 519 extensions::ExtensionSet extensions;
518 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( 520 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
519 origin, process_id, extensions::APIPermission::kNotification, 521 origin, process_id, extensions::APIPermission::kNotification,
520 &extensions); 522 &extensions);
521 for (ExtensionSet::const_iterator iter = extensions.begin(); 523 for (extensions::ExtensionSet::const_iterator iter = extensions.begin();
522 iter != extensions.end(); ++iter) { 524 iter != extensions.end(); ++iter) {
523 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id()); 525 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id());
524 if (IsNotifierEnabled(notifier_id)) 526 if (IsNotifierEnabled(notifier_id))
525 return UTF8ToUTF16((*iter)->name()); 527 return UTF8ToUTF16((*iter)->name());
526 } 528 }
527 } 529 }
528 } 530 }
529 return UTF8ToUTF16(origin.host()); 531 return UTF8ToUTF16(origin.host());
530 } 532 }
531 533
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 // Tell the IO thread that this extension's permission for notifications 675 // Tell the IO thread that this extension's permission for notifications
674 // has changed. 676 // has changed.
675 extensions::InfoMap* extension_info_map = 677 extensions::InfoMap* extension_info_map =
676 extensions::ExtensionSystem::Get(profile_)->info_map(); 678 extensions::ExtensionSystem::Get(profile_)->info_map();
677 BrowserThread::PostTask( 679 BrowserThread::PostTask(
678 BrowserThread::IO, FROM_HERE, 680 BrowserThread::IO, FROM_HERE,
679 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 681 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
680 extension_info_map, notifier_id.id, !enabled)); 682 extension_info_map, notifier_id.id, !enabled));
681 683
682 } 684 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698