Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Side by Side Diff: third_party/WebKit/Source/web/InspectorEmulationAgent.cpp

Issue 1702673002: DevTools: migrate remote debugging protocol generators to jinja2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "web/InspectorEmulationAgent.h" 5 #include "web/InspectorEmulationAgent.h"
6 6
7 #include "core/frame/FrameHost.h" 7 #include "core/frame/FrameHost.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/page/Page.h" 10 #include "core/page/Page.h"
11 #include "platform/geometry/DoubleRect.h" 11 #include "platform/geometry/DoubleRect.h"
12 #include "web/DevToolsEmulator.h" 12 #include "web/DevToolsEmulator.h"
13 #include "web/WebLocalFrameImpl.h" 13 #include "web/WebLocalFrameImpl.h"
14 #include "web/WebViewImpl.h" 14 #include "web/WebViewImpl.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 namespace EmulationAgentState { 18 namespace EmulationAgentState {
19 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled"; 19 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled";
20 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; 20 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled";
21 static const char emulatedMedia[] = "emulatedMedia"; 21 static const char emulatedMedia[] = "emulatedMedia";
22 } 22 }
23 23
24 using namespace protocol;
25
24 PassOwnPtrWillBeRawPtr<InspectorEmulationAgent> InspectorEmulationAgent::create( WebLocalFrameImpl* webLocalFrameImpl, Client* client) 26 PassOwnPtrWillBeRawPtr<InspectorEmulationAgent> InspectorEmulationAgent::create( WebLocalFrameImpl* webLocalFrameImpl, Client* client)
25 { 27 {
26 return adoptPtrWillBeNoop(new InspectorEmulationAgent(webLocalFrameImpl, cli ent)); 28 return adoptPtrWillBeNoop(new InspectorEmulationAgent(webLocalFrameImpl, cli ent));
27 } 29 }
28 30
29 InspectorEmulationAgent::InspectorEmulationAgent(WebLocalFrameImpl* webLocalFram eImpl, Client* client) 31 InspectorEmulationAgent::InspectorEmulationAgent(WebLocalFrameImpl* webLocalFram eImpl, Client* client)
30 : InspectorBaseAgent<InspectorEmulationAgent, protocol::Frontend::Emulation> ("Emulation") 32 : InspectorBaseAgent<InspectorEmulationAgent, protocol::Frontend::Emulation> ("Emulation")
31 , m_webLocalFrameImpl(webLocalFrameImpl) 33 , m_webLocalFrameImpl(webLocalFrameImpl)
32 , m_client(client) 34 , m_client(client)
33 { 35 {
34 } 36 }
35 37
36 InspectorEmulationAgent::~InspectorEmulationAgent() 38 InspectorEmulationAgent::~InspectorEmulationAgent()
37 { 39 {
38 } 40 }
39 41
40 WebViewImpl* InspectorEmulationAgent::webViewImpl() 42 WebViewImpl* InspectorEmulationAgent::webViewImpl()
41 { 43 {
42 return m_webLocalFrameImpl->viewImpl(); 44 return m_webLocalFrameImpl->viewImpl();
43 } 45 }
44 46
45 void InspectorEmulationAgent::restore() 47 void InspectorEmulationAgent::restore()
46 { 48 {
47 ErrorString error; 49 ErrorString error;
48 setScriptExecutionDisabled(&error, m_state->booleanProperty(EmulationAgentSt ate::scriptExecutionDisabled, false)); 50 setScriptExecutionDisabled(&error, m_state->booleanProperty(EmulationAgentSt ate::scriptExecutionDisabled, false));
49 setTouchEmulationEnabled(&error, m_state->booleanProperty(EmulationAgentStat e::touchEventEmulationEnabled, false), nullptr); 51 setTouchEmulationEnabled(&error, m_state->booleanProperty(EmulationAgentStat e::touchEventEmulationEnabled, false), TypeBuilder::optional(String()));
50 String emulatedMedia; 52 String emulatedMedia;
51 m_state->getString(EmulationAgentState::emulatedMedia, &emulatedMedia); 53 m_state->getString(EmulationAgentState::emulatedMedia, &emulatedMedia);
52 setEmulatedMedia(&error, emulatedMedia); 54 setEmulatedMedia(&error, emulatedMedia);
53 } 55 }
54 56
55 void InspectorEmulationAgent::disable(ErrorString*) 57 void InspectorEmulationAgent::disable(ErrorString*)
56 { 58 {
57 ErrorString error; 59 ErrorString error;
58 setScriptExecutionDisabled(&error, false); 60 setScriptExecutionDisabled(&error, false);
59 setTouchEmulationEnabled(&error, false, nullptr); 61 setTouchEmulationEnabled(&error, false, TypeBuilder::optional(String()));
60 setEmulatedMedia(&error, String()); 62 setEmulatedMedia(&error, String());
61 } 63 }
62 64
63 void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*) 65 void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*)
64 { 66 {
65 webViewImpl()->resetScaleStateImmediately(); 67 webViewImpl()->resetScaleStateImmediately();
66 } 68 }
67 69
68 void InspectorEmulationAgent::setPageScaleFactor(ErrorString*, double pageScaleF actor) 70 void InspectorEmulationAgent::setPageScaleFactor(ErrorString*, double pageScaleF actor)
69 { 71 {
70 webViewImpl()->setPageScaleFactor(static_cast<float>(pageScaleFactor)); 72 webViewImpl()->setPageScaleFactor(static_cast<float>(pageScaleFactor));
71 } 73 }
72 74
73 void InspectorEmulationAgent::setScriptExecutionDisabled(ErrorString*, bool valu e) 75 void InspectorEmulationAgent::setScriptExecutionDisabled(ErrorString*, bool valu e)
74 { 76 {
75 m_state->setBoolean(EmulationAgentState::scriptExecutionDisabled, value); 77 m_state->setBoolean(EmulationAgentState::scriptExecutionDisabled, value);
76 webViewImpl()->devToolsEmulator()->setScriptExecutionDisabled(value); 78 webViewImpl()->devToolsEmulator()->setScriptExecutionDisabled(value);
77 } 79 }
78 80
79 void InspectorEmulationAgent::setTouchEmulationEnabled(ErrorString*, bool enable d, const String* configuration) 81 void InspectorEmulationAgent::setTouchEmulationEnabled(ErrorString*, bool enable d, const OptionalValue<String>& configuration)
80 { 82 {
81 m_state->setBoolean(EmulationAgentState::touchEventEmulationEnabled, enabled ); 83 m_state->setBoolean(EmulationAgentState::touchEventEmulationEnabled, enabled );
82 webViewImpl()->devToolsEmulator()->setTouchEventEmulationEnabled(enabled); 84 webViewImpl()->devToolsEmulator()->setTouchEventEmulationEnabled(enabled);
83 } 85 }
84 86
85 void InspectorEmulationAgent::setEmulatedMedia(ErrorString*, const String& media ) 87 void InspectorEmulationAgent::setEmulatedMedia(ErrorString*, const String& media )
86 { 88 {
87 m_state->setString(EmulationAgentState::emulatedMedia, media); 89 m_state->setString(EmulationAgentState::emulatedMedia, media);
88 webViewImpl()->page()->settings().setMediaTypeOverride(media); 90 webViewImpl()->page()->settings().setMediaTypeOverride(media);
89 } 91 }
90 92
91 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli ngRate) 93 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli ngRate)
92 { 94 {
93 m_client->setCPUThrottlingRate(throttlingRate); 95 m_client->setCPUThrottlingRate(throttlingRate);
94 } 96 }
95 97
96 DEFINE_TRACE(InspectorEmulationAgent) 98 DEFINE_TRACE(InspectorEmulationAgent)
97 { 99 {
98 visitor->trace(m_webLocalFrameImpl); 100 visitor->trace(m_webLocalFrameImpl);
99 InspectorBaseAgent::trace(visitor); 101 InspectorBaseAgent::trace(visitor);
100 } 102 }
101 103
102 } // namespace blink 104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698