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

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

Issue 1313363006: Plumb requireInteraction to PlatformNotificationData & database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@constructor
Patch Set: Fix includes Created 5 years, 3 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
« no previous file with comments | « no previous file | content/browser/notifications/notification_database_data.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
7 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
8 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 12 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
12 #include "chrome/browser/notifications/notification_object_proxy.h" 13 #include "chrome/browser/notifications/notification_object_proxy.h"
13 #include "chrome/browser/notifications/notification_ui_manager.h" 14 #include "chrome/browser/notifications/notification_ui_manager.h"
14 #include "chrome/browser/notifications/persistent_notification_delegate.h" 15 #include "chrome/browser/notifications/persistent_notification_delegate.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/profiles/profile_io_data.h" 17 #include "chrome/browser/profiles/profile_io_data.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "components/content_settings/core/browser/host_content_settings_map.h" 19 #include "components/content_settings/core/browser/host_content_settings_map.h"
19 #include "components/content_settings/core/common/content_settings.h" 20 #include "components/content_settings/core/common/content_settings.h"
20 #include "components/url_formatter/url_formatter.h" 21 #include "components/url_formatter/url_formatter.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/desktop_notification_delegate.h" 23 #include "content/public/browser/desktop_notification_delegate.h"
23 #include "content/public/browser/notification_event_dispatcher.h" 24 #include "content/public/browser/notification_event_dispatcher.h"
24 #include "content/public/browser/platform_notification_context.h" 25 #include "content/public/browser/platform_notification_context.h"
25 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
27 #include "content/public/common/content_switches.h"
26 #include "content/public/common/platform_notification_data.h" 28 #include "content/public/common/platform_notification_data.h"
27 #include "ui/message_center/notifier_settings.h" 29 #include "ui/message_center/notifier_settings.h"
28 #include "url/url_constants.h" 30 #include "url/url_constants.h"
29 31
30 #if defined(ENABLE_EXTENSIONS) 32 #if defined(ENABLE_EXTENSIONS)
31 #include "chrome/browser/notifications/notifier_state_tracker.h" 33 #include "chrome/browser/notifications/notifier_state_tracker.h"
32 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" 34 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
33 #include "extensions/browser/extension_registry.h" 35 #include "extensions/browser/extension_registry.h"
34 #include "extensions/browser/info_map.h" 36 #include "extensions/browser/info_map.h"
35 #include "extensions/common/constants.h" 37 #include "extensions/common/constants.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 DisplayNameForContextMessage(profile, origin)); 338 DisplayNameForContextMessage(profile, origin));
337 notification.set_vibration_pattern(notification_data.vibration_pattern); 339 notification.set_vibration_pattern(notification_data.vibration_pattern);
338 notification.set_silent(notification_data.silent); 340 notification.set_silent(notification_data.silent);
339 341
340 std::vector<message_center::ButtonInfo> buttons; 342 std::vector<message_center::ButtonInfo> buttons;
341 for (const auto& action : notification_data.actions) 343 for (const auto& action : notification_data.actions)
342 buttons.push_back(message_center::ButtonInfo(action.title)); 344 buttons.push_back(message_center::ButtonInfo(action.title));
343 345
344 notification.set_buttons(buttons); 346 notification.set_buttons(buttons);
345 347
346 // Web Notifications do not timeout. 348 // On desktop, notifications with require_interaction==true stay on-screen
347 notification.set_never_timeout(true); 349 // rather than minimizing to the notification center after a timeout.
350 // On mobile, this is ignored (notifications are minimized at all times).
351 if (notification_data.require_interaction ||
352 !base::CommandLine::ForCurrentProcess()->HasSwitch(
353 switches::kEnableExperimentalWebPlatformFeatures)) {
354 notification.set_never_timeout(true);
355 }
348 356
349 return notification; 357 return notification;
350 } 358 }
351 359
352 NotificationUIManager* 360 NotificationUIManager*
353 PlatformNotificationServiceImpl::GetNotificationUIManager() const { 361 PlatformNotificationServiceImpl::GetNotificationUIManager() const {
354 if (notification_ui_manager_for_tests_) 362 if (notification_ui_manager_for_tests_)
355 return notification_ui_manager_for_tests_; 363 return notification_ui_manager_for_tests_;
356 364
357 return g_browser_process->notification_ui_manager(); 365 return g_browser_process->notification_ui_manager();
(...skipping 14 matching lines...) Expand all
372 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( 380 extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
373 origin.host(), extensions::ExtensionRegistry::EVERYTHING); 381 origin.host(), extensions::ExtensionRegistry::EVERYTHING);
374 DCHECK(extension); 382 DCHECK(extension);
375 383
376 return base::UTF8ToUTF16(extension->name()); 384 return base::UTF8ToUTF16(extension->name());
377 } 385 }
378 #endif 386 #endif
379 387
380 return base::string16(); 388 return base::string16();
381 } 389 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/notifications/notification_database_data.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698