| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/platform_notification_service_impl.h" | 5 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "components/url_formatter/url_formatter.h" | 32 #include "components/url_formatter/url_formatter.h" |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/desktop_notification_delegate.h" | 34 #include "content/public/browser/desktop_notification_delegate.h" |
| 35 #include "content/public/browser/notification_event_dispatcher.h" | 35 #include "content/public/browser/notification_event_dispatcher.h" |
| 36 #include "content/public/browser/permission_type.h" | 36 #include "content/public/browser/permission_type.h" |
| 37 #include "content/public/browser/storage_partition.h" | 37 #include "content/public/browser/storage_partition.h" |
| 38 #include "content/public/browser/user_metrics.h" | 38 #include "content/public/browser/user_metrics.h" |
| 39 #include "content/public/common/notification_resources.h" | 39 #include "content/public/common/notification_resources.h" |
| 40 #include "content/public/common/platform_notification_data.h" | 40 #include "content/public/common/platform_notification_data.h" |
| 41 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
| 42 #include "ui/message_center/notification.h" |
| 42 #include "ui/message_center/notification_types.h" | 43 #include "ui/message_center/notification_types.h" |
| 43 #include "ui/message_center/notifier_settings.h" | 44 #include "ui/message_center/notifier_settings.h" |
| 44 #include "url/url_constants.h" | 45 #include "url/url_constants.h" |
| 45 | 46 |
| 46 #if defined(ENABLE_EXTENSIONS) | 47 #if defined(ENABLE_EXTENSIONS) |
| 47 #include "chrome/browser/notifications/notifier_state_tracker.h" | 48 #include "chrome/browser/notifications/notifier_state_tracker.h" |
| 48 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" | 49 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" |
| 49 #include "extensions/browser/extension_registry.h" | 50 #include "extensions/browser/extension_registry.h" |
| 50 #include "extensions/browser/info_map.h" | 51 #include "extensions/browser/info_map.h" |
| 51 #include "extensions/common/constants.h" | 52 #include "extensions/common/constants.h" |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 #endif // defined(OS_ANDROID) | 442 #endif // defined(OS_ANDROID) |
| 442 | 443 |
| 443 // Developer supplied action buttons. | 444 // Developer supplied action buttons. |
| 444 std::vector<message_center::ButtonInfo> buttons; | 445 std::vector<message_center::ButtonInfo> buttons; |
| 445 for (size_t i = 0; i < notification_data.actions.size(); i++) { | 446 for (size_t i = 0; i < notification_data.actions.size(); i++) { |
| 446 message_center::ButtonInfo button(notification_data.actions[i].title); | 447 message_center::ButtonInfo button(notification_data.actions[i].title); |
| 447 // TODO(peter): Handle different screen densities instead of always using | 448 // TODO(peter): Handle different screen densities instead of always using |
| 448 // the 1x bitmap - crbug.com/585815. | 449 // the 1x bitmap - crbug.com/585815. |
| 449 button.icon = | 450 button.icon = |
| 450 gfx::Image::CreateFrom1xBitmap(notification_resources.action_icons[i]); | 451 gfx::Image::CreateFrom1xBitmap(notification_resources.action_icons[i]); |
| 452 button.placeholder = notification_data.actions[i].placeholder; |
| 453 switch (notification_data.actions[i].type) { |
| 454 case content::PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON: |
| 455 button.type = message_center::ButtonType::BUTTON; |
| 456 break; |
| 457 case content::PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT: |
| 458 button.type = message_center::ButtonType::TEXT; |
| 459 break; |
| 460 } |
| 451 buttons.push_back(button); | 461 buttons.push_back(button); |
| 452 } | 462 } |
| 453 notification.set_buttons(buttons); | 463 notification.set_buttons(buttons); |
| 454 | 464 |
| 455 // On desktop, notifications with require_interaction==true stay on-screen | 465 // On desktop, notifications with require_interaction==true stay on-screen |
| 456 // rather than minimizing to the notification center after a timeout. | 466 // rather than minimizing to the notification center after a timeout. |
| 457 // On mobile, this is ignored (notifications are minimized at all times). | 467 // On mobile, this is ignored (notifications are minimized at all times). |
| 458 if (notification_data.require_interaction) | 468 if (notification_data.require_interaction) |
| 459 notification.set_never_timeout(true); | 469 notification.set_never_timeout(true); |
| 460 | 470 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 484 } | 494 } |
| 485 #endif | 495 #endif |
| 486 | 496 |
| 487 return base::string16(); | 497 return base::string16(); |
| 488 } | 498 } |
| 489 | 499 |
| 490 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( | 500 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( |
| 491 NotificationDisplayService* display_service) { | 501 NotificationDisplayService* display_service) { |
| 492 test_display_service_ = display_service; | 502 test_display_service_ = display_service; |
| 493 } | 503 } |
| OLD | NEW |