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

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

Issue 2337963003: Plumb through notification action types and placeholders on Android (Closed)
Patch Set: Final review nits Created 4 years, 2 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
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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/metrics/user_metrics_action.h" 12 #include "base/metrics/user_metrics_action.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
17 #include "chrome/browser/notifications/notification_display_service_factory.h" 17 #include "chrome/browser/notifications/notification_display_service_factory.h"
18 #include "chrome/browser/notifications/notification_object_proxy.h" 18 #include "chrome/browser/notifications/notification_object_proxy.h"
19 #include "chrome/browser/notifications/persistent_notification_delegate.h" 19 #include "chrome/browser/notifications/persistent_notification_delegate.h"
20 #include "chrome/browser/permissions/permission_manager.h" 20 #include "chrome/browser/permissions/permission_manager.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_attributes_storage.h" 22 #include "chrome/browser/profiles/profile_attributes_storage.h"
23 #include "chrome/browser/profiles/profile_io_data.h" 23 #include "chrome/browser/profiles/profile_io_data.h"
24 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
28 #include "chrome/grit/generated_resources.h"
28 #include "components/content_settings/core/browser/host_content_settings_map.h" 29 #include "components/content_settings/core/browser/host_content_settings_map.h"
29 #include "components/content_settings/core/common/content_settings.h" 30 #include "components/content_settings/core/common/content_settings.h"
30 #include "components/content_settings/core/common/content_settings_types.h" 31 #include "components/content_settings/core/common/content_settings_types.h"
31 #include "components/prefs/pref_service.h" 32 #include "components/prefs/pref_service.h"
32 #include "components/url_formatter/url_formatter.h" 33 #include "components/url_formatter/url_formatter.h"
33 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/desktop_notification_delegate.h" 35 #include "content/public/browser/desktop_notification_delegate.h"
35 #include "content/public/browser/notification_event_dispatcher.h" 36 #include "content/public/browser/notification_event_dispatcher.h"
36 #include "content/public/browser/permission_type.h" 37 #include "content/public/browser/permission_type.h"
37 #include "content/public/browser/storage_partition.h" 38 #include "content/public/browser/storage_partition.h"
38 #include "content/public/browser/user_metrics.h" 39 #include "content/public/browser/user_metrics.h"
39 #include "content/public/common/notification_resources.h" 40 #include "content/public/common/notification_resources.h"
40 #include "content/public/common/platform_notification_data.h" 41 #include "content/public/common/platform_notification_data.h"
42 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
44 #include "ui/message_center/notification.h"
42 #include "ui/message_center/notification_types.h" 45 #include "ui/message_center/notification_types.h"
43 #include "ui/message_center/notifier_settings.h" 46 #include "ui/message_center/notifier_settings.h"
44 #include "url/url_constants.h" 47 #include "url/url_constants.h"
45 48
46 #if defined(ENABLE_EXTENSIONS) 49 #if defined(ENABLE_EXTENSIONS)
47 #include "chrome/browser/notifications/notifier_state_tracker.h" 50 #include "chrome/browser/notifications/notifier_state_tracker.h"
48 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" 51 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
49 #include "extensions/browser/extension_registry.h" 52 #include "extensions/browser/extension_registry.h"
50 #include "extensions/browser/info_map.h" 53 #include "extensions/browser/info_map.h"
51 #include "extensions/common/constants.h" 54 #include "extensions/common/constants.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 #if defined(OS_ANDROID) 439 #if defined(OS_ANDROID)
437 // TODO(peter): Handle different screen densities instead of always using the 440 // TODO(peter): Handle different screen densities instead of always using the
438 // 1x bitmap - crbug.com/585815. 441 // 1x bitmap - crbug.com/585815.
439 notification.set_small_image( 442 notification.set_small_image(
440 gfx::Image::CreateFrom1xBitmap(notification_resources.badge)); 443 gfx::Image::CreateFrom1xBitmap(notification_resources.badge));
441 #endif // defined(OS_ANDROID) 444 #endif // defined(OS_ANDROID)
442 445
443 // Developer supplied action buttons. 446 // Developer supplied action buttons.
444 std::vector<message_center::ButtonInfo> buttons; 447 std::vector<message_center::ButtonInfo> buttons;
445 for (size_t i = 0; i < notification_data.actions.size(); i++) { 448 for (size_t i = 0; i < notification_data.actions.size(); i++) {
446 message_center::ButtonInfo button(notification_data.actions[i].title); 449 content::PlatformNotificationAction const& action =
450 notification_data.actions[i];
451 message_center::ButtonInfo button(action.title);
447 // TODO(peter): Handle different screen densities instead of always using 452 // TODO(peter): Handle different screen densities instead of always using
448 // the 1x bitmap - crbug.com/585815. 453 // the 1x bitmap - crbug.com/585815.
449 button.icon = 454 button.icon =
450 gfx::Image::CreateFrom1xBitmap(notification_resources.action_icons[i]); 455 gfx::Image::CreateFrom1xBitmap(notification_resources.action_icons[i]);
456 button.placeholder =
457 action.placeholder.is_null()
458 ? l10n_util::GetStringUTF16(IDS_NOTIFICATION_REPLY_PLACEHOLDER)
459 : action.placeholder.string();
460 switch (action.type) {
461 case content::PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON:
462 button.type = message_center::ButtonType::BUTTON;
463 break;
464 case content::PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT:
465 button.type = message_center::ButtonType::TEXT;
466 break;
467 }
451 buttons.push_back(button); 468 buttons.push_back(button);
452 } 469 }
453 notification.set_buttons(buttons); 470 notification.set_buttons(buttons);
454 471
455 // On desktop, notifications with require_interaction==true stay on-screen 472 // On desktop, notifications with require_interaction==true stay on-screen
456 // rather than minimizing to the notification center after a timeout. 473 // rather than minimizing to the notification center after a timeout.
457 // On mobile, this is ignored (notifications are minimized at all times). 474 // On mobile, this is ignored (notifications are minimized at all times).
458 if (notification_data.require_interaction) 475 if (notification_data.require_interaction)
459 notification.set_never_timeout(true); 476 notification.set_never_timeout(true);
460 477
(...skipping 23 matching lines...) Expand all
484 } 501 }
485 #endif 502 #endif
486 503
487 return base::string16(); 504 return base::string16();
488 } 505 }
489 506
490 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( 507 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting(
491 NotificationDisplayService* display_service) { 508 NotificationDisplayService* display_service) {
492 test_display_service_ = display_service; 509 test_display_service_ = display_service;
493 } 510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698