| Index: tools/dom/templates/html/impl/impl_Window.darttemplate
|
| diff --git a/tools/dom/templates/html/impl/impl_Window.darttemplate b/tools/dom/templates/html/impl/impl_Window.darttemplate
|
| index 2f1c19438ab4c468e5fbda46b2cdff58ddf05a0b..74081311ee56338579ba05ecdf29743a739491aa 100644
|
| --- a/tools/dom/templates/html/impl/impl_Window.darttemplate
|
| +++ b/tools/dom/templates/html/impl/impl_Window.darttemplate
|
| @@ -231,10 +231,76 @@ $endif
|
| * lasting storage. This storage cannot be freed without the user's
|
| * permission. Returns a [Future] whose value stores a reference to the
|
| * sandboxed file system for use. Because the file system is sandboxed,
|
| - * applications cannot access file systems created in other web pages.
|
| + * applications cannot access file systems created in other web pages.
|
| */
|
| Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
|
| return _requestFileSystem(persistent? 1 : 0, size);
|
| }
|
| $!MEMBERS
|
| +
|
| + @DomName('DOMWindow.beforeunloadEvent')
|
| + @DocsEditable
|
| + static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
|
| + const _BeforeUnloadEventStreamProvider('beforeunload');
|
| +
|
| + @DomName('DOMWindow.onbeforeunload')
|
| + @DocsEditable
|
| + Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
|
| +}
|
| +
|
| +/**
|
| + * Event object that is fired before the window is closed.
|
| + *
|
| + * The standard window close behavior can be prevented by setting the
|
| + * [returnValue]. This will display a dialog to the user confirming that they
|
| + * want to close the page.
|
| + */
|
| +abstract class BeforeUnloadEvent implements Event {
|
| + /**
|
| + * If set to a non-null value, a dialog will be presented to the user
|
| + * confirming that they want to close the page.
|
| + */
|
| + String returnValue;
|
| +}
|
| +
|
| +class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent {
|
| + String _returnValue;
|
| +
|
| + _BeforeUnloadEvent(Event base): super(base);
|
| +
|
| + String get returnValue => _returnValue;
|
| +
|
| + void set returnValue(String value) {
|
| + _returnValue = value;
|
| +$if DART2JS
|
| + // FF and IE use the value as the return value, Chrome will return this from
|
| + // the event callback function.
|
| + if (JS('bool', '("returnValue" in #)', _base)) {
|
| + JS('void', '#.returnValue = #', _base, value);
|
| + }
|
| +$endif
|
| + }
|
| +}
|
| +
|
| +class _BeforeUnloadEventStreamProvider implements
|
| + EventStreamProvider<BeforeUnloadEvent> {
|
| + final String _eventType;
|
| +
|
| + const _BeforeUnloadEventStreamProvider(this._eventType);
|
| +
|
| + Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) {
|
| + var controller = new StreamController.broadcast();
|
| + var stream = new _EventStream(e, _eventType, useCapture);
|
| + stream.listen((event) {
|
| + var wrapped = new _BeforeUnloadEvent(event);
|
| + controller.add(wrapped);
|
| + return wrapped.returnValue;
|
| + });
|
| +
|
| + return controller.stream;
|
| + }
|
| +
|
| + String getEventType(EventTarget target) {
|
| + return _eventType;
|
| + }
|
| }
|
|
|