Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/device_orientation/DeviceMotionController.h" | 6 #include "modules/device_orientation/DeviceMotionController.h" |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/frame/UseCounter.h" | 10 #include "core/frame/UseCounter.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 DeviceMotionController* controller = static_cast<DeviceMotionController*>(Do cumentSupplement::from(document, supplementName())); | 38 DeviceMotionController* controller = static_cast<DeviceMotionController*>(Do cumentSupplement::from(document, supplementName())); |
| 39 if (!controller) { | 39 if (!controller) { |
| 40 controller = new DeviceMotionController(document); | 40 controller = new DeviceMotionController(document); |
| 41 DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBe Noop(controller)); | 41 DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBe Noop(controller)); |
| 42 } | 42 } |
| 43 return *controller; | 43 return *controller; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void DeviceMotionController::didAddEventListener(LocalDOMWindow* window, const A tomicString& eventType) | 46 void DeviceMotionController::didAddEventListener(LocalDOMWindow* window, const A tomicString& eventType) |
| 47 { | 47 { |
| 48 if (eventType != eventTypeName()) | |
| 49 return; | |
| 50 | |
| 48 if (document().frame()) { | 51 if (document().frame()) { |
| 49 String errorMessage; | 52 String errorMessage; |
| 50 if (document().securityOrigin()->canAccessFeatureRequiringSecureOrigin(e rrorMessage)) { | 53 if (document().securityOrigin()->canAccessFeatureRequiringSecureOrigin(e rrorMessage)) { |
| 51 UseCounter::count(document().frame(), UseCounter::DeviceMotionSecure Origin); | 54 UseCounter::count(document().frame(), UseCounter::DeviceMotionSecure Origin); |
| 52 } else { | 55 } else { |
| 53 UseCounter::count(document().frame(), UseCounter::DeviceMotionInsecu reOrigin); | 56 UseCounter::count(document().frame(), UseCounter::DeviceMotionInsecu reOrigin); |
| 54 if (document().frame()->settings()->strictPowerfulFeatureRestriction s()) | 57 if (document().frame()->settings()->strictPowerfulFeatureRestriction s()) |
| 55 return; | 58 return; |
| 56 } | 59 } |
| 57 } | 60 } |
| 58 | 61 |
| 59 DeviceSingleWindowEventController::didAddEventListener(window, eventType); | 62 DeviceSingleWindowEventController::didAddEventListener(window, eventType); |
|
Mike West
2015/03/12 21:25:12
Returning early changes the behavior of this deleg
timvolodine
2015/03/13 11:40:55
that's no problem, actually this method has an ear
| |
| 60 } | 63 } |
| 61 | 64 |
| 62 bool DeviceMotionController::hasLastData() | 65 bool DeviceMotionController::hasLastData() |
| 63 { | 66 { |
| 64 return DeviceMotionDispatcher::instance().latestDeviceMotionData(); | 67 return DeviceMotionDispatcher::instance().latestDeviceMotionData(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 void DeviceMotionController::registerWithDispatcher() | 70 void DeviceMotionController::registerWithDispatcher() |
| 68 { | 71 { |
| 69 DeviceMotionDispatcher::instance().addController(this); | 72 DeviceMotionDispatcher::instance().addController(this); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 90 return EventTypeNames::devicemotion; | 93 return EventTypeNames::devicemotion; |
| 91 } | 94 } |
| 92 | 95 |
| 93 DEFINE_TRACE(DeviceMotionController) | 96 DEFINE_TRACE(DeviceMotionController) |
| 94 { | 97 { |
| 95 DeviceSingleWindowEventController::trace(visitor); | 98 DeviceSingleWindowEventController::trace(visitor); |
| 96 DocumentSupplement::trace(visitor); | 99 DocumentSupplement::trace(visitor); |
| 97 } | 100 } |
| 98 | 101 |
| 99 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |