Commit 754c1994 authored by avayvod@chromium.org's avatar avayvod@chromium.org

Added a module for the Presentation API implementation and a dummy...

Added a module for the Presentation API implementation and a dummy navigator.presentation.onavailablechange IDL.

BUG=412331

Intent to implement on blink-dev: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/J0ToSdOQVP8

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

git-svn-id: svn://svn.chromium.org/blink/trunk@181975 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6a5150f5
...@@ -44,6 +44,7 @@ PASS window.cached_navigator.userAgent is '' ...@@ -44,6 +44,7 @@ PASS window.cached_navigator.userAgent is ''
PASS window.cached_navigator.vendor is window.navigator.vendor PASS window.cached_navigator.vendor is window.navigator.vendor
PASS window.cached_navigator.vendorSub is '' PASS window.cached_navigator.vendorSub is ''
PASS window.cached_navigator_connection.ontypechange is null PASS window.cached_navigator_connection.ontypechange is null
PASS window.cached_navigator_presentation.onavailablechange is null
PASS window.cached_navigator_serviceWorker.controller is null PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_performance.onwebkitresourcetimingbufferfull is null PASS window.cached_performance.onwebkitresourcetimingbufferfull is null
PASS window.cached_performance_navigation.redirectCount is 0 PASS window.cached_performance_navigation.redirectCount is 0
......
...@@ -44,6 +44,7 @@ PASS window.cached_navigator.userAgent is '' ...@@ -44,6 +44,7 @@ PASS window.cached_navigator.userAgent is ''
PASS window.cached_navigator.vendor is window.navigator.vendor PASS window.cached_navigator.vendor is window.navigator.vendor
PASS window.cached_navigator.vendorSub is '' PASS window.cached_navigator.vendorSub is ''
PASS window.cached_navigator_connection.ontypechange is null PASS window.cached_navigator_connection.ontypechange is null
PASS window.cached_navigator_presentation.onavailablechange is null
PASS window.cached_navigator_serviceWorker.controller is null PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_performance.onwebkitresourcetimingbufferfull is null PASS window.cached_performance.onwebkitresourcetimingbufferfull is null
PASS window.cached_performance_navigation.redirectCount is 0 PASS window.cached_performance_navigation.redirectCount is 0
......
...@@ -44,6 +44,7 @@ PASS window.cached_navigator.userAgent is '' ...@@ -44,6 +44,7 @@ PASS window.cached_navigator.userAgent is ''
PASS window.cached_navigator.vendor is window.navigator.vendor PASS window.cached_navigator.vendor is window.navigator.vendor
PASS window.cached_navigator.vendorSub is '' PASS window.cached_navigator.vendorSub is ''
PASS window.cached_navigator_connection.ontypechange is null PASS window.cached_navigator_connection.ontypechange is null
PASS window.cached_navigator_presentation.onavailablechange is null
PASS window.cached_navigator_serviceWorker.controller is null PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_performance.onwebkitresourcetimingbufferfull is null PASS window.cached_performance.onwebkitresourcetimingbufferfull is null
PASS window.cached_performance_navigation.redirectCount is 0 PASS window.cached_performance_navigation.redirectCount is 0
......
...@@ -50,6 +50,7 @@ PASS oldChildWindow.navigator.language is newChildWindow.navigator.language ...@@ -50,6 +50,7 @@ PASS oldChildWindow.navigator.language is newChildWindow.navigator.language
PASS oldChildWindow.navigator.maxTouchPoints is newChildWindow.navigator.maxTouchPoints PASS oldChildWindow.navigator.maxTouchPoints is newChildWindow.navigator.maxTouchPoints
PASS oldChildWindow.navigator.onLine is newChildWindow.navigator.onLine PASS oldChildWindow.navigator.onLine is newChildWindow.navigator.onLine
PASS oldChildWindow.navigator.platform is newChildWindow.navigator.platform PASS oldChildWindow.navigator.platform is newChildWindow.navigator.platform
PASS oldChildWindow.navigator.presentation.onavailablechange is newChildWindow.navigator.presentation.onavailablechange
PASS oldChildWindow.navigator.product is newChildWindow.navigator.product PASS oldChildWindow.navigator.product is newChildWindow.navigator.product
PASS oldChildWindow.navigator.productSub is newChildWindow.navigator.productSub PASS oldChildWindow.navigator.productSub is newChildWindow.navigator.productSub
PASS oldChildWindow.navigator.serviceWorker.controller is newChildWindow.navigator.serviceWorker.controller PASS oldChildWindow.navigator.serviceWorker.controller is newChildWindow.navigator.serviceWorker.controller
......
...@@ -50,6 +50,7 @@ PASS childWindow.navigator.language is window.navigator.language ...@@ -50,6 +50,7 @@ PASS childWindow.navigator.language is window.navigator.language
PASS childWindow.navigator.maxTouchPoints is 0 PASS childWindow.navigator.maxTouchPoints is 0
PASS childWindow.navigator.onLine is window.navigator.onLine PASS childWindow.navigator.onLine is window.navigator.onLine
PASS childWindow.navigator.platform is window.navigator.platform PASS childWindow.navigator.platform is window.navigator.platform
FAIL childWindow.navigator.presentation.onavailablechange should be null. Threw exception TypeError: Cannot read property 'onavailablechange' of null
PASS childWindow.navigator.product is window.navigator.product PASS childWindow.navigator.product is window.navigator.product
PASS childWindow.navigator.productSub is window.navigator.productSub PASS childWindow.navigator.productSub is window.navigator.productSub
FAIL childWindow.navigator.serviceWorker.controller should be null. Threw exception TypeError: Cannot read property 'controller' of null FAIL childWindow.navigator.serviceWorker.controller should be null. Threw exception TypeError: Cannot read property 'controller' of null
......
...@@ -49,6 +49,7 @@ PASS childWindow.navigator.language is window.navigator.language ...@@ -49,6 +49,7 @@ PASS childWindow.navigator.language is window.navigator.language
PASS childWindow.navigator.maxTouchPoints is 0 PASS childWindow.navigator.maxTouchPoints is 0
PASS childWindow.navigator.onLine is window.navigator.onLine PASS childWindow.navigator.onLine is window.navigator.onLine
PASS childWindow.navigator.platform is window.navigator.platform PASS childWindow.navigator.platform is window.navigator.platform
PASS childWindow.navigator.presentation.onavailablechange is null
PASS childWindow.navigator.product is window.navigator.product PASS childWindow.navigator.product is window.navigator.product
PASS childWindow.navigator.productSub is window.navigator.productSub PASS childWindow.navigator.productSub is window.navigator.productSub
PASS childWindow.navigator.serviceWorker.controller is null PASS childWindow.navigator.serviceWorker.controller is null
......
<!DOCTYPE html>
<html>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
test(function() {
assert_true('presentation' in navigator);
assert_true('onavailablechange' in navigator.presentation);
}, "Test that the Presentation API is present.")
test(function() {
assert_equals(typeof(navigator.presentation), "object");
assert_equals(typeof(navigator.presentation.onavailablechange), "object");
}, "Test the Presentation API property types.");
test(function() {
assert_true(navigator.presentation instanceof EventTarget);
}, "Test that navigator.presentation is an EventTarget.");
</script>
</body>
</html>
...@@ -280,6 +280,7 @@ PeriodicWave ...@@ -280,6 +280,7 @@ PeriodicWave
Plugin Plugin
PluginArray PluginArray
PopStateEvent PopStateEvent
Presentation
ProcessingInstruction ProcessingInstruction
ProgressEvent ProgressEvent
Promise Promise
......
...@@ -23,6 +23,7 @@ audioprocess ...@@ -23,6 +23,7 @@ audioprocess
audiostart audiostart
autocomplete autocomplete
autocompleteerror autocompleteerror
availablechange
beforecopy beforecopy
beforecut beforecut
beforepaste beforepaste
......
...@@ -18,6 +18,7 @@ modules/mediastream/RTCDataChannel ...@@ -18,6 +18,7 @@ modules/mediastream/RTCDataChannel
modules/mediastream/RTCPeerConnection modules/mediastream/RTCPeerConnection
modules/netinfo/NetworkInformation modules/netinfo/NetworkInformation
modules/notifications/Notification modules/notifications/Notification
modules/presentation/Presentation
modules/screen_orientation/ScreenOrientation modules/screen_orientation/ScreenOrientation
modules/serviceworkers/ServiceWorker modules/serviceworkers/ServiceWorker
modules/serviceworkers/ServiceWorkerGlobalScope modules/serviceworkers/ServiceWorkerGlobalScope
......
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
'notifications/Notification.idl', 'notifications/Notification.idl',
'notifications/NotificationPermissionCallback.idl', 'notifications/NotificationPermissionCallback.idl',
'performance/WorkerPerformance.idl', 'performance/WorkerPerformance.idl',
'presentation/Presentation.idl',
'push_messaging/PushEvent.idl', 'push_messaging/PushEvent.idl',
'push_messaging/PushManager.idl', 'push_messaging/PushManager.idl',
'push_messaging/PushRegistration.idl', 'push_messaging/PushRegistration.idl',
...@@ -234,6 +235,7 @@ ...@@ -234,6 +235,7 @@
'netinfo/WorkerNavigatorNetworkInformation.idl', 'netinfo/WorkerNavigatorNetworkInformation.idl',
'performance/SharedWorkerPerformance.idl', 'performance/SharedWorkerPerformance.idl',
'performance/WorkerGlobalScopePerformance.idl', 'performance/WorkerGlobalScopePerformance.idl',
'presentation/NavigatorPresentation.idl',
'push_messaging/NavigatorPushManager.idl', 'push_messaging/NavigatorPushManager.idl',
'push_messaging/ServiceWorkerGlobalScopePush.idl', 'push_messaging/ServiceWorkerGlobalScopePush.idl',
'quota/NavigatorStorageQuota.idl', 'quota/NavigatorStorageQuota.idl',
...@@ -646,6 +648,10 @@ ...@@ -646,6 +648,10 @@
'performance/WorkerGlobalScopePerformance.h', 'performance/WorkerGlobalScopePerformance.h',
'performance/WorkerPerformance.cpp', 'performance/WorkerPerformance.cpp',
'performance/WorkerPerformance.h', 'performance/WorkerPerformance.h',
'presentation/NavigatorPresentation.cpp',
'presentation/NavigatorPresentation.h',
'presentation/Presentation.cpp',
'presentation/Presentation.h',
'push_messaging/NavigatorPushManager.cpp', 'push_messaging/NavigatorPushManager.cpp',
'push_messaging/NavigatorPushManager.h', 'push_messaging/NavigatorPushManager.h',
'push_messaging/PushController.cpp', 'push_messaging/PushController.cpp',
......
// 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.
#include "config.h"
#include "modules/presentation/NavigatorPresentation.h"
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Navigator.h"
#include "modules/presentation/Presentation.h"
#include "platform/heap/Handle.h"
namespace blink {
NavigatorPresentation::NavigatorPresentation(LocalFrame* frame)
: DOMWindowProperty(frame)
{
}
NavigatorPresentation::~NavigatorPresentation()
{
}
// static
const char* NavigatorPresentation::supplementName()
{
return "NavigatorPresentation";
}
// static
NavigatorPresentation& NavigatorPresentation::from(Navigator& navigator)
{
NavigatorPresentation* supplement = static_cast<NavigatorPresentation*>(WillBeHeapSupplement<Navigator>::from(navigator, supplementName()));
if (!supplement) {
supplement = new NavigatorPresentation(navigator.frame());
provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
}
return *supplement;
}
// static
Presentation* NavigatorPresentation::presentation(Navigator& navigator)
{
return NavigatorPresentation::from(navigator).presentation();
}
Presentation* NavigatorPresentation::presentation()
{
if (!m_presentation) {
if (!frame())
return 0;
m_presentation = Presentation::create(frame()->document());
}
return m_presentation.get();
}
void NavigatorPresentation::trace(Visitor* visitor)
{
visitor->trace(m_presentation);
WillBeHeapSupplement<Navigator>::trace(visitor);
DOMWindowProperty::trace(visitor);
}
} // namespace blink
// 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.
#ifndef NavigatorPresentation_h
#define NavigatorPresentation_h
#include "core/frame/DOMWindowProperty.h"
#include "platform/Supplementable.h"
namespace blink {
class Navigator;
class Presentation;
class NavigatorPresentation FINAL
: public NoBaseWillBeGarbageCollectedFinalized<NavigatorPresentation>
, public WillBeHeapSupplement<Navigator>
, public DOMWindowProperty {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorPresentation);
public:
virtual ~NavigatorPresentation();
static NavigatorPresentation& from(Navigator&);
static Presentation* presentation(Navigator&);
virtual void trace(Visitor*) OVERRIDE;
private:
static const char* supplementName();
explicit NavigatorPresentation(LocalFrame*);
Presentation* presentation();
PersistentWillBeMember<Presentation> m_presentation;
};
} // namespace blink
#endif // NavigatorPresentation_h
// 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://webscreens.github.io/presentation-api/#presentation-extension-to-navigator
[
RuntimeEnabled=Presentation
] partial interface Navigator {
readonly attribute Presentation presentation;
};
// 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.
#include "config.h"
#include "modules/presentation/Presentation.h"
#include "modules/EventTargetModules.h"
namespace blink {
Presentation::Presentation(ExecutionContext* executionContext)
: ContextLifecycleObserver(executionContext)
{
}
Presentation::~Presentation()
{
}
// static
Presentation* Presentation::create(ExecutionContext* executionContext)
{
return new Presentation(executionContext);
}
const AtomicString& Presentation::interfaceName() const
{
return EventTargetNames::Presentation;
}
ExecutionContext* Presentation::executionContext() const
{
return ContextLifecycleObserver::executionContext();
}
void Presentation::trace(Visitor* visitor)
{
EventTargetWithInlineData::trace(visitor);
}
} // namespace blink
// 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.
#ifndef Presentation_h
#define Presentation_h
#include "core/dom/ContextLifecycleObserver.h"
#include "core/events/EventTarget.h"
namespace blink {
class Presentation FINAL
: public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<Presentation>
, public EventTargetWithInlineData
, public ContextLifecycleObserver {
DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<Presentation>);
DEFINE_WRAPPERTYPEINFO();
public:
static Presentation* create(ExecutionContext*);
virtual ~Presentation();
// EventTarget implementation.
virtual const AtomicString& interfaceName() const OVERRIDE;
virtual ExecutionContext* executionContext() const OVERRIDE;
virtual void trace(Visitor*) OVERRIDE;
DEFINE_ATTRIBUTE_EVENT_LISTENER(availablechange);
private:
explicit Presentation(ExecutionContext*);
};
} // namespace blink
#endif // Presentation_h
// 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://webscreens.github.io/presentation-api/#presentation-interface
[
GarbageCollected,
RuntimeEnabled=Presentation
] interface Presentation : EventTarget {
attribute EventHandler onavailablechange;
};
...@@ -95,6 +95,7 @@ PagePopup status=stable ...@@ -95,6 +95,7 @@ PagePopup status=stable
PathOpsSVGClipping status=stable PathOpsSVGClipping status=stable
PeerConnection depends_on=MediaStream, status=stable PeerConnection depends_on=MediaStream, status=stable
PreciseMemoryInfo PreciseMemoryInfo
Presentation status=test
PushMessaging status=experimental PushMessaging status=experimental
QuotaPromise status=experimental QuotaPromise status=experimental
OverlayScrollbars OverlayScrollbars
......
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