1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
// Copyright 2015 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 "modules/device_orientation/DeviceOrientationAbsoluteController.h"
#include "core/dom/Document.h"
#include "core/frame/Settings.h"
#include "modules/device_orientation/DeviceOrientationDispatcher.h"
namespace blink {
DeviceOrientationAbsoluteController::DeviceOrientationAbsoluteController(
Document& document)
: DeviceOrientationController(document) {}
DeviceOrientationAbsoluteController::~DeviceOrientationAbsoluteController() {}
const char* DeviceOrientationAbsoluteController::supplementName() {
return "DeviceOrientationAbsoluteController";
}
DeviceOrientationAbsoluteController& DeviceOrientationAbsoluteController::from(
Document& document) {
DeviceOrientationAbsoluteController* controller =
static_cast<DeviceOrientationAbsoluteController*>(
Supplement<Document>::from(
document, DeviceOrientationAbsoluteController::supplementName()));
if (!controller) {
controller = new DeviceOrientationAbsoluteController(document);
Supplement<Document>::provideTo(
document, DeviceOrientationAbsoluteController::supplementName(),
controller);
}
return *controller;
}
void DeviceOrientationAbsoluteController::didAddEventListener(
LocalDOMWindow* window,
const AtomicString& eventType) {
if (eventType != eventTypeName())
return;
if (document().frame()) {
if (document().isSecureContext()) {
UseCounter::count(document().frame(),
UseCounter::DeviceOrientationAbsoluteSecureOrigin);
} else {
Deprecation::countDeprecation(
document().frame(),
UseCounter::DeviceOrientationAbsoluteInsecureOrigin);
// TODO: add rappor logging of insecure origins as in
// DeviceOrientationController.
if (document()
.frame()
->settings()
->getStrictPowerfulFeatureRestrictions())
return;
}
}
// TODO: add rappor url logging as in DeviceOrientationController.
DeviceSingleWindowEventController::didAddEventListener(window, eventType);
}
DeviceOrientationDispatcher&
DeviceOrientationAbsoluteController::dispatcherInstance() const {
return DeviceOrientationDispatcher::instance(true);
}
const AtomicString& DeviceOrientationAbsoluteController::eventTypeName() const {
return EventTypeNames::deviceorientationabsolute;
}
DEFINE_TRACE(DeviceOrientationAbsoluteController) {
DeviceOrientationController::trace(visitor);
}
} // namespace blink
|