Commit c9c799b1 authored by bashi@chromium.org's avatar bashi@chromium.org

Add NotificationOptions

Use IDL dictionary (NotificationOptions) instead of generic
Dictionary. Tests under fast/notifications are passed.

BUG=403150

Review URL: https://codereview.chromium.org/556193002

git-svn-id: svn://svn.chromium.org/blink/trunk@181879 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7b0f9402
...@@ -276,6 +276,7 @@ ...@@ -276,6 +276,7 @@
'websockets/CloseEvent.idl', 'websockets/CloseEvent.idl',
], ],
'modules_dictionary_idl_files': [ 'modules_dictionary_idl_files': [
'notifications/NotificationOptions.idl',
'webmidi/MIDIOptions.idl', 'webmidi/MIDIOptions.idl',
], ],
'generated_modules_files': [ 'generated_modules_files': [
...@@ -290,6 +291,8 @@ ...@@ -290,6 +291,8 @@
'<(blink_modules_output_dir)/IndexedDBNames.h', '<(blink_modules_output_dir)/IndexedDBNames.h',
], ],
'generated_modules_dictionary_files': [ 'generated_modules_dictionary_files': [
'<(blink_modules_output_dir)/notifications/NotificationOptions.cpp',
'<(blink_modules_output_dir)/notifications/NotificationOptions.h',
'<(blink_modules_output_dir)/webmidi/MIDIOptions.cpp', '<(blink_modules_output_dir)/webmidi/MIDIOptions.cpp',
'<(blink_modules_output_dir)/webmidi/MIDIOptions.h', '<(blink_modules_output_dir)/webmidi/MIDIOptions.h',
], ],
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "config.h" #include "config.h"
#include "modules/notifications/Notification.h" #include "modules/notifications/Notification.h"
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ScriptWrappable.h" #include "bindings/core/v8/ScriptWrappable.h"
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/events/Event.h" #include "core/events/Event.h"
...@@ -39,26 +38,22 @@ ...@@ -39,26 +38,22 @@
#include "core/page/WindowFocusAllowedIndicator.h" #include "core/page/WindowFocusAllowedIndicator.h"
#include "modules/notifications/NotificationClient.h" #include "modules/notifications/NotificationClient.h"
#include "modules/notifications/NotificationController.h" #include "modules/notifications/NotificationController.h"
#include "modules/notifications/NotificationOptions.h"
#include "modules/notifications/NotificationPermissionClient.h" #include "modules/notifications/NotificationPermissionClient.h"
namespace blink { namespace blink {
Notification* Notification::create(ExecutionContext* context, const String& title, const Dictionary& options) Notification* Notification::create(ExecutionContext* context, const String& title, const NotificationOptions& options)
{ {
NotificationClient& client = NotificationController::clientFrom(context); NotificationClient& client = NotificationController::clientFrom(context);
Notification* notification = adoptRefCountedGarbageCollectedWillBeNoop(new Notification(title, context, &client)); Notification* notification = adoptRefCountedGarbageCollectedWillBeNoop(new Notification(title, context, &client));
String argument; notification->setBody(options.body());
if (DictionaryHelper::get(options, "body", argument)) notification->setTag(options.tag());
notification->setBody(argument); notification->setLang(options.lang());
if (DictionaryHelper::get(options, "tag", argument)) notification->setDir(options.dir());
notification->setTag(argument); if (options.hasIcon()) {
if (DictionaryHelper::get(options, "lang", argument)) KURL iconUrl = options.icon().isEmpty() ? KURL() : context->completeURL(options.icon());
notification->setLang(argument);
if (DictionaryHelper::get(options, "dir", argument))
notification->setDir(argument);
if (DictionaryHelper::get(options, "icon", argument)) {
KURL iconUrl = argument.isEmpty() ? KURL() : context->completeURL(argument);
if (!iconUrl.isEmpty() && iconUrl.isValid()) if (!iconUrl.isEmpty() && iconUrl.isValid())
notification->setIconUrl(iconUrl); notification->setIconUrl(iconUrl);
} }
......
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
namespace blink { namespace blink {
class Dictionary;
class ExecutionContext; class ExecutionContext;
class NotificationOptions;
class NotificationPermissionCallback; class NotificationPermissionCallback;
class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<Notification>, public ActiveDOMObject, public EventTargetWithInlineData { class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<Notification>, public ActiveDOMObject, public EventTargetWithInlineData {
...@@ -52,7 +52,7 @@ class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFina ...@@ -52,7 +52,7 @@ class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFina
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification);
public: public:
static Notification* create(ExecutionContext*, const String& title, const Dictionary& options); static Notification* create(ExecutionContext*, const String& title, const NotificationOptions&);
virtual ~Notification(); virtual ~Notification();
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
[ [
GarbageCollected, GarbageCollected,
ActiveDOMObject, ActiveDOMObject,
Constructor(DOMString title, [Default=Undefined] optional Dictionary options), Constructor(DOMString title, optional NotificationOptions options),
ConstructorCallWith=ExecutionContext, ConstructorCallWith=ExecutionContext,
RuntimeEnabled=Notifications, RuntimeEnabled=Notifications,
] interface Notification : EventTarget { ] interface Notification : EventTarget {
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// http://notifications.spec.whatwg.org/#api
enum NotificationDirection {
"auto",
"ltr",
"rtl"
};
[
GarbageCollected
] dictionary NotificationOptions {
NotificationDirection dir = "auto";
DOMString lang = "";
DOMString body = "";
DOMString tag = "";
DOMString icon;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment