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 23 matching lines...) Expand all Loading... |
34 visitor->trace(m_page); | 34 visitor->trace(m_page); |
35 InspectorBaseAgent::trace(visitor); | 35 InspectorBaseAgent::trace(visitor); |
36 } | 36 } |
37 | 37 |
38 DeviceOrientationController& DeviceOrientationInspectorAgent::controller() { | 38 DeviceOrientationController& DeviceOrientationInspectorAgent::controller() { |
39 DCHECK(toLocalFrame(m_page->mainFrame())->document()); | 39 DCHECK(toLocalFrame(m_page->mainFrame())->document()); |
40 return DeviceOrientationController::from( | 40 return DeviceOrientationController::from( |
41 *m_page->deprecatedLocalMainFrame()->document()); | 41 *m_page->deprecatedLocalMainFrame()->document()); |
42 } | 42 } |
43 | 43 |
44 void DeviceOrientationInspectorAgent::setDeviceOrientationOverride( | 44 Response DeviceOrientationInspectorAgent::setDeviceOrientationOverride( |
45 ErrorString* error, | |
46 double alpha, | 45 double alpha, |
47 double beta, | 46 double beta, |
48 double gamma) { | 47 double gamma) { |
49 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, | 48 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, |
50 true); | 49 true); |
51 m_state->setDouble(DeviceOrientationInspectorAgentState::alpha, alpha); | 50 m_state->setDouble(DeviceOrientationInspectorAgentState::alpha, alpha); |
52 m_state->setDouble(DeviceOrientationInspectorAgentState::beta, beta); | 51 m_state->setDouble(DeviceOrientationInspectorAgentState::beta, beta); |
53 m_state->setDouble(DeviceOrientationInspectorAgentState::gamma, gamma); | 52 m_state->setDouble(DeviceOrientationInspectorAgentState::gamma, gamma); |
54 controller().setOverride( | 53 controller().setOverride( |
55 DeviceOrientationData::create(alpha, beta, gamma, false)); | 54 DeviceOrientationData::create(alpha, beta, gamma, false)); |
| 55 return Response::OK(); |
56 } | 56 } |
57 | 57 |
58 void DeviceOrientationInspectorAgent::clearDeviceOrientationOverride( | 58 Response DeviceOrientationInspectorAgent::clearDeviceOrientationOverride() { |
59 ErrorString* error) { | |
60 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, | 59 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, |
61 false); | 60 false); |
62 controller().clearOverride(); | 61 controller().clearOverride(); |
| 62 return Response::OK(); |
63 } | 63 } |
64 | 64 |
65 void DeviceOrientationInspectorAgent::disable(ErrorString*) { | 65 Response DeviceOrientationInspectorAgent::disable() { |
66 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, | 66 m_state->setBoolean(DeviceOrientationInspectorAgentState::overrideEnabled, |
67 false); | 67 false); |
68 controller().clearOverride(); | 68 controller().clearOverride(); |
| 69 return Response::OK(); |
69 } | 70 } |
70 | 71 |
71 void DeviceOrientationInspectorAgent::restore() { | 72 void DeviceOrientationInspectorAgent::restore() { |
72 if (m_state->booleanProperty( | 73 if (m_state->booleanProperty( |
73 DeviceOrientationInspectorAgentState::overrideEnabled, false)) { | 74 DeviceOrientationInspectorAgentState::overrideEnabled, false)) { |
74 double alpha = 0; | 75 double alpha = 0; |
75 m_state->getDouble(DeviceOrientationInspectorAgentState::alpha, &alpha); | 76 m_state->getDouble(DeviceOrientationInspectorAgentState::alpha, &alpha); |
76 double beta = 0; | 77 double beta = 0; |
77 m_state->getDouble(DeviceOrientationInspectorAgentState::beta, &beta); | 78 m_state->getDouble(DeviceOrientationInspectorAgentState::beta, &beta); |
78 double gamma = 0; | 79 double gamma = 0; |
79 m_state->getDouble(DeviceOrientationInspectorAgentState::gamma, &gamma); | 80 m_state->getDouble(DeviceOrientationInspectorAgentState::gamma, &gamma); |
80 controller().setOverride( | 81 controller().setOverride( |
81 DeviceOrientationData::create(alpha, beta, gamma, false)); | 82 DeviceOrientationData::create(alpha, beta, gamma, false)); |
82 } | 83 } |
83 } | 84 } |
84 | 85 |
85 void DeviceOrientationInspectorAgent::didCommitLoadForLocalFrame( | 86 void DeviceOrientationInspectorAgent::didCommitLoadForLocalFrame( |
86 LocalFrame* frame) { | 87 LocalFrame* frame) { |
87 // FIXME(dgozman): adapt this for out-of-process iframes. | 88 // FIXME(dgozman): adapt this for out-of-process iframes. |
88 if (frame != m_page->mainFrame()) | 89 if (frame != m_page->mainFrame()) |
89 return; | 90 return; |
90 | 91 |
91 // New document in main frame - apply override there. | 92 // New document in main frame - apply override there. |
92 // No need to cleanup previous one, as it's already gone. | 93 // No need to cleanup previous one, as it's already gone. |
93 restore(); | 94 restore(); |
94 } | 95 } |
95 | 96 |
96 } // namespace blink | 97 } // namespace blink |
OLD | NEW |