OLD | NEW |
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/browser_child_process_host.h" | 10 #include "chrome/browser/browser_child_process_host.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 int callback_context); | 96 int callback_context); |
97 | 97 |
98 private: | 98 private: |
99 virtual ~NotificationPermissionInfoBarDelegate(); | 99 virtual ~NotificationPermissionInfoBarDelegate(); |
100 | 100 |
101 // ConfirmInfoBarDelegate: | 101 // ConfirmInfoBarDelegate: |
102 virtual void InfoBarClosed(); | 102 virtual void InfoBarClosed(); |
103 virtual SkBitmap* GetIcon() const; | 103 virtual SkBitmap* GetIcon() const; |
104 virtual Type GetInfoBarType() const; | 104 virtual Type GetInfoBarType() const; |
105 virtual string16 GetMessageText() const; | 105 virtual string16 GetMessageText() const; |
106 virtual int GetButtons() const; | |
107 virtual string16 GetButtonLabel(InfoBarButton button) const; | 106 virtual string16 GetButtonLabel(InfoBarButton button) const; |
108 virtual bool Accept(); | 107 virtual bool Accept(); |
109 virtual bool Cancel(); | 108 virtual bool Cancel(); |
110 | 109 |
111 // The origin we are asking for permissions on. | 110 // The origin we are asking for permissions on. |
112 GURL origin_; | 111 GURL origin_; |
113 | 112 |
114 // The display name for the origin to be displayed. Will be different from | 113 // The display name for the origin to be displayed. Will be different from |
115 // origin_ for extensions. | 114 // origin_ for extensions. |
116 string16 display_name_; | 115 string16 display_name_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 InfoBarDelegate::Type | 169 InfoBarDelegate::Type |
171 NotificationPermissionInfoBarDelegate::GetInfoBarType() const { | 170 NotificationPermissionInfoBarDelegate::GetInfoBarType() const { |
172 return PAGE_ACTION_TYPE; | 171 return PAGE_ACTION_TYPE; |
173 } | 172 } |
174 | 173 |
175 string16 NotificationPermissionInfoBarDelegate::GetMessageText() const { | 174 string16 NotificationPermissionInfoBarDelegate::GetMessageText() const { |
176 return l10n_util::GetStringFUTF16(IDS_NOTIFICATION_PERMISSIONS, | 175 return l10n_util::GetStringFUTF16(IDS_NOTIFICATION_PERMISSIONS, |
177 display_name_); | 176 display_name_); |
178 } | 177 } |
179 | 178 |
180 int NotificationPermissionInfoBarDelegate::GetButtons() const { | |
181 return BUTTON_OK | BUTTON_CANCEL; | |
182 } | |
183 | |
184 string16 NotificationPermissionInfoBarDelegate::GetButtonLabel( | 179 string16 NotificationPermissionInfoBarDelegate::GetButtonLabel( |
185 InfoBarButton button) const { | 180 InfoBarButton button) const { |
186 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 181 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
187 IDS_NOTIFICATION_PERMISSION_YES : IDS_NOTIFICATION_PERMISSION_NO); | 182 IDS_NOTIFICATION_PERMISSION_YES : IDS_NOTIFICATION_PERMISSION_NO); |
188 } | 183 } |
189 | 184 |
190 bool NotificationPermissionInfoBarDelegate::Accept() { | 185 bool NotificationPermissionInfoBarDelegate::Accept() { |
191 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1); | 186 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1); |
192 profile_->GetDesktopNotificationService()->GrantPermission(origin_); | 187 profile_->GetDesktopNotificationService()->GrantPermission(origin_); |
193 action_taken_ = true; | 188 action_taken_ = true; |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 } | 669 } |
675 return UTF8ToUTF16(origin.host()); | 670 return UTF8ToUTF16(origin.host()); |
676 } | 671 } |
677 | 672 |
678 void DesktopNotificationService::NotifySettingsChange() { | 673 void DesktopNotificationService::NotifySettingsChange() { |
679 NotificationService::current()->Notify( | 674 NotificationService::current()->Notify( |
680 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, | 675 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, |
681 Source<DesktopNotificationService>(this), | 676 Source<DesktopNotificationService>(this), |
682 NotificationService::NoDetails()); | 677 NotificationService::NoDetails()); |
683 } | 678 } |
OLD | NEW |