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

Unified Diff: Source/modules/notifications/Notification.cpp

Issue 1093243003: [WIP] add "auto" attr in notifications Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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: Source/modules/notifications/Notification.cpp
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
index 1dd3a947ddb0548d6fcab6eca34bee9fbbf68786..461ee1c9c161a53b4e4ba8d5adeedeb7f1c6425a 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -167,7 +167,7 @@ void Notification::show()
ASSERT(origin);
// FIXME: Do CSP checks on the associated notification icon.
- WebNotificationData::Direction dir = m_dir == "rtl" ? WebNotificationData::DirectionRightToLeft : WebNotificationData::DirectionLeftToRight;
+ WebNotificationData::Direction dir = directionStringToEnum(m_dir);
// The lifetime and availability of non-persistent notifications is tied to the page
// they were created by, and thus the data doesn't have to be known to the embedder.
@@ -227,12 +227,6 @@ void Notification::dispatchCloseEvent()
dispatchEvent(Event::create(EventTypeNames::close));
}
-TextDirection Notification::direction() const
-{
- // FIXME: Resolve dir()=="auto" against the document.
- return dir() == "rtl" ? RTL : LTR;
-}
-
String Notification::permissionString(WebNotificationPermission permission)
{
switch (permission) {
@@ -248,6 +242,21 @@ String Notification::permissionString(WebNotificationPermission permission)
return "denied";
}
+WebNotificationData Notification::directionStringToEnum(String direction)
+{
+ switch (direction) {
+ case "ltr":
+ return DirectionLeftToRight;
+ case "rtl":
+ return DirectionRightToLeft;
+ case "auto":
+ return DirectionAuto;
+ }
+
+ ASSERT_NOT_REACHED();
+ return DirectionAuto;
+}
+
String Notification::permission(ExecutionContext* context)
{
return permissionString(checkPermission(context));
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | public/platform/modules/notifications/WebNotificationData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698