OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 #include "config.h" |
| 6 #include "modules/device_orientation/DeviceOrientationAbsoluteController.h" |
| 7 |
| 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/Settings.h" |
| 10 #include "modules/device_orientation/DeviceOrientationDispatcher.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 DeviceOrientationAbsoluteController::DeviceOrientationAbsoluteController(Documen
t& document) |
| 15 : DeviceOrientationController(document) |
| 16 { |
| 17 } |
| 18 |
| 19 DeviceOrientationAbsoluteController::~DeviceOrientationAbsoluteController() |
| 20 { |
| 21 } |
| 22 |
| 23 const char* DeviceOrientationAbsoluteController::supplementName() |
| 24 { |
| 25 return "DeviceOrientationAbsoluteController"; |
| 26 } |
| 27 |
| 28 DeviceOrientationAbsoluteController& DeviceOrientationAbsoluteController::from(D
ocument& document) |
| 29 { |
| 30 DeviceOrientationAbsoluteController* controller = static_cast<DeviceOrientat
ionAbsoluteController*>(WillBeHeapSupplement<Document>::from(document, DeviceOri
entationAbsoluteController::supplementName())); |
| 31 if (!controller) { |
| 32 controller = new DeviceOrientationAbsoluteController(document); |
| 33 WillBeHeapSupplement<Document>::provideTo(document, DeviceOrientationAbs
oluteController::supplementName(), adoptPtrWillBeNoop(controller)); |
| 34 } |
| 35 return *controller; |
| 36 } |
| 37 |
| 38 void DeviceOrientationAbsoluteController::didAddEventListener(LocalDOMWindow* wi
ndow, const AtomicString& eventType) |
| 39 { |
| 40 if (eventType != eventTypeName()) |
| 41 return; |
| 42 |
| 43 if (document().frame()) { |
| 44 String errorMessage; |
| 45 if (document().isSecureContext(errorMessage)) { |
| 46 UseCounter::count(document().frame(), UseCounter::DeviceOrientationA
bsoluteSecureOrigin); |
| 47 } else { |
| 48 UseCounter::countDeprecation(document().frame(), UseCounter::DeviceO
rientationAbsoluteInsecureOrigin); |
| 49 // TODO: add rappor logging of insecure origins as in DeviceOrientat
ionController. |
| 50 if (document().frame()->settings()->strictPowerfulFeatureRestriction
s()) |
| 51 return; |
| 52 } |
| 53 } |
| 54 |
| 55 // TODO: add rappor url logging as in DeviceOrientationController. |
| 56 |
| 57 DeviceSingleWindowEventController::didAddEventListener(window, eventType); |
| 58 } |
| 59 |
| 60 DeviceOrientationDispatcher& DeviceOrientationAbsoluteController::dispatcherInst
ance() const |
| 61 { |
| 62 return DeviceOrientationDispatcher::instance(true); |
| 63 } |
| 64 |
| 65 const AtomicString& DeviceOrientationAbsoluteController::eventTypeName() const |
| 66 { |
| 67 return EventTypeNames::deviceorientationabsolute; |
| 68 } |
| 69 |
| 70 DEFINE_TRACE(DeviceOrientationAbsoluteController) |
| 71 { |
| 72 DeviceOrientationController::trace(visitor); |
| 73 } |
| 74 |
| 75 } // namespace blink |
OLD | NEW |