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/command_line.h" | |
8 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
9 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 11 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
13 #include "chrome/browser/notifications/notification_object_proxy.h" | 12 #include "chrome/browser/notifications/notification_object_proxy.h" |
14 #include "chrome/browser/notifications/notification_ui_manager.h" | 13 #include "chrome/browser/notifications/notification_ui_manager.h" |
15 #include "chrome/browser/notifications/persistent_notification_delegate.h" | 14 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_io_data.h" | 16 #include "chrome/browser/profiles/profile_io_data.h" |
18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
19 #include "components/content_settings/core/browser/host_content_settings_map.h" | 18 #include "components/content_settings/core/browser/host_content_settings_map.h" |
20 #include "components/content_settings/core/common/content_settings.h" | 19 #include "components/content_settings/core/common/content_settings.h" |
21 #include "components/url_formatter/url_formatter.h" | 20 #include "components/url_formatter/url_formatter.h" |
22 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/desktop_notification_delegate.h" | 22 #include "content/public/browser/desktop_notification_delegate.h" |
24 #include "content/public/browser/notification_event_dispatcher.h" | 23 #include "content/public/browser/notification_event_dispatcher.h" |
25 #include "content/public/browser/platform_notification_context.h" | 24 #include "content/public/browser/platform_notification_context.h" |
26 #include "content/public/browser/storage_partition.h" | 25 #include "content/public/browser/storage_partition.h" |
27 #include "content/public/common/content_switches.h" | |
28 #include "content/public/common/platform_notification_data.h" | 26 #include "content/public/common/platform_notification_data.h" |
29 #include "ui/message_center/notifier_settings.h" | 27 #include "ui/message_center/notifier_settings.h" |
30 #include "url/url_constants.h" | 28 #include "url/url_constants.h" |
31 | 29 |
32 #if defined(ENABLE_EXTENSIONS) | 30 #if defined(ENABLE_EXTENSIONS) |
33 #include "chrome/browser/notifications/notifier_state_tracker.h" | 31 #include "chrome/browser/notifications/notifier_state_tracker.h" |
34 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" | 32 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" |
35 #include "extensions/browser/extension_registry.h" | 33 #include "extensions/browser/extension_registry.h" |
36 #include "extensions/browser/info_map.h" | 34 #include "extensions/browser/info_map.h" |
37 #include "extensions/common/constants.h" | 35 #include "extensions/common/constants.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 339 |
342 std::vector<message_center::ButtonInfo> buttons; | 340 std::vector<message_center::ButtonInfo> buttons; |
343 for (const auto& action : notification_data.actions) | 341 for (const auto& action : notification_data.actions) |
344 buttons.push_back(message_center::ButtonInfo(action.title)); | 342 buttons.push_back(message_center::ButtonInfo(action.title)); |
345 | 343 |
346 notification.set_buttons(buttons); | 344 notification.set_buttons(buttons); |
347 | 345 |
348 // On desktop, notifications with require_interaction==true stay on-screen | 346 // On desktop, notifications with require_interaction==true stay on-screen |
349 // rather than minimizing to the notification center after a timeout. | 347 // rather than minimizing to the notification center after a timeout. |
350 // On mobile, this is ignored (notifications are minimized at all times). | 348 // On mobile, this is ignored (notifications are minimized at all times). |
351 if (notification_data.require_interaction || | 349 if (notification_data.require_interaction) |
352 !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
353 switches::kEnableExperimentalWebPlatformFeatures)) { | |
354 notification.set_never_timeout(true); | 350 notification.set_never_timeout(true); |
355 } | |
356 | 351 |
357 return notification; | 352 return notification; |
358 } | 353 } |
359 | 354 |
360 NotificationUIManager* | 355 NotificationUIManager* |
361 PlatformNotificationServiceImpl::GetNotificationUIManager() const { | 356 PlatformNotificationServiceImpl::GetNotificationUIManager() const { |
362 if (notification_ui_manager_for_tests_) | 357 if (notification_ui_manager_for_tests_) |
363 return notification_ui_manager_for_tests_; | 358 return notification_ui_manager_for_tests_; |
364 | 359 |
365 return g_browser_process->notification_ui_manager(); | 360 return g_browser_process->notification_ui_manager(); |
(...skipping 14 matching lines...) Expand all Loading... |
380 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 375 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
381 origin.host(), extensions::ExtensionRegistry::EVERYTHING); | 376 origin.host(), extensions::ExtensionRegistry::EVERYTHING); |
382 DCHECK(extension); | 377 DCHECK(extension); |
383 | 378 |
384 return base::UTF8ToUTF16(extension->name()); | 379 return base::UTF8ToUTF16(extension->name()); |
385 } | 380 } |
386 #endif | 381 #endif |
387 | 382 |
388 return base::string16(); | 383 return base::string16(); |
389 } | 384 } |
OLD | NEW |