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

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, 2 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 | 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/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/content_settings/content_settings_details.h" 12 #include "chrome/browser/content_settings/content_settings_details.h"
13 #include "chrome/browser/content_settings/content_settings_provider.h" 13 #include "chrome/browser/content_settings/content_settings_provider.h"
14 #include "chrome/browser/content_settings/host_content_settings_map.h" 14 #include "chrome/browser/content_settings/host_content_settings_map.h"
15 #include "chrome/browser/extensions/extension_info_map.h" 15 #include "chrome/browser/extensions/extension_info_map.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system.h" 17 #include "chrome/browser/extensions/extension_system.h"
18 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 18 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
19 #include "chrome/browser/infobars/infobar.h"
19 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
20 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 21 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
21 #include "chrome/browser/notifications/notification.h" 22 #include "chrome/browser/notifications/notification.h"
22 #include "chrome/browser/notifications/notification_object_proxy.h" 23 #include "chrome/browser/notifications/notification_object_proxy.h"
23 #include "chrome/browser/notifications/notification_ui_manager.h" 24 #include "chrome/browser/notifications/notification_ui_manager.h"
24 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" 25 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
25 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac tory.h" 26 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac tory.h"
26 #include "chrome/browser/prefs/scoped_user_pref_update.h" 27 #include "chrome/browser/prefs/scoped_user_pref_update.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"
(...skipping 30 matching lines...) Expand all
59 using WebKit::WebNotificationPresenter; 60 using WebKit::WebNotificationPresenter;
60 using WebKit::WebTextDirection; 61 using WebKit::WebTextDirection;
61 62
62 63
63 // NotificationPermissionInfoBarDelegate -------------------------------------- 64 // NotificationPermissionInfoBarDelegate --------------------------------------
64 65
65 // The delegate for the infobar shown when an origin requests notification 66 // The delegate for the infobar shown when an origin requests notification
66 // permissions. 67 // permissions.
67 class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { 68 class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate {
68 public: 69 public:
69 // Creates a notification permission infobar delegate and adds it to 70 // Creates a notification permission infobar and delegate and adds the infobar
70 // |infobar_service|. 71 // to |infobar_service|.
71 static void Create(InfoBarService* infobar_service, 72 static void Create(InfoBarService* infobar_service,
72 DesktopNotificationService* notification_service, 73 DesktopNotificationService* notification_service,
73 const GURL& origin, 74 const GURL& origin,
74 const string16& display_name, 75 const string16& display_name,
75 int process_id, 76 int process_id,
76 int route_id, 77 int route_id,
77 int callback_context); 78 int callback_context);
78 79
79 private: 80 private:
80 NotificationPermissionInfoBarDelegate( 81 NotificationPermissionInfoBarDelegate(
81 InfoBarService* infobar_service,
82 DesktopNotificationService* notification_service, 82 DesktopNotificationService* notification_service,
83 const GURL& origin, 83 const GURL& origin,
84 const string16& display_name, 84 const string16& display_name,
85 int process_id, 85 int process_id,
86 int route_id, 86 int route_id,
87 int callback_context); 87 int callback_context);
88 virtual ~NotificationPermissionInfoBarDelegate(); 88 virtual ~NotificationPermissionInfoBarDelegate();
89 89
90 // ConfirmInfoBarDelegate: 90 // ConfirmInfoBarDelegate:
91 virtual int GetIconID() const OVERRIDE; 91 virtual int GetIconID() const OVERRIDE;
(...skipping 27 matching lines...) Expand all
119 119
120 // static 120 // static
121 void NotificationPermissionInfoBarDelegate::Create( 121 void NotificationPermissionInfoBarDelegate::Create(
122 InfoBarService* infobar_service, 122 InfoBarService* infobar_service,
123 DesktopNotificationService* notification_service, 123 DesktopNotificationService* notification_service,
124 const GURL& origin, 124 const GURL& origin,
125 const string16& display_name, 125 const string16& display_name,
126 int process_id, 126 int process_id,
127 int route_id, 127 int route_id,
128 int callback_context) { 128 int callback_context) {
129 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( 129 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
130 new NotificationPermissionInfoBarDelegate( 130 scoped_ptr<ConfirmInfoBarDelegate>(
131 infobar_service, notification_service, origin, display_name, 131 new NotificationPermissionInfoBarDelegate(
132 process_id, route_id, callback_context))); 132 notification_service, origin, display_name, process_id, route_id,
133 callback_context))));
133 } 134 }
134 135
135 NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate( 136 NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate(
136 InfoBarService* infobar_service,
137 DesktopNotificationService* notification_service, 137 DesktopNotificationService* notification_service,
138 const GURL& origin, 138 const GURL& origin,
139 const string16& display_name, 139 const string16& display_name,
140 int process_id, 140 int process_id,
141 int route_id, 141 int route_id,
142 int callback_context) 142 int callback_context)
143 : ConfirmInfoBarDelegate(infobar_service), 143 : ConfirmInfoBarDelegate(),
144 origin_(origin), 144 origin_(origin),
145 display_name_(display_name), 145 display_name_(display_name),
146 notification_service_(notification_service), 146 notification_service_(notification_service),
147 process_id_(process_id), 147 process_id_(process_id),
148 route_id_(route_id), 148 route_id_(route_id),
149 callback_context_(callback_context), 149 callback_context_(callback_context),
150 action_taken_(false) { 150 action_taken_(false) {
151 } 151 }
152 152
153 NotificationPermissionInfoBarDelegate:: 153 NotificationPermissionInfoBarDelegate::
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED, type); 660 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED, type);
661 661
662 extensions::Extension* extension = 662 extensions::Extension* extension =
663 content::Details<extensions::Extension>(details).ptr(); 663 content::Details<extensions::Extension>(details).ptr();
664 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); 664 NotifierId notifier_id(NotifierId::APPLICATION, extension->id());
665 if (IsNotifierEnabled(notifier_id)) 665 if (IsNotifierEnabled(notifier_id))
666 return; 666 return;
667 667
668 SetNotifierEnabled(notifier_id, true); 668 SetNotifierEnabled(notifier_id, true);
669 } 669 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698