| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 static const char pageAgentScriptExecutionDisabled[] = "pageAgentScriptExecution
Disabled"; | 87 static const char pageAgentScriptExecutionDisabled[] = "pageAgentScriptExecution
Disabled"; |
| 88 static const char pageAgentScriptsToEvaluateOnLoad[] = "pageAgentScriptsToEvalua
teOnLoad"; | 88 static const char pageAgentScriptsToEvaluateOnLoad[] = "pageAgentScriptsToEvalua
teOnLoad"; |
| 89 static const char pageAgentScreenWidthOverride[] = "pageAgentScreenWidthOverride
"; | 89 static const char pageAgentScreenWidthOverride[] = "pageAgentScreenWidthOverride
"; |
| 90 static const char pageAgentScreenHeightOverride[] = "pageAgentScreenHeightOverri
de"; | 90 static const char pageAgentScreenHeightOverride[] = "pageAgentScreenHeightOverri
de"; |
| 91 static const char pageAgentFontScaleFactorOverride[] = "pageAgentFontScaleFactor
Override"; | 91 static const char pageAgentFontScaleFactorOverride[] = "pageAgentFontScaleFactor
Override"; |
| 92 static const char pageAgentFitWindow[] = "pageAgentFitWindow"; | 92 static const char pageAgentFitWindow[] = "pageAgentFitWindow"; |
| 93 static const char pageAgentShowFPSCounter[] = "pageAgentShowFPSCounter"; | 93 static const char pageAgentShowFPSCounter[] = "pageAgentShowFPSCounter"; |
| 94 static const char pageAgentContinuousPaintingEnabled[] = "pageAgentContinuousPai
ntingEnabled"; | 94 static const char pageAgentContinuousPaintingEnabled[] = "pageAgentContinuousPai
ntingEnabled"; |
| 95 static const char pageAgentShowPaintRects[] = "pageAgentShowPaintRects"; | 95 static const char pageAgentShowPaintRects[] = "pageAgentShowPaintRects"; |
| 96 static const char pageAgentShowDebugBorders[] = "pageAgentShowDebugBorders"; | 96 static const char pageAgentShowDebugBorders[] = "pageAgentShowDebugBorders"; |
| 97 #if ENABLE(TOUCH_EVENTS) | |
| 98 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; | 97 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; |
| 99 #endif | |
| 100 static const char pageAgentEmulatedMedia[] = "pageAgentEmulatedMedia"; | 98 static const char pageAgentEmulatedMedia[] = "pageAgentEmulatedMedia"; |
| 101 } | 99 } |
| 102 | 100 |
| 103 static bool decodeBuffer(const char* buffer, unsigned size, const String& textEn
codingName, String* result) | 101 static bool decodeBuffer(const char* buffer, unsigned size, const String& textEn
codingName, String* result) |
| 104 { | 102 { |
| 105 if (buffer) { | 103 if (buffer) { |
| 106 TextEncoding encoding(textEncodingName); | 104 TextEncoding encoding(textEncodingName); |
| 107 if (!encoding.isValid()) | 105 if (!encoding.isValid()) |
| 108 encoding = WindowsLatin1Encoding(); | 106 encoding = WindowsLatin1Encoding(); |
| 109 *result = encoding.decode(buffer, size); | 107 *result = encoding.decode(buffer, size); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 337 |
| 340 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) | 338 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) |
| 341 { | 339 { |
| 342 m_frontend = frontend->page(); | 340 m_frontend = frontend->page(); |
| 343 } | 341 } |
| 344 | 342 |
| 345 void InspectorPageAgent::clearFrontend() | 343 void InspectorPageAgent::clearFrontend() |
| 346 { | 344 { |
| 347 ErrorString error; | 345 ErrorString error; |
| 348 disable(&error); | 346 disable(&error); |
| 349 #if ENABLE(TOUCH_EVENTS) | |
| 350 updateTouchEventEmulationInPage(false); | 347 updateTouchEventEmulationInPage(false); |
| 351 #endif | |
| 352 m_frontend = 0; | 348 m_frontend = 0; |
| 353 } | 349 } |
| 354 | 350 |
| 355 void InspectorPageAgent::restore() | 351 void InspectorPageAgent::restore() |
| 356 { | 352 { |
| 357 if (m_state->getBoolean(PageAgentState::pageAgentEnabled)) { | 353 if (m_state->getBoolean(PageAgentState::pageAgentEnabled)) { |
| 358 ErrorString error; | 354 ErrorString error; |
| 359 enable(&error); | 355 enable(&error); |
| 360 bool scriptExecutionDisabled = m_state->getBoolean(PageAgentState::pageA
gentScriptExecutionDisabled); | 356 bool scriptExecutionDisabled = m_state->getBoolean(PageAgentState::pageA
gentScriptExecutionDisabled); |
| 361 setScriptExecutionDisabled(0, scriptExecutionDisabled); | 357 setScriptExecutionDisabled(0, scriptExecutionDisabled); |
| 362 bool showPaintRects = m_state->getBoolean(PageAgentState::pageAgentShowP
aintRects); | 358 bool showPaintRects = m_state->getBoolean(PageAgentState::pageAgentShowP
aintRects); |
| 363 setShowPaintRects(0, showPaintRects); | 359 setShowPaintRects(0, showPaintRects); |
| 364 bool showDebugBorders = m_state->getBoolean(PageAgentState::pageAgentSho
wDebugBorders); | 360 bool showDebugBorders = m_state->getBoolean(PageAgentState::pageAgentSho
wDebugBorders); |
| 365 setShowDebugBorders(0, showDebugBorders); | 361 setShowDebugBorders(0, showDebugBorders); |
| 366 bool showFPSCounter = m_state->getBoolean(PageAgentState::pageAgentShowF
PSCounter); | 362 bool showFPSCounter = m_state->getBoolean(PageAgentState::pageAgentShowF
PSCounter); |
| 367 setShowFPSCounter(0, showFPSCounter); | 363 setShowFPSCounter(0, showFPSCounter); |
| 368 String emulatedMedia = m_state->getString(PageAgentState::pageAgentEmula
tedMedia); | 364 String emulatedMedia = m_state->getString(PageAgentState::pageAgentEmula
tedMedia); |
| 369 setEmulatedMedia(0, emulatedMedia); | 365 setEmulatedMedia(0, emulatedMedia); |
| 370 bool continuousPaintingEnabled = m_state->getBoolean(PageAgentState::pag
eAgentContinuousPaintingEnabled); | 366 bool continuousPaintingEnabled = m_state->getBoolean(PageAgentState::pag
eAgentContinuousPaintingEnabled); |
| 371 setContinuousPaintingEnabled(0, continuousPaintingEnabled); | 367 setContinuousPaintingEnabled(0, continuousPaintingEnabled); |
| 372 | 368 |
| 373 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pag
eAgentScreenWidthOverride)); | 369 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pag
eAgentScreenWidthOverride)); |
| 374 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pa
geAgentScreenHeightOverride)); | 370 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pa
geAgentScreenHeightOverride)); |
| 375 double currentFontScaleFactor = m_state->getDouble(PageAgentState::pageA
gentFontScaleFactorOverride); | 371 double currentFontScaleFactor = m_state->getDouble(PageAgentState::pageA
gentFontScaleFactorOverride); |
| 376 bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFit
Window); | 372 bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFit
Window); |
| 377 updateViewMetrics(currentWidth, currentHeight, currentFontScaleFactor, c
urrentFitWindow); | 373 updateViewMetrics(currentWidth, currentHeight, currentFontScaleFactor, c
urrentFitWindow); |
| 378 #if ENABLE(TOUCH_EVENTS) | |
| 379 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc
hEventEmulationEnabled)); | 374 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc
hEventEmulationEnabled)); |
| 380 #endif | |
| 381 } | 375 } |
| 382 } | 376 } |
| 383 | 377 |
| 384 void InspectorPageAgent::webViewResized(const IntSize& size) | 378 void InspectorPageAgent::webViewResized(const IntSize& size) |
| 385 { | 379 { |
| 386 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAge
ntScreenWidthOverride)); | 380 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAge
ntScreenWidthOverride)); |
| 387 m_overlay->resize(currentWidth ? size : IntSize()); | 381 m_overlay->resize(currentWidth ? size : IntSize()); |
| 388 } | 382 } |
| 389 | 383 |
| 390 void InspectorPageAgent::enable(ErrorString*) | 384 void InspectorPageAgent::enable(ErrorString*) |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 void InspectorPageAgent::updateViewMetrics(int width, int height, double fontSca
leFactor, bool fitWindow) | 1074 void InspectorPageAgent::updateViewMetrics(int width, int height, double fontSca
leFactor, bool fitWindow) |
| 1081 { | 1075 { |
| 1082 m_client->overrideDeviceMetrics(width, height, static_cast<float>(fontScaleF
actor), fitWindow); | 1076 m_client->overrideDeviceMetrics(width, height, static_cast<float>(fontScaleF
actor), fitWindow); |
| 1083 | 1077 |
| 1084 Document* document = mainFrame()->document(); | 1078 Document* document = mainFrame()->document(); |
| 1085 if (document) | 1079 if (document) |
| 1086 document->styleResolverChanged(RecalcStyleImmediately); | 1080 document->styleResolverChanged(RecalcStyleImmediately); |
| 1087 InspectorInstrumentation::mediaQueryResultChanged(document); | 1081 InspectorInstrumentation::mediaQueryResultChanged(document); |
| 1088 } | 1082 } |
| 1089 | 1083 |
| 1090 #if ENABLE(TOUCH_EVENTS) | |
| 1091 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled) | 1084 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled) |
| 1092 { | 1085 { |
| 1093 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled); | 1086 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled); |
| 1094 if (mainFrame() && mainFrame()->settings()) | 1087 if (mainFrame() && mainFrame()->settings()) |
| 1095 mainFrame()->settings()->setTouchEventEmulationEnabled(enabled); | 1088 mainFrame()->settings()->setTouchEventEmulationEnabled(enabled); |
| 1096 } | 1089 } |
| 1097 #endif | |
| 1098 | 1090 |
| 1099 void InspectorPageAgent::setGeolocationOverride(ErrorString* error, const double
* latitude, const double* longitude, const double* accuracy) | 1091 void InspectorPageAgent::setGeolocationOverride(ErrorString* error, const double
* latitude, const double* longitude, const double* accuracy) |
| 1100 { | 1092 { |
| 1101 GeolocationController* controller = GeolocationController::from(m_page); | 1093 GeolocationController* controller = GeolocationController::from(m_page); |
| 1102 GeolocationPosition* position = 0; | 1094 GeolocationPosition* position = 0; |
| 1103 if (!controller) { | 1095 if (!controller) { |
| 1104 *error = "Internal error: unable to override geolocation"; | 1096 *error = "Internal error: unable to override geolocation"; |
| 1105 return; | 1097 return; |
| 1106 } | 1098 } |
| 1107 position = controller->lastPosition(); | 1099 position = controller->lastPosition(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 | 1153 |
| 1162 DeviceOrientationData* InspectorPageAgent::overrideDeviceOrientation(DeviceOrien
tationData* deviceOrientation) | 1154 DeviceOrientationData* InspectorPageAgent::overrideDeviceOrientation(DeviceOrien
tationData* deviceOrientation) |
| 1163 { | 1155 { |
| 1164 if (m_deviceOrientation) | 1156 if (m_deviceOrientation) |
| 1165 deviceOrientation = m_deviceOrientation.get(); | 1157 deviceOrientation = m_deviceOrientation.get(); |
| 1166 return deviceOrientation; | 1158 return deviceOrientation; |
| 1167 } | 1159 } |
| 1168 | 1160 |
| 1169 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString* error, bool enabl
ed) | 1161 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString* error, bool enabl
ed) |
| 1170 { | 1162 { |
| 1171 #if ENABLE(TOUCH_EVENTS) | |
| 1172 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl
ed) | 1163 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl
ed) |
| 1173 return; | 1164 return; |
| 1174 UNUSED_PARAM(error); | 1165 UNUSED_PARAM(error); |
| 1175 updateTouchEventEmulationInPage(enabled); | 1166 updateTouchEventEmulationInPage(enabled); |
| 1176 #else | |
| 1177 *error = "Touch events emulation not supported"; | |
| 1178 UNUSED_PARAM(enabled); | |
| 1179 #endif | |
| 1180 } | 1167 } |
| 1181 | 1168 |
| 1182 void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media) | 1169 void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media) |
| 1183 { | 1170 { |
| 1184 String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMe
dia); | 1171 String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMe
dia); |
| 1185 if (media == currentMedia) | 1172 if (media == currentMedia) |
| 1186 return; | 1173 return; |
| 1187 | 1174 |
| 1188 m_state->setString(PageAgentState::pageAgentEmulatedMedia, media); | 1175 m_state->setString(PageAgentState::pageAgentEmulatedMedia, media); |
| 1189 Document* document = 0; | 1176 Document* document = 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 // Handled on the browser level. | 1215 // Handled on the browser level. |
| 1229 } | 1216 } |
| 1230 | 1217 |
| 1231 void InspectorPageAgent::handleJavaScriptDialog(ErrorString* errorString, bool a
ccept, const String* promptText) | 1218 void InspectorPageAgent::handleJavaScriptDialog(ErrorString* errorString, bool a
ccept, const String* promptText) |
| 1232 { | 1219 { |
| 1233 // Handled on the browser level. | 1220 // Handled on the browser level. |
| 1234 } | 1221 } |
| 1235 | 1222 |
| 1236 } // namespace WebCore | 1223 } // namespace WebCore |
| 1237 | 1224 |
| OLD | NEW |