| 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 "modules/device_orientation/DeviceOrientationInspectorAgent.h" | 5 #include "modules/device_orientation/DeviceOrientationInspectorAgent.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalFrame.h" | 7 #include "core/frame/LocalFrame.h" |
| 8 #include "core/page/Page.h" | 8 #include "core/page/Page.h" |
| 9 #include "modules/device_orientation/DeviceOrientationController.h" | 9 #include "modules/device_orientation/DeviceOrientationController.h" |
| 10 #include "modules/device_orientation/DeviceOrientationData.h" | 10 #include "modules/device_orientation/DeviceOrientationData.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 DeviceOrientationController& DeviceOrientationInspectorAgent::controller() | 43 DeviceOrientationController& DeviceOrientationInspectorAgent::controller() |
| 44 { | 44 { |
| 45 DCHECK(toLocalFrame(m_page->mainFrame())->document()); | 45 DCHECK(toLocalFrame(m_page->mainFrame())->document()); |
| 46 return DeviceOrientationController::from(*m_page->deprecatedLocalMainFrame()
->document()); | 46 return DeviceOrientationController::from(*m_page->deprecatedLocalMainFrame()
->document()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void DeviceOrientationInspectorAgent::setDeviceOrientationOverride(ErrorString*
error, double alpha, double beta, double gamma) | 49 void DeviceOrientationInspectorAgent::setDeviceOrientationOverride(ErrorString*
error, double alpha, double beta, double gamma) |
| 50 { | 50 { |
| 51 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, t
rue); | 51 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, t
rue); |
| 52 m_state->setNumber(DeviceOrientationInspectorAgentState::alpha, alpha); | 52 m_state->setDouble(DeviceOrientationInspectorAgentState::alpha, alpha); |
| 53 m_state->setNumber(DeviceOrientationInspectorAgentState::beta, beta); | 53 m_state->setDouble(DeviceOrientationInspectorAgentState::beta, beta); |
| 54 m_state->setNumber(DeviceOrientationInspectorAgentState::gamma, gamma); | 54 m_state->setDouble(DeviceOrientationInspectorAgentState::gamma, gamma); |
| 55 controller().setOverride(DeviceOrientationData::create(alpha, beta, gamma, f
alse)); | 55 controller().setOverride(DeviceOrientationData::create(alpha, beta, gamma, f
alse)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void DeviceOrientationInspectorAgent::clearDeviceOrientationOverride(ErrorString
* error) | 58 void DeviceOrientationInspectorAgent::clearDeviceOrientationOverride(ErrorString
* error) |
| 59 { | 59 { |
| 60 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, f
alse); | 60 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, f
alse); |
| 61 controller().clearOverride(); | 61 controller().clearOverride(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void DeviceOrientationInspectorAgent::disable(ErrorString*) | 64 void DeviceOrientationInspectorAgent::disable(ErrorString*) |
| 65 { | 65 { |
| 66 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, f
alse); | 66 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, f
alse); |
| 67 controller().clearOverride(); | 67 controller().clearOverride(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void DeviceOrientationInspectorAgent::restore() | 70 void DeviceOrientationInspectorAgent::restore() |
| 71 { | 71 { |
| 72 if (m_state->booleanProperty(DeviceOrientationInspectorAgentState::overrideE
nabled, false)) { | 72 if (m_state->booleanProperty(DeviceOrientationInspectorAgentState::overrideE
nabled, false)) { |
| 73 double alpha = 0; | 73 double alpha = 0; |
| 74 m_state->getNumber(DeviceOrientationInspectorAgentState::alpha, &alpha); | 74 m_state->getDouble(DeviceOrientationInspectorAgentState::alpha, &alpha); |
| 75 double beta = 0; | 75 double beta = 0; |
| 76 m_state->getNumber(DeviceOrientationInspectorAgentState::beta, &beta); | 76 m_state->getDouble(DeviceOrientationInspectorAgentState::beta, &beta); |
| 77 double gamma = 0; | 77 double gamma = 0; |
| 78 m_state->getNumber(DeviceOrientationInspectorAgentState::gamma, &gamma); | 78 m_state->getDouble(DeviceOrientationInspectorAgentState::gamma, &gamma); |
| 79 controller().setOverride(DeviceOrientationData::create(alpha, beta, gamm
a, false)); | 79 controller().setOverride(DeviceOrientationData::create(alpha, beta, gamm
a, false)); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 void DeviceOrientationInspectorAgent::didCommitLoadForLocalFrame(LocalFrame* fra
me) | 83 void DeviceOrientationInspectorAgent::didCommitLoadForLocalFrame(LocalFrame* fra
me) |
| 84 { | 84 { |
| 85 // FIXME(dgozman): adapt this for out-of-process iframes. | 85 // FIXME(dgozman): adapt this for out-of-process iframes. |
| 86 if (frame != m_page->mainFrame()) | 86 if (frame != m_page->mainFrame()) |
| 87 return; | 87 return; |
| 88 | 88 |
| 89 // New document in main frame - apply override there. | 89 // New document in main frame - apply override there. |
| 90 // No need to cleanup previous one, as it's already gone. | 90 // No need to cleanup previous one, as it's already gone. |
| 91 restore(); | 91 restore(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |