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

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: Created 4 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
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"
(...skipping 24 matching lines...) Expand all
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/desktop_notification_delegate.h" 36 #include "content/public/browser/desktop_notification_delegate.h"
37 #include "content/public/browser/notification_event_dispatcher.h" 37 #include "content/public/browser/notification_event_dispatcher.h"
38 #include "content/public/browser/permission_type.h" 38 #include "content/public/browser/permission_type.h"
39 #include "content/public/browser/platform_notification_context.h" 39 #include "content/public/browser/platform_notification_context.h"
40 #include "content/public/browser/storage_partition.h" 40 #include "content/public/browser/storage_partition.h"
41 #include "content/public/browser/user_metrics.h" 41 #include "content/public/browser/user_metrics.h"
42 #include "content/public/common/notification_resources.h" 42 #include "content/public/common/notification_resources.h"
43 #include "content/public/common/platform_notification_data.h" 43 #include "content/public/common/platform_notification_data.h"
44 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
45 #include "ui/message_center/notification.h"
45 #include "ui/message_center/notification_types.h" 46 #include "ui/message_center/notification_types.h"
46 #include "ui/message_center/notifier_settings.h" 47 #include "ui/message_center/notifier_settings.h"
47 #include "url/url_constants.h" 48 #include "url/url_constants.h"
48 49
49 #if defined(ENABLE_EXTENSIONS) 50 #if defined(ENABLE_EXTENSIONS)
50 #include "chrome/browser/notifications/notifier_state_tracker.h" 51 #include "chrome/browser/notifications/notifier_state_tracker.h"
51 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" 52 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
52 #include "extensions/browser/extension_registry.h" 53 #include "extensions/browser/extension_registry.h"
53 #include "extensions/browser/info_map.h" 54 #include "extensions/browser/info_map.h"
54 #include "extensions/common/constants.h" 55 #include "extensions/common/constants.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 #endif // defined(OS_ANDROID) 473 #endif // defined(OS_ANDROID)
473 474
474 // Developer supplied action buttons. 475 // Developer supplied action buttons.
475 std::vector<message_center::ButtonInfo> buttons; 476 std::vector<message_center::ButtonInfo> buttons;
476 for (size_t i = 0; i < notification_data.actions.size(); i++) { 477 for (size_t i = 0; i < notification_data.actions.size(); i++) {
477 message_center::ButtonInfo button(notification_data.actions[i].title); 478 message_center::ButtonInfo button(notification_data.actions[i].title);
478 // TODO(peter): Handle different screen densities instead of always using 479 // TODO(peter): Handle different screen densities instead of always using
479 // the 1x bitmap - crbug.com/585815. 480 // the 1x bitmap - crbug.com/585815.
480 button.icon = 481 button.icon =
481 gfx::Image::CreateFrom1xBitmap(notification_resources.action_icons[i]); 482 gfx::Image::CreateFrom1xBitmap(notification_resources.action_icons[i]);
483 button.placeholder = notification_data.actions[i].placeholder;
484 switch (notification_data.actions[i].type) {
485 case content::PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON:
486 button.type = message_center::NotificationActionType::BUTTON;
487 break;
488 case content::PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT:
489 button.type = message_center::NotificationActionType::TEXT;
490 break;
491 }
482 buttons.push_back(button); 492 buttons.push_back(button);
483 } 493 }
484 notification.set_buttons(buttons); 494 notification.set_buttons(buttons);
485 495
486 // On desktop, notifications with require_interaction==true stay on-screen 496 // On desktop, notifications with require_interaction==true stay on-screen
487 // rather than minimizing to the notification center after a timeout. 497 // rather than minimizing to the notification center after a timeout.
488 // On mobile, this is ignored (notifications are minimized at all times). 498 // On mobile, this is ignored (notifications are minimized at all times).
489 if (notification_data.require_interaction) 499 if (notification_data.require_interaction)
490 notification.set_never_timeout(true); 500 notification.set_never_timeout(true);
491 501
(...skipping 23 matching lines...) Expand all
515 } 525 }
516 #endif 526 #endif
517 527
518 return base::string16(); 528 return base::string16();
519 } 529 }
520 530
521 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( 531 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting(
522 NotificationDisplayService* display_service) { 532 NotificationDisplayService* display_service) {
523 test_display_service_ = display_service; 533 test_display_service_ = display_service;
524 } 534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698