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 "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 11 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
12 #include "chrome/browser/notifications/notification_object_proxy.h" | 12 #include "chrome/browser/notifications/notification_object_proxy.h" |
13 #include "chrome/browser/notifications/notification_ui_manager.h" | 13 #include "chrome/browser/notifications/notification_ui_manager.h" |
14 #include "chrome/browser/notifications/persistent_notification_delegate.h" | 14 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_io_data.h" | 16 #include "chrome/browser/profiles/profile_io_data.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "components/content_settings/core/browser/host_content_settings_map.h" | 18 #include "components/content_settings/core/browser/host_content_settings_map.h" |
19 #include "components/content_settings/core/common/content_settings.h" | 19 #include "components/content_settings/core/common/content_settings.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/desktop_notification_delegate.h" | 21 #include "content/public/browser/desktop_notification_delegate.h" |
22 #include "content/public/browser/notification_event_dispatcher.h" | 22 #include "content/public/browser/notification_event_dispatcher.h" |
23 #include "content/public/browser/platform_notification_context.h" | 23 #include "content/public/browser/platform_notification_context.h" |
24 #include "content/public/browser/storage_partition.h" | 24 #include "content/public/browser/storage_partition.h" |
25 #include "content/public/common/platform_notification_action.h" | |
25 #include "content/public/common/platform_notification_data.h" | 26 #include "content/public/common/platform_notification_data.h" |
26 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
27 #include "ui/message_center/notifier_settings.h" | 28 #include "ui/message_center/notifier_settings.h" |
28 #include "url/url_constants.h" | 29 #include "url/url_constants.h" |
29 | 30 |
30 #if defined(ENABLE_EXTENSIONS) | 31 #if defined(ENABLE_EXTENSIONS) |
31 #include "chrome/browser/notifications/desktop_notification_service.h" | 32 #include "chrome/browser/notifications/desktop_notification_service.h" |
32 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 33 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
33 #include "extensions/browser/extension_registry.h" | 34 #include "extensions/browser/extension_registry.h" |
34 #include "extensions/browser/info_map.h" | 35 #include "extensions/browser/info_map.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 // different pixel density. Be smarter about this when the API gets updated | 329 // different pixel density. Be smarter about this when the API gets updated |
329 // with a way for developers to specify images of different resolutions. | 330 // with a way for developers to specify images of different resolutions. |
330 Notification notification(origin, notification_data.title, | 331 Notification notification(origin, notification_data.title, |
331 notification_data.body, gfx::Image::CreateFrom1xBitmap(icon), | 332 notification_data.body, gfx::Image::CreateFrom1xBitmap(icon), |
332 display_source, notification_data.tag, delegate); | 333 display_source, notification_data.tag, delegate); |
333 | 334 |
334 notification.set_context_message(display_source); | 335 notification.set_context_message(display_source); |
335 notification.set_vibration_pattern(notification_data.vibration_pattern); | 336 notification.set_vibration_pattern(notification_data.vibration_pattern); |
336 notification.set_silent(notification_data.silent); | 337 notification.set_silent(notification_data.silent); |
337 | 338 |
339 std::vector<message_center::ButtonInfo> buttons; | |
340 for (content::PlatformNotificationAction action : notification_data.actions) | |
Peter Beverloo
2015/07/30 17:02:04
const& to avoid the copies.
Fine to use auto.
johnme
2015/07/31 18:21:31
Done.
| |
341 buttons.push_back(message_center::ButtonInfo(action.title)); | |
342 notification.set_buttons(buttons); | |
Peter Beverloo
2015/07/30 17:02:05
micro nit: blank line above this one.
johnme
2015/07/31 18:21:31
Done.
| |
343 | |
338 // Web Notifications do not timeout. | 344 // Web Notifications do not timeout. |
339 notification.set_never_timeout(true); | 345 notification.set_never_timeout(true); |
340 | 346 |
341 return notification; | 347 return notification; |
342 } | 348 } |
343 | 349 |
344 NotificationUIManager* | 350 NotificationUIManager* |
345 PlatformNotificationServiceImpl::GetNotificationUIManager() const { | 351 PlatformNotificationServiceImpl::GetNotificationUIManager() const { |
346 if (notification_ui_manager_for_tests_) | 352 if (notification_ui_manager_for_tests_) |
347 return notification_ui_manager_for_tests_; | 353 return notification_ui_manager_for_tests_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 formatted_origin.push_back(':'); | 402 formatted_origin.push_back(':'); |
397 formatted_origin.append(base::UTF8ToUTF16(origin.port())); | 403 formatted_origin.append(base::UTF8ToUTF16(origin.port())); |
398 } | 404 } |
399 return formatted_origin; | 405 return formatted_origin; |
400 } | 406 } |
401 | 407 |
402 // TODO(dewittj): Once file:// URLs are passed in to the origin | 408 // TODO(dewittj): Once file:// URLs are passed in to the origin |
403 // GURL here, begin returning the path as the display name. | 409 // GURL here, begin returning the path as the display name. |
404 return net::FormatUrl(origin, languages); | 410 return net::FormatUrl(origin, languages); |
405 } | 411 } |
OLD | NEW |