| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "web/InspectorEmulationAgent.h" | 6 #include "web/InspectorEmulationAgent.h" |
| 7 | 7 |
| 8 #include "core/frame/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| 11 #include "core/inspector/InspectorState.h" | 11 #include "core/inspector/InspectorState.h" |
| 12 #include "core/page/Page.h" | 12 #include "core/page/Page.h" |
| 13 #include "platform/geometry/DoubleRect.h" | 13 #include "platform/geometry/DoubleRect.h" |
| 14 #include "web/DevToolsEmulator.h" | 14 #include "web/DevToolsEmulator.h" |
| 15 #include "web/WebLocalFrameImpl.h" | 15 #include "web/WebLocalFrameImpl.h" |
| 16 #include "web/WebViewImpl.h" | 16 #include "web/WebViewImpl.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 namespace EmulationAgentState { | 20 namespace EmulationAgentState { |
| 21 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled"; | 21 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled"; |
| 22 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; | 22 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; |
| 23 static const char emulatedMedia[] = "emulatedMedia"; | 23 static const char emulatedMedia[] = "emulatedMedia"; |
| 24 } | 24 } |
| 25 | 25 |
| 26 PassOwnPtrWillBeRawPtr<InspectorEmulationAgent> InspectorEmulationAgent::create(
WebLocalFrameImpl* webLocalFrameImpl) | 26 PassOwnPtrWillBeRawPtr<InspectorEmulationAgent> InspectorEmulationAgent::create(
WebLocalFrameImpl* webLocalFrameImpl, Client* client) |
| 27 { | 27 { |
| 28 return adoptPtrWillBeNoop(new InspectorEmulationAgent(webLocalFrameImpl)); | 28 return adoptPtrWillBeNoop(new InspectorEmulationAgent(webLocalFrameImpl, cli
ent)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 InspectorEmulationAgent::InspectorEmulationAgent(WebLocalFrameImpl* webLocalFram
eImpl) | 31 InspectorEmulationAgent::InspectorEmulationAgent(WebLocalFrameImpl* webLocalFram
eImpl, Client* client) |
| 32 : InspectorBaseAgent<InspectorEmulationAgent, InspectorFrontend::Emulation>(
"Emulation") | 32 : InspectorBaseAgent<InspectorEmulationAgent, InspectorFrontend::Emulation>(
"Emulation") |
| 33 , m_webLocalFrameImpl(webLocalFrameImpl) | 33 , m_webLocalFrameImpl(webLocalFrameImpl) |
| 34 , m_client(client) |
| 34 { | 35 { |
| 35 webViewImpl()->devToolsEmulator()->setEmulationAgent(this); | 36 webViewImpl()->devToolsEmulator()->setEmulationAgent(this); |
| 36 } | 37 } |
| 37 | 38 |
| 38 InspectorEmulationAgent::~InspectorEmulationAgent() | 39 InspectorEmulationAgent::~InspectorEmulationAgent() |
| 39 { | 40 { |
| 40 } | 41 } |
| 41 | 42 |
| 42 WebViewImpl* InspectorEmulationAgent::webViewImpl() | 43 WebViewImpl* InspectorEmulationAgent::webViewImpl() |
| 43 { | 44 { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 m_state->setBoolean(EmulationAgentState::touchEventEmulationEnabled, enabled
); | 93 m_state->setBoolean(EmulationAgentState::touchEventEmulationEnabled, enabled
); |
| 93 webViewImpl()->devToolsEmulator()->setTouchEventEmulationEnabled(enabled); | 94 webViewImpl()->devToolsEmulator()->setTouchEventEmulationEnabled(enabled); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void InspectorEmulationAgent::setEmulatedMedia(ErrorString*, const String& media
) | 97 void InspectorEmulationAgent::setEmulatedMedia(ErrorString*, const String& media
) |
| 97 { | 98 { |
| 98 m_state->setString(EmulationAgentState::emulatedMedia, media); | 99 m_state->setString(EmulationAgentState::emulatedMedia, media); |
| 99 webViewImpl()->page()->settings().setMediaTypeOverride(media); | 100 webViewImpl()->page()->settings().setMediaTypeOverride(media); |
| 100 } | 101 } |
| 101 | 102 |
| 103 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli
ngRate) |
| 104 { |
| 105 m_client->setCPUThrottlingRate(throttlingRate); |
| 106 } |
| 107 |
| 102 void InspectorEmulationAgent::viewportChanged() | 108 void InspectorEmulationAgent::viewportChanged() |
| 103 { | 109 { |
| 104 if (!webViewImpl()->devToolsEmulator()->deviceEmulationEnabled() || !fronten
d()) | 110 if (!webViewImpl()->devToolsEmulator()->deviceEmulationEnabled() || !fronten
d()) |
| 105 return; | 111 return; |
| 106 | 112 |
| 107 FrameView* view = m_webLocalFrameImpl->frameView(); | 113 FrameView* view = m_webLocalFrameImpl->frameView(); |
| 108 if (!view) | 114 if (!view) |
| 109 return; | 115 return; |
| 110 | 116 |
| 111 IntSize contentsSize = view->contentsSize(); | 117 IntSize contentsSize = view->contentsSize(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 123 frontend()->viewportChanged(viewport); | 129 frontend()->viewportChanged(viewport); |
| 124 } | 130 } |
| 125 | 131 |
| 126 DEFINE_TRACE(InspectorEmulationAgent) | 132 DEFINE_TRACE(InspectorEmulationAgent) |
| 127 { | 133 { |
| 128 visitor->trace(m_webLocalFrameImpl); | 134 visitor->trace(m_webLocalFrameImpl); |
| 129 InspectorBaseAgent::trace(visitor); | 135 InspectorBaseAgent::trace(visitor); |
| 130 } | 136 } |
| 131 | 137 |
| 132 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |