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

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

Issue 7125006: Get rid of Chrome notifications dependency, and instead go through ContentBrowserClient to show U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix browsertest Created 9 years, 6 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"
(...skipping 19 matching lines...) Expand all
30 #include "content/browser/site_instance.h" 30 #include "content/browser/site_instance.h"
31 #include "content/browser/worker_host/worker_process_host.h" 31 #include "content/browser/worker_host/worker_process_host.h"
32 #include "content/common/desktop_notification_messages.h" 32 #include "content/common/desktop_notification_messages.h"
33 #include "content/common/notification_service.h" 33 #include "content/common/notification_service.h"
34 #include "content/common/notification_type.h" 34 #include "content/common/notification_type.h"
35 #include "grit/browser_resources.h" 35 #include "grit/browser_resources.h"
36 #include "grit/chromium_strings.h" 36 #include "grit/chromium_strings.h"
37 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
38 #include "grit/theme_resources.h" 38 #include "grit/theme_resources.h"
39 #include "net/base/escape.h" 39 #include "net/base/escape.h"
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen ter.h"
41 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/resource/resource_bundle.h" 41 #include "ui/base/resource/resource_bundle.h"
43 42
44 using WebKit::WebNotificationPresenter; 43 using WebKit::WebNotificationPresenter;
45 using WebKit::WebTextDirection; 44 using WebKit::WebTextDirection;
46 45
47 const ContentSetting kDefaultSetting = CONTENT_SETTING_ASK; 46 const ContentSetting kDefaultSetting = CONTENT_SETTING_ASK;
48 47
49 namespace { 48 namespace {
50 49
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 callback_context_(callback_context), 146 callback_context_(callback_context),
148 action_taken_(false) { 147 action_taken_(false) {
149 } 148 }
150 149
151 NotificationPermissionInfoBarDelegate:: 150 NotificationPermissionInfoBarDelegate::
152 ~NotificationPermissionInfoBarDelegate() { 151 ~NotificationPermissionInfoBarDelegate() {
153 if (!action_taken_) 152 if (!action_taken_)
154 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Ignored", 1); 153 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Ignored", 1);
155 154
156 RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_); 155 RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
157 if (host) { 156 if (host)
158 host->Send(new DesktopNotificationMsg_PermissionRequestDone( 157 host->DesktopNotificationPermissionRequestDone(callback_context_);
159 route_id_, callback_context_));
160 }
161 } 158 }
162 159
163 gfx::Image* NotificationPermissionInfoBarDelegate::GetIcon() const { 160 gfx::Image* NotificationPermissionInfoBarDelegate::GetIcon() const {
164 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 161 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
165 IDR_PRODUCT_ICON_32); 162 IDR_PRODUCT_ICON_32);
166 } 163 }
167 164
168 InfoBarDelegate::Type 165 InfoBarDelegate::Type
169 NotificationPermissionInfoBarDelegate::GetInfoBarType() const { 166 NotificationPermissionInfoBarDelegate::GetInfoBarType() const {
170 return PAGE_ACTION_TYPE; 167 return PAGE_ACTION_TYPE;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 ContentSetting setting = GetContentSetting(origin); 515 ContentSetting setting = GetContentSetting(origin);
519 if (setting == CONTENT_SETTING_ASK) { 516 if (setting == CONTENT_SETTING_ASK) {
520 // Show an info bar requesting permission. 517 // Show an info bar requesting permission.
521 wrapper->AddInfoBar( 518 wrapper->AddInfoBar(
522 new NotificationPermissionInfoBarDelegate( 519 new NotificationPermissionInfoBarDelegate(
523 tab, origin, DisplayNameForOrigin(origin), process_id, 520 tab, origin, DisplayNameForOrigin(origin), process_id,
524 route_id, callback_context)); 521 route_id, callback_context));
525 } else { 522 } else {
526 // Notify renderer immediately. 523 // Notify renderer immediately.
527 RenderViewHost* host = RenderViewHost::FromID(process_id, route_id); 524 RenderViewHost* host = RenderViewHost::FromID(process_id, route_id);
528 if (host) { 525 if (host)
529 host->Send(new DesktopNotificationMsg_PermissionRequestDone( 526 host->DesktopNotificationPermissionRequestDone(callback_context);
530 route_id, callback_context));
531 }
532 } 527 }
533 } 528 }
534 529
535 void DesktopNotificationService::ShowNotification( 530 void DesktopNotificationService::ShowNotification(
536 const Notification& notification) { 531 const Notification& notification) {
537 ui_manager_->Add(notification, profile_); 532 ui_manager_->Add(notification, profile_);
538 } 533 }
539 534
540 bool DesktopNotificationService::CancelDesktopNotification( 535 bool DesktopNotificationService::CancelDesktopNotification(
541 int process_id, int route_id, int notification_id) { 536 int process_id, int route_id, int notification_id) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 return UTF8ToUTF16(origin.host()); 580 return UTF8ToUTF16(origin.host());
586 } 581 }
587 582
588 void DesktopNotificationService::NotifySettingsChange() { 583 void DesktopNotificationService::NotifySettingsChange() {
589 NotificationService::current()->Notify( 584 NotificationService::current()->Notify(
590 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, 585 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
591 Source<DesktopNotificationService>(this), 586 Source<DesktopNotificationService>(this),
592 NotificationService::NoDetails()); 587 NotificationService::NoDetails());
593 } 588 }
594 589
595 int DesktopNotificationService::HasPermission(const GURL& origin) { 590 WebKit::WebNotificationPresenter::Permission
591 DesktopNotificationService::HasPermission(const GURL& origin) {
596 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 592 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
597 return prefs_cache()->HasPermission(origin.GetOrigin()); 593 return prefs_cache()->HasPermission(origin.GetOrigin());
598 } 594 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698