| 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/content_settings/content_settings_details.h" | 10 #include "chrome/browser/content_settings/content_settings_details.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/content_settings.h" | 26 #include "chrome/common/content_settings.h" |
| 27 #include "chrome/common/content_settings_pattern.h" | 27 #include "chrome/common/content_settings_pattern.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "content/browser/browser_child_process_host.h" | 30 #include "content/browser/browser_child_process_host.h" |
| 31 #include "content/browser/renderer_host/render_view_host.h" | 31 #include "content/browser/renderer_host/render_view_host.h" |
| 32 #include "content/browser/site_instance.h" | 32 #include "content/browser/site_instance.h" |
| 33 #include "content/browser/worker_host/worker_process_host.h" | 33 #include "content/browser/worker_host/worker_process_host.h" |
| 34 #include "content/common/desktop_notification_messages.h" | |
| 35 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 36 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
| 36 #include "content/public/common/show_desktop_notification_params.h" |
| 37 #include "grit/browser_resources.h" | 37 #include "grit/browser_resources.h" |
| 38 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
| 39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
| 40 #include "grit/theme_resources.h" | 40 #include "grit/theme_resources.h" |
| 41 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
| 44 | 44 |
| 45 using content::BrowserThread; | 45 using content::BrowserThread; |
| 46 using WebKit::WebNotificationPresenter; | 46 using WebKit::WebNotificationPresenter; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 int process_id, int route_id, int notification_id) { | 379 int process_id, int route_id, int notification_id) { |
| 380 scoped_refptr<NotificationObjectProxy> proxy( | 380 scoped_refptr<NotificationObjectProxy> proxy( |
| 381 new NotificationObjectProxy(process_id, route_id, notification_id, | 381 new NotificationObjectProxy(process_id, route_id, notification_id, |
| 382 false)); | 382 false)); |
| 383 if (ui_manager_) | 383 if (ui_manager_) |
| 384 return ui_manager_->CancelById(proxy->id()); | 384 return ui_manager_->CancelById(proxy->id()); |
| 385 return false; | 385 return false; |
| 386 } | 386 } |
| 387 | 387 |
| 388 bool DesktopNotificationService::ShowDesktopNotification( | 388 bool DesktopNotificationService::ShowDesktopNotification( |
| 389 const DesktopNotificationHostMsg_Show_Params& params, | 389 const content::ShowDesktopNotificationHostMsgParams& params, |
| 390 int process_id, int route_id, DesktopNotificationSource source) { | 390 int process_id, int route_id, DesktopNotificationSource source) { |
| 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 392 const GURL& origin = params.origin; | 392 const GURL& origin = params.origin; |
| 393 NotificationObjectProxy* proxy = | 393 NotificationObjectProxy* proxy = |
| 394 new NotificationObjectProxy(process_id, route_id, | 394 new NotificationObjectProxy(process_id, route_id, |
| 395 params.notification_id, | 395 params.notification_id, |
| 396 source == WorkerNotification); | 396 source == WorkerNotification); |
| 397 GURL contents; | 397 GURL contents; |
| 398 if (params.is_html) { | 398 if (params.is_html) { |
| 399 contents = params.contents_url; | 399 contents = params.contents_url; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 444 |
| 445 if (setting == CONTENT_SETTING_ALLOW) | 445 if (setting == CONTENT_SETTING_ALLOW) |
| 446 return WebKit::WebNotificationPresenter::PermissionAllowed; | 446 return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 447 if (setting == CONTENT_SETTING_BLOCK) | 447 if (setting == CONTENT_SETTING_BLOCK) |
| 448 return WebKit::WebNotificationPresenter::PermissionDenied; | 448 return WebKit::WebNotificationPresenter::PermissionDenied; |
| 449 if (setting == CONTENT_SETTING_ASK) | 449 if (setting == CONTENT_SETTING_ASK) |
| 450 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 450 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 451 NOTREACHED() << "Invalid notifications settings value: " << setting; | 451 NOTREACHED() << "Invalid notifications settings value: " << setting; |
| 452 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 452 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 453 } | 453 } |
| OLD | NEW |