1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef DeviceOrientationController_h
6#define DeviceOrientationController_h
7
8#include "core/dom/DocumentSupplementable.h"
9#include "core/frame/DeviceSingleWindowEventController.h"
10
11namespace blink {
12
13class DeviceOrientationData;
14class Event;
15
16class DeviceOrientationController FINAL : public DeviceSingleWindowEventController, public DocumentSupplement {
17    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DeviceOrientationController);
18public:
19    virtual ~DeviceOrientationController();
20
21    static const char* supplementName();
22    static DeviceOrientationController& from(Document&);
23
24    // Inherited from DeviceSingleWindowEventController.
25    void didUpdateData() OVERRIDE;
26
27    void setOverride(DeviceOrientationData*);
28    void clearOverride();
29
30    virtual void trace(Visitor*) OVERRIDE;
31
32private:
33    explicit DeviceOrientationController(Document&);
34
35    // Inherited from DeviceEventControllerBase.
36    virtual void registerWithDispatcher() OVERRIDE;
37    virtual void unregisterWithDispatcher() OVERRIDE;
38    virtual bool hasLastData() OVERRIDE;
39
40    // Inherited from DeviceSingleWindowEventController.
41    virtual PassRefPtrWillBeRawPtr<Event> lastEvent() const OVERRIDE;
42    virtual const AtomicString& eventTypeName() const OVERRIDE;
43    virtual bool isNullEvent(Event*) const OVERRIDE;
44
45    DeviceOrientationData* lastData() const;
46
47    PersistentWillBeMember<DeviceOrientationData> m_overrideOrientationData;
48};
49
50} // namespace blink
51
52#endif // DeviceOrientationController_h
53