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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
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 | Annotate | Revision Log
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"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/content_settings/content_settings_details.h" 13 #include "chrome/browser/content_settings/content_settings_details.h"
14 #include "chrome/browser/content_settings/content_settings_provider.h" 14 #include "chrome/browser/content_settings/content_settings_provider.h"
15 #include "chrome/browser/content_settings/host_content_settings_map.h" 15 #include "chrome/browser/content_settings/host_content_settings_map.h"
16 #include "chrome/browser/extensions/api/notifications/notifications_api.h" 16 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 19 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
20 #include "chrome/browser/infobars/infobar.h"
20 #include "chrome/browser/infobars/infobar_service.h" 21 #include "chrome/browser/infobars/infobar_service.h"
21 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 22 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
22 #include "chrome/browser/notifications/notification.h" 23 #include "chrome/browser/notifications/notification.h"
23 #include "chrome/browser/notifications/notification_object_proxy.h" 24 #include "chrome/browser/notifications/notification_object_proxy.h"
24 #include "chrome/browser/notifications/notification_ui_manager.h" 25 #include "chrome/browser/notifications/notification_ui_manager.h"
25 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" 26 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
26 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac tory.h" 27 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac tory.h"
27 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
29 #include "chrome/common/content_settings.h" 30 #include "chrome/common/content_settings.h"
(...skipping 30 matching lines...) Expand all
60 using message_center::NotifierId; 61 using message_center::NotifierId;
61 using blink::WebTextDirection; 62 using blink::WebTextDirection;
62 63
63 64
64 // NotificationPermissionInfoBarDelegate -------------------------------------- 65 // NotificationPermissionInfoBarDelegate --------------------------------------
65 66
66 // The delegate for the infobar shown when an origin requests notification 67 // The delegate for the infobar shown when an origin requests notification
67 // permissions. 68 // permissions.
68 class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { 69 class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate {
69 public: 70 public:
70 // Creates a notification permission infobar delegate and adds it to 71 // Creates a notification permission infobar and delegate and adds the infobar
71 // |infobar_service|. 72 // to |infobar_service|.
72 static void Create(InfoBarService* infobar_service, 73 static void Create(InfoBarService* infobar_service,
73 DesktopNotificationService* notification_service, 74 DesktopNotificationService* notification_service,
74 const GURL& origin, 75 const GURL& origin,
75 const string16& display_name, 76 const string16& display_name,
76 int process_id, 77 int process_id,
77 int route_id, 78 int route_id,
78 int callback_context); 79 int callback_context);
79 80
80 private: 81 private:
81 NotificationPermissionInfoBarDelegate( 82 NotificationPermissionInfoBarDelegate(
82 InfoBarService* infobar_service,
83 DesktopNotificationService* notification_service, 83 DesktopNotificationService* notification_service,
84 const GURL& origin, 84 const GURL& origin,
85 const string16& display_name, 85 const string16& display_name,
86 int process_id, 86 int process_id,
87 int route_id, 87 int route_id,
88 int callback_context); 88 int callback_context);
89 virtual ~NotificationPermissionInfoBarDelegate(); 89 virtual ~NotificationPermissionInfoBarDelegate();
90 90
91 // ConfirmInfoBarDelegate: 91 // ConfirmInfoBarDelegate:
92 virtual int GetIconID() const OVERRIDE; 92 virtual int GetIconID() const OVERRIDE;
(...skipping 27 matching lines...) Expand all
120 120
121 // static 121 // static
122 void NotificationPermissionInfoBarDelegate::Create( 122 void NotificationPermissionInfoBarDelegate::Create(
123 InfoBarService* infobar_service, 123 InfoBarService* infobar_service,
124 DesktopNotificationService* notification_service, 124 DesktopNotificationService* notification_service,
125 const GURL& origin, 125 const GURL& origin,
126 const string16& display_name, 126 const string16& display_name,
127 int process_id, 127 int process_id,
128 int route_id, 128 int route_id,
129 int callback_context) { 129 int callback_context) {
130 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( 130 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
131 new NotificationPermissionInfoBarDelegate( 131 scoped_ptr<ConfirmInfoBarDelegate>(
132 infobar_service, notification_service, origin, display_name, 132 new NotificationPermissionInfoBarDelegate(
133 process_id, route_id, callback_context))); 133 notification_service, origin, display_name, process_id, route_id,
134 callback_context))));
134 } 135 }
135 136
136 NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate( 137 NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate(
137 InfoBarService* infobar_service,
138 DesktopNotificationService* notification_service, 138 DesktopNotificationService* notification_service,
139 const GURL& origin, 139 const GURL& origin,
140 const string16& display_name, 140 const string16& display_name,
141 int process_id, 141 int process_id,
142 int route_id, 142 int route_id,
143 int callback_context) 143 int callback_context)
144 : ConfirmInfoBarDelegate(infobar_service), 144 : ConfirmInfoBarDelegate(),
145 origin_(origin), 145 origin_(origin),
146 display_name_(display_name), 146 display_name_(display_name),
147 notification_service_(notification_service), 147 notification_service_(notification_service),
148 process_id_(process_id), 148 process_id_(process_id),
149 route_id_(route_id), 149 route_id_(route_id),
150 callback_context_(callback_context), 150 callback_context_(callback_context),
151 action_taken_(false) { 151 action_taken_(false) {
152 } 152 }
153 153
154 NotificationPermissionInfoBarDelegate:: 154 NotificationPermissionInfoBarDelegate::
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // Tell the IO thread that this extension's permission for notifications 682 // Tell the IO thread that this extension's permission for notifications
683 // has changed. 683 // has changed.
684 extensions::InfoMap* extension_info_map = 684 extensions::InfoMap* extension_info_map =
685 extensions::ExtensionSystem::Get(profile_)->info_map(); 685 extensions::ExtensionSystem::Get(profile_)->info_map();
686 BrowserThread::PostTask( 686 BrowserThread::PostTask(
687 BrowserThread::IO, FROM_HERE, 687 BrowserThread::IO, FROM_HERE,
688 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 688 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
689 extension_info_map, notifier_id.id, !enabled)); 689 extension_info_map, notifier_id.id, !enabled));
690 690
691 } 691 }
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_infobar_delegate.cc ('k') | chrome/browser/notifications/notification_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698