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