| 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 #ifndef EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ | 6 #define EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "extensions/browser/api/execute_code_function.h" | 11 #include "extensions/browser/api/execute_code_function.h" |
| 12 #include "extensions/browser/api/web_contents_capture_client.h" | 12 #include "extensions/browser/api/web_contents_capture_client.h" |
| 13 #include "extensions/browser/extension_function.h" | 13 #include "extensions/browser/extension_function.h" |
| 14 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" | 14 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" |
| 15 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 15 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 16 | 16 |
| 17 // WARNING: WebViewInternal could be loaded in an unblessed context, thus any | 17 // WARNING: WebViewInternal could be loaded in an unblessed context, thus any |
| 18 // new APIs must extend WebViewInternalExtensionFunction or | 18 // new APIs must extend WebViewInternalExtensionFunction or |
| 19 // WebViewInternalExecuteCodeFunction which do a process ID check to prevent | 19 // WebViewInternalExecuteCodeFunction which do a process ID check to prevent |
| 20 // abuse by normal renderer processes. | 20 // abuse by normal renderer processes. |
| 21 namespace extensions { | 21 namespace extensions { |
| 22 | 22 |
| 23 // An abstract base class for async webview APIs. It does a process ID check | 23 // An abstract base class for async webview APIs. It does a process ID check |
| 24 // in RunAsync, and then calls RunAsyncSafe which must be overriden by all | 24 // in RunAsync, and then calls RunAsyncSafe which must be overriden by all |
| 25 // subclasses. | 25 // subclasses. |
| 26 class WebViewInternalExtensionFunction : public AsyncExtensionFunction { | 26 class LegacyWebViewInternalExtensionFunction : public AsyncExtensionFunction { |
| 27 public: | 27 public: |
| 28 WebViewInternalExtensionFunction() {} | 28 LegacyWebViewInternalExtensionFunction() {} |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 ~WebViewInternalExtensionFunction() override {} | 31 ~LegacyWebViewInternalExtensionFunction() override {} |
| 32 | 32 |
| 33 // ExtensionFunction implementation. | 33 // ExtensionFunction implementation. |
| 34 bool RunAsync() final; | 34 bool RunAsync() final; |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 virtual bool RunAsyncSafe(WebViewGuest* guest) = 0; | 37 virtual bool RunAsyncSafe(WebViewGuest* guest) = 0; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class WebViewInternalExtensionFunction : public UIThreadExtensionFunction { |
| 41 public: |
| 42 WebViewInternalExtensionFunction() {} |
| 43 |
| 44 protected: |
| 45 ~WebViewInternalExtensionFunction() override {} |
| 46 bool PreRunValidation(std::string* error) override; |
| 47 |
| 48 WebViewGuest* guest_ = nullptr; |
| 49 }; |
| 50 |
| 40 class WebViewInternalCaptureVisibleRegionFunction | 51 class WebViewInternalCaptureVisibleRegionFunction |
| 41 : public WebViewInternalExtensionFunction, | 52 : public LegacyWebViewInternalExtensionFunction, |
| 42 public WebContentsCaptureClient { | 53 public WebContentsCaptureClient { |
| 43 public: | 54 public: |
| 44 DECLARE_EXTENSION_FUNCTION("webViewInternal.captureVisibleRegion", | 55 DECLARE_EXTENSION_FUNCTION("webViewInternal.captureVisibleRegion", |
| 45 WEBVIEWINTERNAL_CAPTUREVISIBLEREGION); | 56 WEBVIEWINTERNAL_CAPTUREVISIBLEREGION); |
| 46 WebViewInternalCaptureVisibleRegionFunction(); | 57 WebViewInternalCaptureVisibleRegionFunction(); |
| 47 | 58 |
| 48 protected: | 59 protected: |
| 49 ~WebViewInternalCaptureVisibleRegionFunction() override {} | 60 ~WebViewInternalCaptureVisibleRegionFunction() override {} |
| 50 | 61 |
| 51 private: | 62 private: |
| 52 // WebViewInternalExtensionFunction implementation. | 63 // LegacyWebViewInternalExtensionFunction implementation. |
| 53 bool RunAsyncSafe(WebViewGuest* guest) override; | 64 bool RunAsyncSafe(WebViewGuest* guest) override; |
| 54 | 65 |
| 55 // extensions::WebContentsCaptureClient: | 66 // extensions::WebContentsCaptureClient: |
| 56 bool IsScreenshotEnabled() override; | 67 bool IsScreenshotEnabled() override; |
| 57 bool ClientAllowsTransparency() override; | 68 bool ClientAllowsTransparency() override; |
| 58 void OnCaptureSuccess(const SkBitmap& bitmap) override; | 69 void OnCaptureSuccess(const SkBitmap& bitmap) override; |
| 59 void OnCaptureFailure(FailureReason reason) override; | 70 void OnCaptureFailure(FailureReason reason) override; |
| 60 | 71 |
| 61 bool is_guest_transparent_; | 72 bool is_guest_transparent_; |
| 62 | 73 |
| 63 DISALLOW_COPY_AND_ASSIGN(WebViewInternalCaptureVisibleRegionFunction); | 74 DISALLOW_COPY_AND_ASSIGN(WebViewInternalCaptureVisibleRegionFunction); |
| 64 }; | 75 }; |
| 65 | 76 |
| 66 class WebViewInternalNavigateFunction | 77 class WebViewInternalNavigateFunction |
| 67 : public WebViewInternalExtensionFunction { | 78 : public WebViewInternalExtensionFunction { |
| 68 public: | 79 public: |
| 69 DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate", | 80 DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate", |
| 70 WEBVIEWINTERNAL_NAVIGATE); | 81 WEBVIEWINTERNAL_NAVIGATE); |
| 71 WebViewInternalNavigateFunction() {} | 82 WebViewInternalNavigateFunction() {} |
| 72 | 83 |
| 73 protected: | 84 protected: |
| 74 ~WebViewInternalNavigateFunction() override {} | 85 ~WebViewInternalNavigateFunction() override {} |
| 75 | 86 ResponseAction Run() override; |
| 76 private: | |
| 77 // WebViewInternalExtensionFunction implementation. | |
| 78 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 79 | 87 |
| 80 DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction); | 88 DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction); |
| 81 }; | 89 }; |
| 82 | 90 |
| 83 class WebViewInternalExecuteCodeFunction | 91 class WebViewInternalExecuteCodeFunction |
| 84 : public extensions::ExecuteCodeFunction { | 92 : public extensions::ExecuteCodeFunction { |
| 85 public: | 93 public: |
| 86 WebViewInternalExecuteCodeFunction(); | 94 WebViewInternalExecuteCodeFunction(); |
| 87 | 95 |
| 88 protected: | 96 protected: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 196 |
| 189 class WebViewInternalSetNameFunction : public WebViewInternalExtensionFunction { | 197 class WebViewInternalSetNameFunction : public WebViewInternalExtensionFunction { |
| 190 public: | 198 public: |
| 191 DECLARE_EXTENSION_FUNCTION("webViewInternal.setName", | 199 DECLARE_EXTENSION_FUNCTION("webViewInternal.setName", |
| 192 WEBVIEWINTERNAL_SETNAME); | 200 WEBVIEWINTERNAL_SETNAME); |
| 193 | 201 |
| 194 WebViewInternalSetNameFunction(); | 202 WebViewInternalSetNameFunction(); |
| 195 | 203 |
| 196 protected: | 204 protected: |
| 197 ~WebViewInternalSetNameFunction() override; | 205 ~WebViewInternalSetNameFunction() override; |
| 198 | 206 ResponseAction Run() override; |
| 199 private: | |
| 200 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 201 | 207 |
| 202 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetNameFunction); | 208 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetNameFunction); |
| 203 }; | 209 }; |
| 204 | 210 |
| 205 class WebViewInternalSetAllowTransparencyFunction : | 211 class WebViewInternalSetAllowTransparencyFunction |
| 206 public WebViewInternalExtensionFunction { | 212 : public WebViewInternalExtensionFunction { |
| 207 public: | 213 public: |
| 208 DECLARE_EXTENSION_FUNCTION("webViewInternal.setAllowTransparency", | 214 DECLARE_EXTENSION_FUNCTION("webViewInternal.setAllowTransparency", |
| 209 WEBVIEWINTERNAL_SETALLOWTRANSPARENCY); | 215 WEBVIEWINTERNAL_SETALLOWTRANSPARENCY); |
| 210 | 216 |
| 211 WebViewInternalSetAllowTransparencyFunction(); | 217 WebViewInternalSetAllowTransparencyFunction(); |
| 212 | 218 |
| 213 protected: | 219 protected: |
| 214 ~WebViewInternalSetAllowTransparencyFunction() override; | 220 ~WebViewInternalSetAllowTransparencyFunction() override; |
| 215 | 221 ResponseAction Run() override; |
| 216 private: | |
| 217 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 218 | 222 |
| 219 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetAllowTransparencyFunction); | 223 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetAllowTransparencyFunction); |
| 220 }; | 224 }; |
| 221 | 225 |
| 222 class WebViewInternalSetAllowScalingFunction | 226 class WebViewInternalSetAllowScalingFunction |
| 223 : public WebViewInternalExtensionFunction { | 227 : public WebViewInternalExtensionFunction { |
| 224 public: | 228 public: |
| 225 DECLARE_EXTENSION_FUNCTION("webViewInternal.setAllowScaling", | 229 DECLARE_EXTENSION_FUNCTION("webViewInternal.setAllowScaling", |
| 226 WEBVIEWINTERNAL_SETALLOWSCALING); | 230 WEBVIEWINTERNAL_SETALLOWSCALING); |
| 227 | 231 |
| 228 WebViewInternalSetAllowScalingFunction(); | 232 WebViewInternalSetAllowScalingFunction(); |
| 229 | 233 |
| 230 protected: | 234 protected: |
| 231 ~WebViewInternalSetAllowScalingFunction() override; | 235 ~WebViewInternalSetAllowScalingFunction() override; |
| 232 | 236 ResponseAction Run() override; |
| 233 private: | |
| 234 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 235 | 237 |
| 236 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetAllowScalingFunction); | 238 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetAllowScalingFunction); |
| 237 }; | 239 }; |
| 238 | 240 |
| 239 class WebViewInternalSetZoomFunction : public WebViewInternalExtensionFunction { | 241 class WebViewInternalSetZoomFunction : public WebViewInternalExtensionFunction { |
| 240 public: | 242 public: |
| 241 DECLARE_EXTENSION_FUNCTION("webViewInternal.setZoom", | 243 DECLARE_EXTENSION_FUNCTION("webViewInternal.setZoom", |
| 242 WEBVIEWINTERNAL_SETZOOM); | 244 WEBVIEWINTERNAL_SETZOOM); |
| 243 | 245 |
| 244 WebViewInternalSetZoomFunction(); | 246 WebViewInternalSetZoomFunction(); |
| 245 | 247 |
| 246 protected: | 248 protected: |
| 247 ~WebViewInternalSetZoomFunction() override; | 249 ~WebViewInternalSetZoomFunction() override; |
| 248 | 250 ResponseAction Run() override; |
| 249 private: | |
| 250 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 251 | 251 |
| 252 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetZoomFunction); | 252 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetZoomFunction); |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 class WebViewInternalGetZoomFunction : public WebViewInternalExtensionFunction { | 255 class WebViewInternalGetZoomFunction : public WebViewInternalExtensionFunction { |
| 256 public: | 256 public: |
| 257 DECLARE_EXTENSION_FUNCTION("webViewInternal.getZoom", | 257 DECLARE_EXTENSION_FUNCTION("webViewInternal.getZoom", |
| 258 WEBVIEWINTERNAL_GETZOOM); | 258 WEBVIEWINTERNAL_GETZOOM); |
| 259 | 259 |
| 260 WebViewInternalGetZoomFunction(); | 260 WebViewInternalGetZoomFunction(); |
| 261 | 261 |
| 262 protected: | 262 protected: |
| 263 ~WebViewInternalGetZoomFunction() override; | 263 ~WebViewInternalGetZoomFunction() override; |
| 264 | 264 ResponseAction Run() override; |
| 265 private: | |
| 266 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 267 | 265 |
| 268 DISALLOW_COPY_AND_ASSIGN(WebViewInternalGetZoomFunction); | 266 DISALLOW_COPY_AND_ASSIGN(WebViewInternalGetZoomFunction); |
| 269 }; | 267 }; |
| 270 | 268 |
| 271 class WebViewInternalSetZoomModeFunction | 269 class WebViewInternalSetZoomModeFunction |
| 272 : public WebViewInternalExtensionFunction { | 270 : public WebViewInternalExtensionFunction { |
| 273 public: | 271 public: |
| 274 DECLARE_EXTENSION_FUNCTION("webViewInternal.setZoomMode", | 272 DECLARE_EXTENSION_FUNCTION("webViewInternal.setZoomMode", |
| 275 WEBVIEWINTERNAL_SETZOOMMODE); | 273 WEBVIEWINTERNAL_SETZOOMMODE); |
| 276 | 274 |
| 277 WebViewInternalSetZoomModeFunction(); | 275 WebViewInternalSetZoomModeFunction(); |
| 278 | 276 |
| 279 protected: | 277 protected: |
| 280 ~WebViewInternalSetZoomModeFunction() override; | 278 ~WebViewInternalSetZoomModeFunction() override; |
| 281 | 279 ResponseAction Run() override; |
| 282 private: | |
| 283 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 284 | 280 |
| 285 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetZoomModeFunction); | 281 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetZoomModeFunction); |
| 286 }; | 282 }; |
| 287 | 283 |
| 288 class WebViewInternalGetZoomModeFunction | 284 class WebViewInternalGetZoomModeFunction |
| 289 : public WebViewInternalExtensionFunction { | 285 : public WebViewInternalExtensionFunction { |
| 290 public: | 286 public: |
| 291 DECLARE_EXTENSION_FUNCTION("webViewInternal.getZoomMode", | 287 DECLARE_EXTENSION_FUNCTION("webViewInternal.getZoomMode", |
| 292 WEBVIEWINTERNAL_GETZOOMMODE); | 288 WEBVIEWINTERNAL_GETZOOMMODE); |
| 293 | 289 |
| 294 WebViewInternalGetZoomModeFunction(); | 290 WebViewInternalGetZoomModeFunction(); |
| 295 | 291 |
| 296 protected: | 292 protected: |
| 297 ~WebViewInternalGetZoomModeFunction() override; | 293 ~WebViewInternalGetZoomModeFunction() override; |
| 298 | 294 ResponseAction Run() override; |
| 299 private: | |
| 300 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 301 | 295 |
| 302 DISALLOW_COPY_AND_ASSIGN(WebViewInternalGetZoomModeFunction); | 296 DISALLOW_COPY_AND_ASSIGN(WebViewInternalGetZoomModeFunction); |
| 303 }; | 297 }; |
| 304 | 298 |
| 305 class WebViewInternalFindFunction : public WebViewInternalExtensionFunction { | 299 class WebViewInternalFindFunction |
| 300 : public LegacyWebViewInternalExtensionFunction { |
| 306 public: | 301 public: |
| 307 DECLARE_EXTENSION_FUNCTION("webViewInternal.find", WEBVIEWINTERNAL_FIND); | 302 DECLARE_EXTENSION_FUNCTION("webViewInternal.find", WEBVIEWINTERNAL_FIND); |
| 308 | 303 |
| 309 WebViewInternalFindFunction(); | 304 WebViewInternalFindFunction(); |
| 310 | 305 |
| 311 // Exposes SendResponse() for use by WebViewInternalFindHelper. | 306 // Exposes SendResponse() for use by WebViewInternalFindHelper. |
| 312 using WebViewInternalExtensionFunction::SendResponse; | 307 using LegacyWebViewInternalExtensionFunction::SendResponse; |
| 313 | 308 |
| 314 protected: | 309 protected: |
| 315 ~WebViewInternalFindFunction() override; | 310 ~WebViewInternalFindFunction() override; |
| 316 | 311 |
| 317 private: | 312 private: |
| 318 // WebViewInternalExtensionFunction implementation. | 313 // LegacyWebViewInternalExtensionFunction implementation. |
| 319 bool RunAsyncSafe(WebViewGuest* guest) override; | 314 bool RunAsyncSafe(WebViewGuest* guest) override; |
| 320 | 315 |
| 321 DISALLOW_COPY_AND_ASSIGN(WebViewInternalFindFunction); | 316 DISALLOW_COPY_AND_ASSIGN(WebViewInternalFindFunction); |
| 322 }; | 317 }; |
| 323 | 318 |
| 324 class WebViewInternalStopFindingFunction | 319 class WebViewInternalStopFindingFunction |
| 325 : public WebViewInternalExtensionFunction { | 320 : public WebViewInternalExtensionFunction { |
| 326 public: | 321 public: |
| 327 DECLARE_EXTENSION_FUNCTION("webViewInternal.stopFinding", | 322 DECLARE_EXTENSION_FUNCTION("webViewInternal.stopFinding", |
| 328 WEBVIEWINTERNAL_STOPFINDING); | 323 WEBVIEWINTERNAL_STOPFINDING); |
| 329 | 324 |
| 330 WebViewInternalStopFindingFunction(); | 325 WebViewInternalStopFindingFunction(); |
| 331 | 326 |
| 332 protected: | 327 protected: |
| 333 ~WebViewInternalStopFindingFunction() override; | 328 ~WebViewInternalStopFindingFunction() override; |
| 334 | 329 ResponseAction Run() override; |
| 335 private: | |
| 336 // WebViewInternalExtensionFunction implementation. | |
| 337 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 338 | 330 |
| 339 DISALLOW_COPY_AND_ASSIGN(WebViewInternalStopFindingFunction); | 331 DISALLOW_COPY_AND_ASSIGN(WebViewInternalStopFindingFunction); |
| 340 }; | 332 }; |
| 341 | 333 |
| 342 class WebViewInternalLoadDataWithBaseUrlFunction | 334 class WebViewInternalLoadDataWithBaseUrlFunction |
| 343 : public WebViewInternalExtensionFunction { | 335 : public WebViewInternalExtensionFunction { |
| 344 public: | 336 public: |
| 345 DECLARE_EXTENSION_FUNCTION("webViewInternal.loadDataWithBaseUrl", | 337 DECLARE_EXTENSION_FUNCTION("webViewInternal.loadDataWithBaseUrl", |
| 346 WEBVIEWINTERNAL_LOADDATAWITHBASEURL); | 338 WEBVIEWINTERNAL_LOADDATAWITHBASEURL); |
| 347 | 339 |
| 348 WebViewInternalLoadDataWithBaseUrlFunction(); | 340 WebViewInternalLoadDataWithBaseUrlFunction(); |
| 349 | 341 |
| 350 protected: | 342 protected: |
| 351 ~WebViewInternalLoadDataWithBaseUrlFunction() override; | 343 ~WebViewInternalLoadDataWithBaseUrlFunction() override; |
| 352 | 344 ResponseAction Run() override; |
| 353 private: | |
| 354 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 355 | 345 |
| 356 DISALLOW_COPY_AND_ASSIGN(WebViewInternalLoadDataWithBaseUrlFunction); | 346 DISALLOW_COPY_AND_ASSIGN(WebViewInternalLoadDataWithBaseUrlFunction); |
| 357 }; | 347 }; |
| 358 | 348 |
| 359 class WebViewInternalGoFunction : public WebViewInternalExtensionFunction { | 349 class WebViewInternalGoFunction : public WebViewInternalExtensionFunction { |
| 360 public: | 350 public: |
| 361 DECLARE_EXTENSION_FUNCTION("webViewInternal.go", WEBVIEWINTERNAL_GO); | 351 DECLARE_EXTENSION_FUNCTION("webViewInternal.go", WEBVIEWINTERNAL_GO); |
| 362 | 352 |
| 363 WebViewInternalGoFunction(); | 353 WebViewInternalGoFunction(); |
| 364 | 354 |
| 365 protected: | 355 protected: |
| 366 ~WebViewInternalGoFunction() override; | 356 ~WebViewInternalGoFunction() override; |
| 367 | 357 ResponseAction Run() override; |
| 368 private: | |
| 369 // WebViewInternalExtensionFunction implementation. | |
| 370 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 371 | 358 |
| 372 DISALLOW_COPY_AND_ASSIGN(WebViewInternalGoFunction); | 359 DISALLOW_COPY_AND_ASSIGN(WebViewInternalGoFunction); |
| 373 }; | 360 }; |
| 374 | 361 |
| 375 class WebViewInternalReloadFunction : public WebViewInternalExtensionFunction { | 362 class WebViewInternalReloadFunction : public WebViewInternalExtensionFunction { |
| 376 public: | 363 public: |
| 377 DECLARE_EXTENSION_FUNCTION("webViewInternal.reload", WEBVIEWINTERNAL_RELOAD); | 364 DECLARE_EXTENSION_FUNCTION("webViewInternal.reload", WEBVIEWINTERNAL_RELOAD); |
| 378 | 365 |
| 379 WebViewInternalReloadFunction(); | 366 WebViewInternalReloadFunction(); |
| 380 | 367 |
| 381 protected: | 368 protected: |
| 382 ~WebViewInternalReloadFunction() override; | 369 ~WebViewInternalReloadFunction() override; |
| 383 | 370 ResponseAction Run() override; |
| 384 private: | |
| 385 // WebViewInternalExtensionFunction implementation. | |
| 386 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 387 | 371 |
| 388 DISALLOW_COPY_AND_ASSIGN(WebViewInternalReloadFunction); | 372 DISALLOW_COPY_AND_ASSIGN(WebViewInternalReloadFunction); |
| 389 }; | 373 }; |
| 390 | 374 |
| 391 class WebViewInternalSetPermissionFunction | 375 class WebViewInternalSetPermissionFunction |
| 392 : public WebViewInternalExtensionFunction { | 376 : public WebViewInternalExtensionFunction { |
| 393 public: | 377 public: |
| 394 DECLARE_EXTENSION_FUNCTION("webViewInternal.setPermission", | 378 DECLARE_EXTENSION_FUNCTION("webViewInternal.setPermission", |
| 395 WEBVIEWINTERNAL_SETPERMISSION); | 379 WEBVIEWINTERNAL_SETPERMISSION); |
| 396 | 380 |
| 397 WebViewInternalSetPermissionFunction(); | 381 WebViewInternalSetPermissionFunction(); |
| 398 | 382 |
| 399 protected: | 383 protected: |
| 400 ~WebViewInternalSetPermissionFunction() override; | 384 ~WebViewInternalSetPermissionFunction() override; |
| 401 | 385 ResponseAction Run() override; |
| 402 private: | |
| 403 // WebViewInternalExtensionFunction implementation. | |
| 404 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 405 | 386 |
| 406 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetPermissionFunction); | 387 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetPermissionFunction); |
| 407 }; | 388 }; |
| 408 | 389 |
| 409 class WebViewInternalOverrideUserAgentFunction | 390 class WebViewInternalOverrideUserAgentFunction |
| 410 : public WebViewInternalExtensionFunction { | 391 : public WebViewInternalExtensionFunction { |
| 411 public: | 392 public: |
| 412 DECLARE_EXTENSION_FUNCTION("webViewInternal.overrideUserAgent", | 393 DECLARE_EXTENSION_FUNCTION("webViewInternal.overrideUserAgent", |
| 413 WEBVIEWINTERNAL_OVERRIDEUSERAGENT); | 394 WEBVIEWINTERNAL_OVERRIDEUSERAGENT); |
| 414 | 395 |
| 415 WebViewInternalOverrideUserAgentFunction(); | 396 WebViewInternalOverrideUserAgentFunction(); |
| 416 | 397 |
| 417 protected: | 398 protected: |
| 418 ~WebViewInternalOverrideUserAgentFunction() override; | 399 ~WebViewInternalOverrideUserAgentFunction() override; |
| 419 | 400 ResponseAction Run() override; |
| 420 private: | |
| 421 // WebViewInternalExtensionFunction implementation. | |
| 422 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 423 | 401 |
| 424 DISALLOW_COPY_AND_ASSIGN(WebViewInternalOverrideUserAgentFunction); | 402 DISALLOW_COPY_AND_ASSIGN(WebViewInternalOverrideUserAgentFunction); |
| 425 }; | 403 }; |
| 426 | 404 |
| 427 class WebViewInternalStopFunction : public WebViewInternalExtensionFunction { | 405 class WebViewInternalStopFunction : public WebViewInternalExtensionFunction { |
| 428 public: | 406 public: |
| 429 DECLARE_EXTENSION_FUNCTION("webViewInternal.stop", WEBVIEWINTERNAL_STOP); | 407 DECLARE_EXTENSION_FUNCTION("webViewInternal.stop", WEBVIEWINTERNAL_STOP); |
| 430 | 408 |
| 431 WebViewInternalStopFunction(); | 409 WebViewInternalStopFunction(); |
| 432 | 410 |
| 433 protected: | 411 protected: |
| 434 ~WebViewInternalStopFunction() override; | 412 ~WebViewInternalStopFunction() override; |
| 435 | 413 ResponseAction Run() override; |
| 436 private: | |
| 437 // WebViewInternalExtensionFunction implementation. | |
| 438 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 439 | 414 |
| 440 DISALLOW_COPY_AND_ASSIGN(WebViewInternalStopFunction); | 415 DISALLOW_COPY_AND_ASSIGN(WebViewInternalStopFunction); |
| 441 }; | 416 }; |
| 442 | 417 |
| 443 class WebViewInternalTerminateFunction | 418 class WebViewInternalTerminateFunction |
| 444 : public WebViewInternalExtensionFunction { | 419 : public WebViewInternalExtensionFunction { |
| 445 public: | 420 public: |
| 446 DECLARE_EXTENSION_FUNCTION("webViewInternal.terminate", | 421 DECLARE_EXTENSION_FUNCTION("webViewInternal.terminate", |
| 447 WEBVIEWINTERNAL_TERMINATE); | 422 WEBVIEWINTERNAL_TERMINATE); |
| 448 | 423 |
| 449 WebViewInternalTerminateFunction(); | 424 WebViewInternalTerminateFunction(); |
| 450 | 425 |
| 451 protected: | 426 protected: |
| 452 ~WebViewInternalTerminateFunction() override; | 427 ~WebViewInternalTerminateFunction() override; |
| 453 | 428 ResponseAction Run() override; |
| 454 private: | |
| 455 // WebViewInternalExtensionFunction implementation. | |
| 456 bool RunAsyncSafe(WebViewGuest* guest) override; | |
| 457 | 429 |
| 458 DISALLOW_COPY_AND_ASSIGN(WebViewInternalTerminateFunction); | 430 DISALLOW_COPY_AND_ASSIGN(WebViewInternalTerminateFunction); |
| 459 }; | 431 }; |
| 460 | 432 |
| 461 class WebViewInternalClearDataFunction | 433 class WebViewInternalClearDataFunction |
| 462 : public WebViewInternalExtensionFunction { | 434 : public LegacyWebViewInternalExtensionFunction { |
| 463 public: | 435 public: |
| 464 DECLARE_EXTENSION_FUNCTION("webViewInternal.clearData", | 436 DECLARE_EXTENSION_FUNCTION("webViewInternal.clearData", |
| 465 WEBVIEWINTERNAL_CLEARDATA); | 437 WEBVIEWINTERNAL_CLEARDATA); |
| 466 | 438 |
| 467 WebViewInternalClearDataFunction(); | 439 WebViewInternalClearDataFunction(); |
| 468 | 440 |
| 469 protected: | 441 protected: |
| 470 ~WebViewInternalClearDataFunction() override; | 442 ~WebViewInternalClearDataFunction() override; |
| 471 | 443 |
| 472 private: | 444 private: |
| 473 // WebViewInternalExtensionFunction implementation. | 445 // LegacyWebViewInternalExtensionFunction implementation. |
| 474 bool RunAsyncSafe(WebViewGuest* guest) override; | 446 bool RunAsyncSafe(WebViewGuest* guest) override; |
| 475 | 447 |
| 476 uint32_t GetRemovalMask(); | 448 uint32_t GetRemovalMask(); |
| 477 void ClearDataDone(); | 449 void ClearDataDone(); |
| 478 | 450 |
| 479 // Removal start time. | 451 // Removal start time. |
| 480 base::Time remove_since_; | 452 base::Time remove_since_; |
| 481 // Removal mask, corresponds to StoragePartition::RemoveDataMask enum. | 453 // Removal mask, corresponds to StoragePartition::RemoveDataMask enum. |
| 482 uint32_t remove_mask_; | 454 uint32_t remove_mask_; |
| 483 // Tracks any data related or parse errors. | 455 // Tracks any data related or parse errors. |
| 484 bool bad_message_; | 456 bool bad_message_; |
| 485 | 457 |
| 486 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); | 458 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); |
| 487 }; | 459 }; |
| 488 | 460 |
| 489 } // namespace extensions | 461 } // namespace extensions |
| 490 | 462 |
| 491 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ | 463 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ |
| OLD | NEW |