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 @@
'websockets/CloseEvent.idl',
],
'modules_dictionary_idl_files': [
'notifications/NotificationOptions.idl',
'webmidi/MIDIOptions.idl',
],
'generated_modules_files': [
......@@ -290,6 +291,8 @@
'<(blink_modules_output_dir)/IndexedDBNames.h',
],
'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.h',
],
......
......@@ -31,7 +31,6 @@
#include "config.h"
#include "modules/notifications/Notification.h"
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ScriptWrappable.h"
#include "core/dom/Document.h"
#include "core/events/Event.h"
......@@ -39,26 +38,22 @@
#include "core/page/WindowFocusAllowedIndicator.h"
#include "modules/notifications/NotificationClient.h"
#include "modules/notifications/NotificationController.h"
#include "modules/notifications/NotificationOptions.h"
#include "modules/notifications/NotificationPermissionClient.h"
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);
Notification* notification = adoptRefCountedGarbageCollectedWillBeNoop(new Notification(title, context, &client));
String argument;
if (DictionaryHelper::get(options, "body", argument))
notification->setBody(argument);
if (DictionaryHelper::get(options, "tag", argument))
notification->setTag(argument);
if (DictionaryHelper::get(options, "lang", argument))
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);
notification->setBody(options.body());
notification->setTag(options.tag());
notification->setLang(options.lang());
notification->setDir(options.dir());
if (options.hasIcon()) {
KURL iconUrl = options.icon().isEmpty() ? KURL() : context->completeURL(options.icon());
if (!iconUrl.isEmpty() && iconUrl.isValid())
notification->setIconUrl(iconUrl);
}
......
......@@ -43,8 +43,8 @@
namespace blink {
class Dictionary;
class ExecutionContext;
class NotificationOptions;
class NotificationPermissionCallback;
class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<Notification>, public ActiveDOMObject, public EventTargetWithInlineData {
......@@ -52,7 +52,7 @@ class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFina
DEFINE_WRAPPERTYPEINFO();
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification);
public:
static Notification* create(ExecutionContext*, const String& title, const Dictionary& options);
static Notification* create(ExecutionContext*, const String& title, const NotificationOptions&);
virtual ~Notification();
......
......@@ -32,7 +32,7 @@
[
GarbageCollected,
ActiveDOMObject,
Constructor(DOMString title, [Default=Undefined] optional Dictionary options),
Constructor(DOMString title, optional NotificationOptions options),
ConstructorCallWith=ExecutionContext,
RuntimeEnabled=Notifications,
] 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