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

Unified Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 2337963003: Plumb through notification action types and placeholders on Android (Closed)
Patch Set: Responding to review comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/platform_notification_service_impl.cc
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
index 7b1472ac7d62e6cf12000c86bb5b7f3d667b9a75..4148ccd7e6bb6ee6929a7252fe1e02263adbb8f9 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
@@ -38,7 +39,9 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/common/notification_resources.h"
#include "content/public/common/platform_notification_data.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/message_center/notification.h"
#include "ui/message_center/notification_types.h"
#include "ui/message_center/notifier_settings.h"
#include "url/url_constants.h"
@@ -443,11 +446,24 @@ Notification PlatformNotificationServiceImpl::CreateNotificationFromData(
// Developer supplied action buttons.
std::vector<message_center::ButtonInfo> buttons;
for (size_t i = 0; i < notification_data.actions.size(); i++) {
- message_center::ButtonInfo button(notification_data.actions[i].title);
+ content::PlatformNotificationAction action = notification_data.actions[i];
Peter Beverloo 2016/09/26 16:04:34 nit: const& (right now we're making a copy, which
awdf 2016/09/27 14:45:27 Done. (Gah C++.. expect a lot more of these kinds
Peter Beverloo 2016/09/27 15:28:31 No problem at all! There's so many parts of the la
+ message_center::ButtonInfo button(action.title);
// TODO(peter): Handle different screen densities instead of always using
// the 1x bitmap - crbug.com/585815.
button.icon =
gfx::Image::CreateFrom1xBitmap(notification_resources.action_icons[i]);
+ button.placeholder =
+ action.placeholder.is_null()
+ ? l10n_util::GetStringUTF16(IDS_NOTIFICATION_REPLY_PLACEHOLDER)
+ : action.placeholder.string();
+ switch (action.type) {
+ case content::PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON:
+ button.type = message_center::ButtonType::BUTTON;
+ break;
+ case content::PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT:
+ button.type = message_center::ButtonType::TEXT;
+ break;
+ }
buttons.push_back(button);
}
notification.set_buttons(buttons);

Powered by Google App Engine
This is Rietveld 408576698