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

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

Issue 1730383003: DevTools: consistently use Maybe for optional values in the protocol generator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 9 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"
(...skipping 28 matching lines...) Expand all
39 39
40 WebViewImpl* InspectorEmulationAgent::webViewImpl() 40 WebViewImpl* InspectorEmulationAgent::webViewImpl()
41 { 41 {
42 return m_webLocalFrameImpl->viewImpl(); 42 return m_webLocalFrameImpl->viewImpl();
43 } 43 }
44 44
45 void InspectorEmulationAgent::restore() 45 void InspectorEmulationAgent::restore()
46 { 46 {
47 ErrorString error; 47 ErrorString error;
48 setScriptExecutionDisabled(&error, m_state->booleanProperty(EmulationAgentSt ate::scriptExecutionDisabled, false)); 48 setScriptExecutionDisabled(&error, m_state->booleanProperty(EmulationAgentSt ate::scriptExecutionDisabled, false));
49 setTouchEmulationEnabled(&error, m_state->booleanProperty(EmulationAgentStat e::touchEventEmulationEnabled, false), protocol::optional(String())); 49 setTouchEmulationEnabled(&error, m_state->booleanProperty(EmulationAgentStat e::touchEventEmulationEnabled, false), protocol::Maybe<String>());
50 String emulatedMedia; 50 String emulatedMedia;
51 m_state->getString(EmulationAgentState::emulatedMedia, &emulatedMedia); 51 m_state->getString(EmulationAgentState::emulatedMedia, &emulatedMedia);
52 setEmulatedMedia(&error, emulatedMedia); 52 setEmulatedMedia(&error, emulatedMedia);
53 } 53 }
54 54
55 void InspectorEmulationAgent::disable(ErrorString*) 55 void InspectorEmulationAgent::disable(ErrorString*)
56 { 56 {
57 ErrorString error; 57 ErrorString error;
58 setScriptExecutionDisabled(&error, false); 58 setScriptExecutionDisabled(&error, false);
59 setTouchEmulationEnabled(&error, false, protocol::optional(String())); 59 setTouchEmulationEnabled(&error, false, protocol::Maybe<String>());
60 setEmulatedMedia(&error, String()); 60 setEmulatedMedia(&error, String());
61 } 61 }
62 62
63 void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*) 63 void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*)
64 { 64 {
65 webViewImpl()->resetScaleStateImmediately(); 65 webViewImpl()->resetScaleStateImmediately();
66 } 66 }
67 67
68 void InspectorEmulationAgent::setPageScaleFactor(ErrorString*, double pageScaleF actor) 68 void InspectorEmulationAgent::setPageScaleFactor(ErrorString*, double pageScaleF actor)
69 { 69 {
70 webViewImpl()->setPageScaleFactor(static_cast<float>(pageScaleFactor)); 70 webViewImpl()->setPageScaleFactor(static_cast<float>(pageScaleFactor));
71 } 71 }
72 72
73 void InspectorEmulationAgent::setScriptExecutionDisabled(ErrorString*, bool valu e) 73 void InspectorEmulationAgent::setScriptExecutionDisabled(ErrorString*, bool valu e)
74 { 74 {
75 m_state->setBoolean(EmulationAgentState::scriptExecutionDisabled, value); 75 m_state->setBoolean(EmulationAgentState::scriptExecutionDisabled, value);
76 webViewImpl()->devToolsEmulator()->setScriptExecutionDisabled(value); 76 webViewImpl()->devToolsEmulator()->setScriptExecutionDisabled(value);
77 } 77 }
78 78
79 void InspectorEmulationAgent::setTouchEmulationEnabled(ErrorString*, bool enable d, const OptionalValue<String>& configuration) 79 void InspectorEmulationAgent::setTouchEmulationEnabled(ErrorString*, bool enable d, const Maybe<String>& configuration)
80 { 80 {
81 m_state->setBoolean(EmulationAgentState::touchEventEmulationEnabled, enabled ); 81 m_state->setBoolean(EmulationAgentState::touchEventEmulationEnabled, enabled );
82 webViewImpl()->devToolsEmulator()->setTouchEventEmulationEnabled(enabled); 82 webViewImpl()->devToolsEmulator()->setTouchEventEmulationEnabled(enabled);
83 } 83 }
84 84
85 void InspectorEmulationAgent::setEmulatedMedia(ErrorString*, const String& media ) 85 void InspectorEmulationAgent::setEmulatedMedia(ErrorString*, const String& media )
86 { 86 {
87 m_state->setString(EmulationAgentState::emulatedMedia, media); 87 m_state->setString(EmulationAgentState::emulatedMedia, media);
88 webViewImpl()->page()->settings().setMediaTypeOverride(media); 88 webViewImpl()->page()->settings().setMediaTypeOverride(media);
89 } 89 }
90 90
91 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli ngRate) 91 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli ngRate)
92 { 92 {
93 m_client->setCPUThrottlingRate(throttlingRate); 93 m_client->setCPUThrottlingRate(throttlingRate);
94 } 94 }
95 95
96 DEFINE_TRACE(InspectorEmulationAgent) 96 DEFINE_TRACE(InspectorEmulationAgent)
97 { 97 {
98 visitor->trace(m_webLocalFrameImpl); 98 visitor->trace(m_webLocalFrameImpl);
99 InspectorBaseAgent::trace(visitor); 99 InspectorBaseAgent::trace(visitor);
100 } 100 }
101 101
102 } // namespace blink 102 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698