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

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

Issue 6803012: Profile shouldn't own DesktopNotificationService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lint Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/content_settings/content_settings_provider.h" 10 #include "chrome/browser/content_settings/content_settings_provider.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
12 #include "chrome/browser/notifications/notification.h" 13 #include "chrome/browser/notifications/notification.h"
13 #include "chrome/browser/notifications/notification_object_proxy.h" 14 #include "chrome/browser/notifications/notification_object_proxy.h"
14 #include "chrome/browser/notifications/notification_ui_manager.h" 15 #include "chrome/browser/notifications/notification_ui_manager.h"
15 #include "chrome/browser/notifications/notifications_prefs_cache.h" 16 #include "chrome/browser/notifications/notifications_prefs_cache.h"
16 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/prefs/scoped_user_pref_update.h" 18 #include "chrome/browser/prefs/scoped_user_pref_update.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 180 }
180 181
181 string16 NotificationPermissionInfoBarDelegate::GetButtonLabel( 182 string16 NotificationPermissionInfoBarDelegate::GetButtonLabel(
182 InfoBarButton button) const { 183 InfoBarButton button) const {
183 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 184 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
184 IDS_NOTIFICATION_PERMISSION_YES : IDS_NOTIFICATION_PERMISSION_NO); 185 IDS_NOTIFICATION_PERMISSION_YES : IDS_NOTIFICATION_PERMISSION_NO);
185 } 186 }
186 187
187 bool NotificationPermissionInfoBarDelegate::Accept() { 188 bool NotificationPermissionInfoBarDelegate::Accept() {
188 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1); 189 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1);
189 profile_->GetDesktopNotificationService()->GrantPermission(origin_); 190 DesktopNotificationServiceFactory::GetForProfile(profile_)->
191 GrantPermission(origin_);
190 action_taken_ = true; 192 action_taken_ = true;
191 return true; 193 return true;
192 } 194 }
193 195
194 bool NotificationPermissionInfoBarDelegate::Cancel() { 196 bool NotificationPermissionInfoBarDelegate::Cancel() {
195 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1); 197 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1);
196 profile_->GetDesktopNotificationService()->DenyPermission(origin_); 198 DesktopNotificationServiceFactory::GetForProfile(profile_)->
199 DenyPermission(origin_);
197 action_taken_ = true; 200 action_taken_ = true;
198 return true; 201 return true;
199 } 202 }
200 203
201 204
202 // DesktopNotificationService ------------------------------------------------- 205 // DesktopNotificationService -------------------------------------------------
203 206
204 // static 207 // static
205 string16 DesktopNotificationService::CreateDataUrl( 208 string16 DesktopNotificationService::CreateDataUrl(
206 const GURL& icon_url, const string16& title, const string16& body, 209 const GURL& icon_url, const string16& title, const string16& body,
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 578 }
576 return UTF8ToUTF16(origin.host()); 579 return UTF8ToUTF16(origin.host());
577 } 580 }
578 581
579 void DesktopNotificationService::NotifySettingsChange() { 582 void DesktopNotificationService::NotifySettingsChange() {
580 NotificationService::current()->Notify( 583 NotificationService::current()->Notify(
581 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, 584 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
582 Source<DesktopNotificationService>(this), 585 Source<DesktopNotificationService>(this),
583 NotificationService::NoDetails()); 586 NotificationService::NoDetails());
584 } 587 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698