| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions are | |
| 7 * met: | |
| 8 * | |
| 9 * * Redistributions of source code must retain the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer. | |
| 11 * * Redistributions in binary form must reproduce the above | |
| 12 * copyright notice, this list of conditions and the following disclaimer | |
| 13 * in the documentation and/or other materials provided with the | |
| 14 * distribution. | |
| 15 * * Neither the name of Google Inc. nor the names of its | |
| 16 * contributors may be used to endorse or promote products derived from | |
| 17 * this software without specific prior written permission. | |
| 18 * | |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 30 */ | |
| 31 | |
| 32 #include "web/FrameLoaderClientImpl.h" | |
| 33 | |
| 34 #include "bindings/core/v8/ScriptController.h" | |
| 35 #include "core/HTMLNames.h" | |
| 36 #include "core/dom/Document.h" | |
| 37 #include "core/dom/Fullscreen.h" | |
| 38 #include "core/events/MessageEvent.h" | |
| 39 #include "core/events/MouseEvent.h" | |
| 40 #include "core/events/UIEventWithKeyState.h" | |
| 41 #include "core/frame/FrameView.h" | |
| 42 #include "core/frame/Settings.h" | |
| 43 #include "core/html/HTMLFrameElementBase.h" | |
| 44 #include "core/html/HTMLMediaElement.h" | |
| 45 #include "core/html/HTMLPlugInElement.h" | |
| 46 #include "core/input/EventHandler.h" | |
| 47 #include "core/layout/HitTestResult.h" | |
| 48 #include "core/loader/DocumentLoader.h" | |
| 49 #include "core/loader/FrameLoadRequest.h" | |
| 50 #include "core/loader/FrameLoader.h" | |
| 51 #include "core/loader/HistoryItem.h" | |
| 52 #include "core/origin_trials/OriginTrials.h" | |
| 53 #include "core/page/Page.h" | |
| 54 #include "core/page/WindowFeatures.h" | |
| 55 #include "modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.h" | |
| 56 #include "modules/device_light/DeviceLightController.h" | |
| 57 #include "modules/device_orientation/DeviceMotionController.h" | |
| 58 #include "modules/device_orientation/DeviceOrientationAbsoluteController.h" | |
| 59 #include "modules/device_orientation/DeviceOrientationController.h" | |
| 60 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" | |
| 61 #include "modules/gamepad/NavigatorGamepad.h" | |
| 62 #include "modules/remoteplayback/HTMLMediaElementRemotePlayback.h" | |
| 63 #include "modules/remoteplayback/RemotePlayback.h" | |
| 64 #include "modules/serviceworkers/NavigatorServiceWorker.h" | |
| 65 #include "modules/serviceworkers/ServiceWorkerLinkResource.h" | |
| 66 #include "modules/storage/DOMWindowStorageController.h" | |
| 67 #include "modules/vr/NavigatorVR.h" | |
| 68 #include "platform/Histogram.h" | |
| 69 #include "platform/RuntimeEnabledFeatures.h" | |
| 70 #include "platform/UserGestureIndicator.h" | |
| 71 #include "platform/exported/WrappedResourceRequest.h" | |
| 72 #include "platform/exported/WrappedResourceResponse.h" | |
| 73 #include "platform/network/HTTPParsers.h" | |
| 74 #include "platform/network/mime/MIMETypeRegistry.h" | |
| 75 #include "platform/plugins/PluginData.h" | |
| 76 #include "public/platform/Platform.h" | |
| 77 #include "public/platform/WebApplicationCacheHost.h" | |
| 78 #include "public/platform/WebMediaPlayerSource.h" | |
| 79 #include "public/platform/WebRTCPeerConnectionHandler.h" | |
| 80 #include "public/platform/WebSecurityOrigin.h" | |
| 81 #include "public/platform/WebURL.h" | |
| 82 #include "public/platform/WebURLError.h" | |
| 83 #include "public/platform/WebVector.h" | |
| 84 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" | |
| 85 #include "public/platform/modules/serviceworker/WebServiceWorkerProviderClient.h
" | |
| 86 #include "public/web/WebAutofillClient.h" | |
| 87 #include "public/web/WebContentSettingsClient.h" | |
| 88 #include "public/web/WebDOMEvent.h" | |
| 89 #include "public/web/WebDocument.h" | |
| 90 #include "public/web/WebFormElement.h" | |
| 91 #include "public/web/WebFrameClient.h" | |
| 92 #include "public/web/WebNode.h" | |
| 93 #include "public/web/WebPlugin.h" | |
| 94 #include "public/web/WebPluginParams.h" | |
| 95 #include "public/web/WebViewClient.h" | |
| 96 #include "web/DevToolsEmulator.h" | |
| 97 #include "web/SharedWorkerRepositoryClientImpl.h" | |
| 98 #include "web/WebDataSourceImpl.h" | |
| 99 #include "web/WebDevToolsAgentImpl.h" | |
| 100 #include "web/WebDevToolsFrontendImpl.h" | |
| 101 #include "web/WebLocalFrameImpl.h" | |
| 102 #include "web/WebPluginContainerImpl.h" | |
| 103 #include "web/WebViewImpl.h" | |
| 104 #include "wtf/PtrUtil.h" | |
| 105 #include "wtf/StringExtras.h" | |
| 106 #include "wtf/text/CString.h" | |
| 107 #include "wtf/text/WTFString.h" | |
| 108 #include <memory> | |
| 109 #include <v8.h> | |
| 110 | |
| 111 namespace blink { | |
| 112 | |
| 113 namespace { | |
| 114 | |
| 115 // Convenience helper for frame tree helpers in FrameClient to reduce the amount | |
| 116 // of null-checking boilerplate code. Since the frame tree is maintained in the | |
| 117 // web/ layer, the frame tree helpers often have to deal with null WebFrames: | |
| 118 // for example, a frame with no parent will return null for WebFrame::parent(). | |
| 119 // TODO(dcheng): Remove duplication between FrameLoaderClientImpl and | |
| 120 // RemoteFrameClientImpl somehow... | |
| 121 Frame* toCoreFrame(WebFrame* frame) { | |
| 122 return frame ? frame->toImplBase()->frame() : nullptr; | |
| 123 } | |
| 124 | |
| 125 } // namespace | |
| 126 | |
| 127 FrameLoaderClientImpl::FrameLoaderClientImpl(WebLocalFrameImpl* frame) | |
| 128 : m_webFrame(frame) {} | |
| 129 | |
| 130 FrameLoaderClientImpl* FrameLoaderClientImpl::create(WebLocalFrameImpl* frame) { | |
| 131 return new FrameLoaderClientImpl(frame); | |
| 132 } | |
| 133 | |
| 134 FrameLoaderClientImpl::~FrameLoaderClientImpl() {} | |
| 135 | |
| 136 DEFINE_TRACE(FrameLoaderClientImpl) { | |
| 137 visitor->trace(m_webFrame); | |
| 138 FrameLoaderClient::trace(visitor); | |
| 139 } | |
| 140 | |
| 141 void FrameLoaderClientImpl::didCreateNewDocument() { | |
| 142 if (m_webFrame->client()) | |
| 143 m_webFrame->client()->didCreateNewDocument(m_webFrame); | |
| 144 } | |
| 145 | |
| 146 void FrameLoaderClientImpl::dispatchDidClearWindowObjectInMainWorld() { | |
| 147 if (m_webFrame->client()) { | |
| 148 m_webFrame->client()->didClearWindowObject(m_webFrame); | |
| 149 Document* document = m_webFrame->frame()->document(); | |
| 150 if (document) { | |
| 151 DeviceMotionController::from(*document); | |
| 152 DeviceOrientationController::from(*document); | |
| 153 DeviceOrientationAbsoluteController::from(*document); | |
| 154 if (RuntimeEnabledFeatures::deviceLightEnabled()) | |
| 155 DeviceLightController::from(*document); | |
| 156 NavigatorGamepad::from(*document); | |
| 157 NavigatorServiceWorker::from(*document); | |
| 158 DOMWindowStorageController::from(*document); | |
| 159 if (RuntimeEnabledFeatures::webVREnabled() || | |
| 160 OriginTrials::webVREnabled(document->getExecutionContext())) | |
| 161 NavigatorVR::from(*document); | |
| 162 } | |
| 163 } | |
| 164 // FIXME: when extensions go out of process, this whole concept stops working. | |
| 165 WebDevToolsFrontendImpl* devToolsFrontend = | |
| 166 m_webFrame->top()->isWebLocalFrame() | |
| 167 ? toWebLocalFrameImpl(m_webFrame->top())->devToolsFrontend() | |
| 168 : nullptr; | |
| 169 if (devToolsFrontend) | |
| 170 devToolsFrontend->didClearWindowObject(m_webFrame); | |
| 171 } | |
| 172 | |
| 173 void FrameLoaderClientImpl::documentElementAvailable() { | |
| 174 if (m_webFrame->client()) | |
| 175 m_webFrame->client()->didCreateDocumentElement(m_webFrame); | |
| 176 } | |
| 177 | |
| 178 void FrameLoaderClientImpl::runScriptsAtDocumentElementAvailable() { | |
| 179 if (m_webFrame->client()) | |
| 180 m_webFrame->client()->runScriptsAtDocumentElementAvailable(m_webFrame); | |
| 181 // The callback might have deleted the frame, do not use |this|! | |
| 182 } | |
| 183 | |
| 184 void FrameLoaderClientImpl::runScriptsAtDocumentReady(bool documentIsEmpty) { | |
| 185 if (m_webFrame->client()) | |
| 186 m_webFrame->client()->runScriptsAtDocumentReady(m_webFrame, | |
| 187 documentIsEmpty); | |
| 188 // The callback might have deleted the frame, do not use |this|! | |
| 189 } | |
| 190 | |
| 191 void FrameLoaderClientImpl::didCreateScriptContext( | |
| 192 v8::Local<v8::Context> context, | |
| 193 int worldId) { | |
| 194 if (m_webFrame->client()) | |
| 195 m_webFrame->client()->didCreateScriptContext(m_webFrame, context, worldId); | |
| 196 } | |
| 197 | |
| 198 void FrameLoaderClientImpl::willReleaseScriptContext( | |
| 199 v8::Local<v8::Context> context, | |
| 200 int worldId) { | |
| 201 if (m_webFrame->client()) | |
| 202 m_webFrame->client()->willReleaseScriptContext(m_webFrame, context, | |
| 203 worldId); | |
| 204 } | |
| 205 | |
| 206 bool FrameLoaderClientImpl::allowScriptExtensions() { | |
| 207 return true; | |
| 208 } | |
| 209 | |
| 210 void FrameLoaderClientImpl::didChangeScrollOffset() { | |
| 211 if (m_webFrame->client()) | |
| 212 m_webFrame->client()->didChangeScrollOffset(m_webFrame); | |
| 213 } | |
| 214 | |
| 215 void FrameLoaderClientImpl::didUpdateCurrentHistoryItem() { | |
| 216 if (m_webFrame->client()) | |
| 217 m_webFrame->client()->didUpdateCurrentHistoryItem(); | |
| 218 } | |
| 219 | |
| 220 bool FrameLoaderClientImpl::allowScript(bool enabledPerSettings) { | |
| 221 if (m_webFrame->contentSettingsClient()) | |
| 222 return m_webFrame->contentSettingsClient()->allowScript(enabledPerSettings); | |
| 223 | |
| 224 return enabledPerSettings; | |
| 225 } | |
| 226 | |
| 227 bool FrameLoaderClientImpl::allowScriptFromSource(bool enabledPerSettings, | |
| 228 const KURL& scriptURL) { | |
| 229 if (m_webFrame->contentSettingsClient()) | |
| 230 return m_webFrame->contentSettingsClient()->allowScriptFromSource( | |
| 231 enabledPerSettings, scriptURL); | |
| 232 | |
| 233 return enabledPerSettings; | |
| 234 } | |
| 235 | |
| 236 bool FrameLoaderClientImpl::allowPlugins(bool enabledPerSettings) { | |
| 237 if (m_webFrame->contentSettingsClient()) | |
| 238 return m_webFrame->contentSettingsClient()->allowPlugins( | |
| 239 enabledPerSettings); | |
| 240 | |
| 241 return enabledPerSettings; | |
| 242 } | |
| 243 | |
| 244 bool FrameLoaderClientImpl::allowImage(bool enabledPerSettings, | |
| 245 const KURL& imageURL) { | |
| 246 if (m_webFrame->contentSettingsClient()) | |
| 247 return m_webFrame->contentSettingsClient()->allowImage(enabledPerSettings, | |
| 248 imageURL); | |
| 249 | |
| 250 return enabledPerSettings; | |
| 251 } | |
| 252 | |
| 253 bool FrameLoaderClientImpl::allowRunningInsecureContent(bool enabledPerSettings, | |
| 254 SecurityOrigin* context, | |
| 255 const KURL& url) { | |
| 256 if (m_webFrame->contentSettingsClient()) | |
| 257 return m_webFrame->contentSettingsClient()->allowRunningInsecureContent( | |
| 258 enabledPerSettings, WebSecurityOrigin(context), WebURL(url)); | |
| 259 | |
| 260 return enabledPerSettings; | |
| 261 } | |
| 262 | |
| 263 bool FrameLoaderClientImpl::allowAutoplay(bool defaultValue) { | |
| 264 if (m_webFrame->contentSettingsClient()) | |
| 265 return m_webFrame->contentSettingsClient()->allowAutoplay(defaultValue); | |
| 266 | |
| 267 return defaultValue; | |
| 268 } | |
| 269 | |
| 270 void FrameLoaderClientImpl::passiveInsecureContentFound(const KURL& url) { | |
| 271 if (m_webFrame->contentSettingsClient()) | |
| 272 return m_webFrame->contentSettingsClient()->passiveInsecureContentFound( | |
| 273 WebURL(url)); | |
| 274 } | |
| 275 | |
| 276 void FrameLoaderClientImpl::didNotAllowScript() { | |
| 277 if (m_webFrame->contentSettingsClient()) | |
| 278 m_webFrame->contentSettingsClient()->didNotAllowScript(); | |
| 279 } | |
| 280 | |
| 281 void FrameLoaderClientImpl::didNotAllowPlugins() { | |
| 282 if (m_webFrame->contentSettingsClient()) | |
| 283 m_webFrame->contentSettingsClient()->didNotAllowPlugins(); | |
| 284 } | |
| 285 | |
| 286 bool FrameLoaderClientImpl::hasWebView() const { | |
| 287 return m_webFrame->viewImpl(); | |
| 288 } | |
| 289 | |
| 290 bool FrameLoaderClientImpl::inShadowTree() const { | |
| 291 return m_webFrame->inShadowTree(); | |
| 292 } | |
| 293 | |
| 294 Frame* FrameLoaderClientImpl::opener() const { | |
| 295 return toCoreFrame(m_webFrame->opener()); | |
| 296 } | |
| 297 | |
| 298 void FrameLoaderClientImpl::setOpener(Frame* opener) { | |
| 299 WebFrame* openerFrame = WebFrame::fromFrame(opener); | |
| 300 if (m_webFrame->client() && m_webFrame->opener() != openerFrame) | |
| 301 m_webFrame->client()->didChangeOpener(openerFrame); | |
| 302 m_webFrame->setOpener(openerFrame); | |
| 303 } | |
| 304 | |
| 305 Frame* FrameLoaderClientImpl::parent() const { | |
| 306 return toCoreFrame(m_webFrame->parent()); | |
| 307 } | |
| 308 | |
| 309 Frame* FrameLoaderClientImpl::top() const { | |
| 310 return toCoreFrame(m_webFrame->top()); | |
| 311 } | |
| 312 | |
| 313 Frame* FrameLoaderClientImpl::nextSibling() const { | |
| 314 return toCoreFrame(m_webFrame->nextSibling()); | |
| 315 } | |
| 316 | |
| 317 Frame* FrameLoaderClientImpl::firstChild() const { | |
| 318 return toCoreFrame(m_webFrame->firstChild()); | |
| 319 } | |
| 320 | |
| 321 void FrameLoaderClientImpl::willBeDetached() { | |
| 322 m_webFrame->willBeDetached(); | |
| 323 } | |
| 324 | |
| 325 void FrameLoaderClientImpl::detached(FrameDetachType type) { | |
| 326 // Alert the client that the frame is being detached. This is the last | |
| 327 // chance we have to communicate with the client. | |
| 328 WebFrameClient* client = m_webFrame->client(); | |
| 329 if (!client) | |
| 330 return; | |
| 331 | |
| 332 m_webFrame->willDetachParent(); | |
| 333 | |
| 334 // Signal that no further communication with WebFrameClient should take | |
| 335 // place at this point since we are no longer associated with the Page. | |
| 336 m_webFrame->setClient(0); | |
| 337 | |
| 338 client->frameDetached(m_webFrame, | |
| 339 static_cast<WebFrameClient::DetachType>(type)); | |
| 340 // Clear our reference to LocalFrame at the very end, in case the client | |
| 341 // refers to it. | |
| 342 m_webFrame->setCoreFrame(nullptr); | |
| 343 } | |
| 344 | |
| 345 void FrameLoaderClientImpl::dispatchWillSendRequest(ResourceRequest& request) { | |
| 346 // Give the WebFrameClient a crack at the request. | |
| 347 if (m_webFrame->client()) { | |
| 348 WrappedResourceRequest webreq(request); | |
| 349 m_webFrame->client()->willSendRequest(m_webFrame, webreq); | |
| 350 } | |
| 351 } | |
| 352 | |
| 353 void FrameLoaderClientImpl::dispatchDidReceiveResponse( | |
| 354 const ResourceResponse& response) { | |
| 355 if (m_webFrame->client()) { | |
| 356 WrappedResourceResponse webresp(response); | |
| 357 m_webFrame->client()->didReceiveResponse(webresp); | |
| 358 } | |
| 359 } | |
| 360 | |
| 361 void FrameLoaderClientImpl::dispatchDidFinishDocumentLoad() { | |
| 362 // TODO(dglazkov): Sadly, workers are WebFrameClients, and they can totally | |
| 363 // destroy themselves when didFinishDocumentLoad is invoked, and in turn | |
| 364 // destroy the fake WebLocalFrame that they create, which means that you | |
| 365 // should not put any code touching `this` after the two lines below. | |
| 366 if (m_webFrame->client()) | |
| 367 m_webFrame->client()->didFinishDocumentLoad(m_webFrame); | |
| 368 } | |
| 369 | |
| 370 void FrameLoaderClientImpl::dispatchDidLoadResourceFromMemoryCache( | |
| 371 const ResourceRequest& request, | |
| 372 const ResourceResponse& response) { | |
| 373 if (m_webFrame->client()) | |
| 374 m_webFrame->client()->didLoadResourceFromMemoryCache( | |
| 375 WrappedResourceRequest(request), WrappedResourceResponse(response)); | |
| 376 } | |
| 377 | |
| 378 void FrameLoaderClientImpl::dispatchDidHandleOnloadEvents() { | |
| 379 if (m_webFrame->client()) | |
| 380 m_webFrame->client()->didHandleOnloadEvents(m_webFrame); | |
| 381 } | |
| 382 | |
| 383 void FrameLoaderClientImpl:: | |
| 384 dispatchDidReceiveServerRedirectForProvisionalLoad() { | |
| 385 if (m_webFrame->client()) | |
| 386 m_webFrame->client()->didReceiveServerRedirectForProvisionalLoad( | |
| 387 m_webFrame); | |
| 388 } | |
| 389 | |
| 390 void FrameLoaderClientImpl::dispatchDidNavigateWithinPage( | |
| 391 HistoryItem* item, | |
| 392 HistoryCommitType commitType, | |
| 393 bool contentInitiated) { | |
| 394 bool shouldCreateHistoryEntry = commitType == StandardCommit; | |
| 395 // TODO(dglazkov): Does this need to be called for subframes? | |
| 396 m_webFrame->viewImpl()->didCommitLoad(shouldCreateHistoryEntry, true); | |
| 397 if (m_webFrame->client()) | |
| 398 m_webFrame->client()->didNavigateWithinPage( | |
| 399 m_webFrame, WebHistoryItem(item), | |
| 400 static_cast<WebHistoryCommitType>(commitType), contentInitiated); | |
| 401 } | |
| 402 | |
| 403 void FrameLoaderClientImpl::dispatchWillCommitProvisionalLoad() { | |
| 404 if (m_webFrame->client()) | |
| 405 m_webFrame->client()->willCommitProvisionalLoad(m_webFrame); | |
| 406 } | |
| 407 | |
| 408 void FrameLoaderClientImpl::dispatchDidStartProvisionalLoad( | |
| 409 DocumentLoader* loader) { | |
| 410 if (m_webFrame->client()) { | |
| 411 m_webFrame->client()->didStartProvisionalLoad( | |
| 412 WebDataSourceImpl::fromDocumentLoader(loader)); | |
| 413 } | |
| 414 if (WebDevToolsAgentImpl* devTools = devToolsAgent()) | |
| 415 devTools->didStartProvisionalLoad(m_webFrame->frame()); | |
| 416 } | |
| 417 | |
| 418 void FrameLoaderClientImpl::dispatchDidReceiveTitle(const String& title) { | |
| 419 if (m_webFrame->client()) | |
| 420 m_webFrame->client()->didReceiveTitle(m_webFrame, title, | |
| 421 WebTextDirectionLeftToRight); | |
| 422 } | |
| 423 | |
| 424 void FrameLoaderClientImpl::dispatchDidChangeIcons(IconType type) { | |
| 425 if (m_webFrame->client()) | |
| 426 m_webFrame->client()->didChangeIcon(m_webFrame, | |
| 427 static_cast<WebIconURL::Type>(type)); | |
| 428 } | |
| 429 | |
| 430 void FrameLoaderClientImpl::dispatchDidCommitLoad( | |
| 431 HistoryItem* item, | |
| 432 HistoryCommitType commitType) { | |
| 433 if (!m_webFrame->parent()) { | |
| 434 m_webFrame->viewImpl()->didCommitLoad(commitType == StandardCommit, false); | |
| 435 } | |
| 436 | |
| 437 if (m_webFrame->client()) | |
| 438 m_webFrame->client()->didCommitProvisionalLoad( | |
| 439 m_webFrame, WebHistoryItem(item), | |
| 440 static_cast<WebHistoryCommitType>(commitType)); | |
| 441 if (WebDevToolsAgentImpl* devTools = devToolsAgent()) | |
| 442 devTools->didCommitLoadForLocalFrame(m_webFrame->frame()); | |
| 443 } | |
| 444 | |
| 445 void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad( | |
| 446 const ResourceError& error, | |
| 447 HistoryCommitType commitType) { | |
| 448 m_webFrame->didFail(error, true, commitType); | |
| 449 } | |
| 450 | |
| 451 void FrameLoaderClientImpl::dispatchDidFailLoad(const ResourceError& error, | |
| 452 HistoryCommitType commitType) { | |
| 453 m_webFrame->didFail(error, false, commitType); | |
| 454 } | |
| 455 | |
| 456 void FrameLoaderClientImpl::dispatchDidFinishLoad() { | |
| 457 m_webFrame->didFinish(); | |
| 458 } | |
| 459 | |
| 460 void FrameLoaderClientImpl::dispatchDidChangeThemeColor() { | |
| 461 if (m_webFrame->client()) | |
| 462 m_webFrame->client()->didChangeThemeColor(); | |
| 463 } | |
| 464 | |
| 465 static bool allowCreatingBackgroundTabs() { | |
| 466 const WebInputEvent* inputEvent = WebViewImpl::currentInputEvent(); | |
| 467 if (!inputEvent || (inputEvent->type() != WebInputEvent::MouseUp && | |
| 468 (inputEvent->type() != WebInputEvent::RawKeyDown && | |
| 469 inputEvent->type() != WebInputEvent::KeyDown) && | |
| 470 inputEvent->type() != WebInputEvent::GestureTap)) | |
| 471 return false; | |
| 472 | |
| 473 unsigned short buttonNumber; | |
| 474 if (WebInputEvent::isMouseEventType(inputEvent->type())) { | |
| 475 const WebMouseEvent* mouseEvent = | |
| 476 static_cast<const WebMouseEvent*>(inputEvent); | |
| 477 | |
| 478 switch (mouseEvent->button) { | |
| 479 case WebMouseEvent::Button::Left: | |
| 480 buttonNumber = 0; | |
| 481 break; | |
| 482 case WebMouseEvent::Button::Middle: | |
| 483 buttonNumber = 1; | |
| 484 break; | |
| 485 case WebMouseEvent::Button::Right: | |
| 486 buttonNumber = 2; | |
| 487 break; | |
| 488 default: | |
| 489 return false; | |
| 490 } | |
| 491 } else { | |
| 492 // The click is simulated when triggering the keypress event. | |
| 493 buttonNumber = 0; | |
| 494 } | |
| 495 bool ctrl = inputEvent->modifiers() & WebMouseEvent::ControlKey; | |
| 496 bool shift = inputEvent->modifiers() & WebMouseEvent::ShiftKey; | |
| 497 bool alt = inputEvent->modifiers() & WebMouseEvent::AltKey; | |
| 498 bool meta = inputEvent->modifiers() & WebMouseEvent::MetaKey; | |
| 499 | |
| 500 NavigationPolicy userPolicy; | |
| 501 if (!navigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, | |
| 502 &userPolicy)) | |
| 503 return false; | |
| 504 return userPolicy == NavigationPolicyNewBackgroundTab; | |
| 505 } | |
| 506 | |
| 507 NavigationPolicy FrameLoaderClientImpl::decidePolicyForNavigation( | |
| 508 const ResourceRequest& request, | |
| 509 DocumentLoader* loader, | |
| 510 NavigationType type, | |
| 511 NavigationPolicy policy, | |
| 512 bool replacesCurrentHistoryItem, | |
| 513 bool isClientRedirect, | |
| 514 HTMLFormElement* form) { | |
| 515 if (!m_webFrame->client()) | |
| 516 return NavigationPolicyIgnore; | |
| 517 | |
| 518 if (policy == NavigationPolicyNewBackgroundTab && | |
| 519 !allowCreatingBackgroundTabs() && | |
| 520 !UIEventWithKeyState::newTabModifierSetFromIsolatedWorld()) | |
| 521 policy = NavigationPolicyNewForegroundTab; | |
| 522 | |
| 523 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(loader); | |
| 524 | |
| 525 // Newly created child frames may need to be navigated to a history item | |
| 526 // during a back/forward navigation. This will only happen when the parent | |
| 527 // is a LocalFrame doing a back/forward navigation that has not completed. | |
| 528 // (If the load has completed and the parent later adds a frame with script, | |
| 529 // we do not want to use a history item for it.) | |
| 530 bool isHistoryNavigationInNewChildFrame = | |
| 531 m_webFrame->parent() && m_webFrame->parent()->isWebLocalFrame() && | |
| 532 isBackForwardLoadType(toWebLocalFrameImpl(m_webFrame->parent()) | |
| 533 ->frame() | |
| 534 ->loader() | |
| 535 .documentLoader() | |
| 536 ->loadType()) && | |
| 537 !toWebLocalFrameImpl(m_webFrame->parent()) | |
| 538 ->frame() | |
| 539 ->document() | |
| 540 ->loadEventFinished(); | |
| 541 | |
| 542 WrappedResourceRequest wrappedResourceRequest(request); | |
| 543 WebFrameClient::NavigationPolicyInfo navigationInfo(wrappedResourceRequest); | |
| 544 navigationInfo.navigationType = static_cast<WebNavigationType>(type); | |
| 545 navigationInfo.defaultPolicy = static_cast<WebNavigationPolicy>(policy); | |
| 546 navigationInfo.extraData = ds ? ds->getExtraData() : nullptr; | |
| 547 navigationInfo.replacesCurrentHistoryItem = replacesCurrentHistoryItem; | |
| 548 navigationInfo.isHistoryNavigationInNewChildFrame = | |
| 549 isHistoryNavigationInNewChildFrame; | |
| 550 navigationInfo.isClientRedirect = isClientRedirect; | |
| 551 // Caching could be disabled for requests initiated by DevTools. | |
| 552 // TODO(ananta) | |
| 553 // We should extract the network cache state into a global component which | |
| 554 // can be queried here and wherever necessary. | |
| 555 navigationInfo.isCacheDisabled = | |
| 556 devToolsAgent() ? devToolsAgent()->cacheDisabled() : false; | |
| 557 if (form) | |
| 558 navigationInfo.form = WebFormElement(form); | |
| 559 | |
| 560 WebNavigationPolicy webPolicy = | |
| 561 m_webFrame->client()->decidePolicyForNavigation(navigationInfo); | |
| 562 return static_cast<NavigationPolicy>(webPolicy); | |
| 563 } | |
| 564 | |
| 565 void FrameLoaderClientImpl::dispatchWillSendSubmitEvent(HTMLFormElement* form) { | |
| 566 if (m_webFrame->client()) | |
| 567 m_webFrame->client()->willSendSubmitEvent(WebFormElement(form)); | |
| 568 } | |
| 569 | |
| 570 void FrameLoaderClientImpl::dispatchWillSubmitForm(HTMLFormElement* form) { | |
| 571 if (m_webFrame->client()) | |
| 572 m_webFrame->client()->willSubmitForm(WebFormElement(form)); | |
| 573 } | |
| 574 | |
| 575 void FrameLoaderClientImpl::didStartLoading(LoadStartType loadStartType) { | |
| 576 if (m_webFrame->client()) | |
| 577 m_webFrame->client()->didStartLoading(loadStartType == | |
| 578 NavigationToDifferentDocument); | |
| 579 } | |
| 580 | |
| 581 void FrameLoaderClientImpl::progressEstimateChanged(double progressEstimate) { | |
| 582 if (m_webFrame->client()) | |
| 583 m_webFrame->client()->didChangeLoadProgress(progressEstimate); | |
| 584 } | |
| 585 | |
| 586 void FrameLoaderClientImpl::didStopLoading() { | |
| 587 if (m_webFrame->client()) | |
| 588 m_webFrame->client()->didStopLoading(); | |
| 589 } | |
| 590 | |
| 591 void FrameLoaderClientImpl::loadURLExternally(const ResourceRequest& request, | |
| 592 NavigationPolicy policy, | |
| 593 const String& suggestedName, | |
| 594 bool shouldReplaceCurrentEntry) { | |
| 595 if (!m_webFrame->client()) | |
| 596 return; | |
| 597 DCHECK(m_webFrame->frame()->document()); | |
| 598 Fullscreen::fullyExitFullscreen(*m_webFrame->frame()->document()); | |
| 599 m_webFrame->client()->loadURLExternally( | |
| 600 WrappedResourceRequest(request), static_cast<WebNavigationPolicy>(policy), | |
| 601 suggestedName, shouldReplaceCurrentEntry); | |
| 602 } | |
| 603 | |
| 604 void FrameLoaderClientImpl::loadErrorPage(int reason) { | |
| 605 if (m_webFrame->client()) | |
| 606 m_webFrame->client()->loadErrorPage(reason); | |
| 607 } | |
| 608 | |
| 609 bool FrameLoaderClientImpl::navigateBackForward(int offset) const { | |
| 610 WebViewImpl* webview = m_webFrame->viewImpl(); | |
| 611 if (!webview->client()) | |
| 612 return false; | |
| 613 | |
| 614 DCHECK(offset); | |
| 615 if (offset > webview->client()->historyForwardListCount()) | |
| 616 return false; | |
| 617 if (offset < -webview->client()->historyBackListCount()) | |
| 618 return false; | |
| 619 webview->client()->navigateBackForwardSoon(offset); | |
| 620 return true; | |
| 621 } | |
| 622 | |
| 623 void FrameLoaderClientImpl::didAccessInitialDocument() { | |
| 624 if (m_webFrame->client()) | |
| 625 m_webFrame->client()->didAccessInitialDocument(); | |
| 626 } | |
| 627 | |
| 628 void FrameLoaderClientImpl::didDisplayInsecureContent() { | |
| 629 if (m_webFrame->client()) | |
| 630 m_webFrame->client()->didDisplayInsecureContent(); | |
| 631 } | |
| 632 | |
| 633 void FrameLoaderClientImpl::didRunInsecureContent(SecurityOrigin* origin, | |
| 634 const KURL& insecureURL) { | |
| 635 if (m_webFrame->client()) | |
| 636 m_webFrame->client()->didRunInsecureContent(WebSecurityOrigin(origin), | |
| 637 insecureURL); | |
| 638 } | |
| 639 | |
| 640 void FrameLoaderClientImpl::didDetectXSS(const KURL& insecureURL, | |
| 641 bool didBlockEntirePage) { | |
| 642 if (m_webFrame->client()) | |
| 643 m_webFrame->client()->didDetectXSS(insecureURL, didBlockEntirePage); | |
| 644 } | |
| 645 | |
| 646 void FrameLoaderClientImpl::didDispatchPingLoader(const KURL& url) { | |
| 647 if (m_webFrame->client()) | |
| 648 m_webFrame->client()->didDispatchPingLoader(url); | |
| 649 } | |
| 650 | |
| 651 void FrameLoaderClientImpl::didDisplayContentWithCertificateErrors( | |
| 652 const KURL& url) { | |
| 653 if (m_webFrame->client()) | |
| 654 m_webFrame->client()->didDisplayContentWithCertificateErrors(url); | |
| 655 } | |
| 656 | |
| 657 void FrameLoaderClientImpl::didRunContentWithCertificateErrors( | |
| 658 const KURL& url) { | |
| 659 if (m_webFrame->client()) | |
| 660 m_webFrame->client()->didRunContentWithCertificateErrors(url); | |
| 661 } | |
| 662 | |
| 663 void FrameLoaderClientImpl::didChangePerformanceTiming() { | |
| 664 if (m_webFrame->client()) | |
| 665 m_webFrame->client()->didChangePerformanceTiming(); | |
| 666 } | |
| 667 | |
| 668 void FrameLoaderClientImpl::didObserveLoadingBehavior( | |
| 669 WebLoadingBehaviorFlag behavior) { | |
| 670 if (m_webFrame->client()) | |
| 671 m_webFrame->client()->didObserveLoadingBehavior(behavior); | |
| 672 } | |
| 673 | |
| 674 void FrameLoaderClientImpl::selectorMatchChanged( | |
| 675 const Vector<String>& addedSelectors, | |
| 676 const Vector<String>& removedSelectors) { | |
| 677 if (WebFrameClient* client = m_webFrame->client()) | |
| 678 client->didMatchCSS(m_webFrame, WebVector<WebString>(addedSelectors), | |
| 679 WebVector<WebString>(removedSelectors)); | |
| 680 } | |
| 681 | |
| 682 DocumentLoader* FrameLoaderClientImpl::createDocumentLoader( | |
| 683 LocalFrame* frame, | |
| 684 const ResourceRequest& request, | |
| 685 const SubstituteData& data, | |
| 686 ClientRedirectPolicy clientRedirectPolicy) { | |
| 687 DCHECK(frame); | |
| 688 | |
| 689 WebDataSourceImpl* ds = | |
| 690 WebDataSourceImpl::create(frame, request, data, clientRedirectPolicy); | |
| 691 if (m_webFrame->client()) | |
| 692 m_webFrame->client()->didCreateDataSource(m_webFrame, ds); | |
| 693 return ds; | |
| 694 } | |
| 695 | |
| 696 String FrameLoaderClientImpl::userAgent() { | |
| 697 WebString override = | |
| 698 m_webFrame->client() ? m_webFrame->client()->userAgentOverride() : ""; | |
| 699 if (!override.isEmpty()) | |
| 700 return override; | |
| 701 | |
| 702 if (m_userAgent.isEmpty()) | |
| 703 m_userAgent = Platform::current()->userAgent(); | |
| 704 return m_userAgent; | |
| 705 } | |
| 706 | |
| 707 String FrameLoaderClientImpl::doNotTrackValue() { | |
| 708 WebString doNotTrack = m_webFrame->client()->doNotTrackValue(); | |
| 709 if (!doNotTrack.isEmpty()) | |
| 710 return doNotTrack; | |
| 711 return String(); | |
| 712 } | |
| 713 | |
| 714 // Called when the FrameLoader goes into a state in which a new page load | |
| 715 // will occur. | |
| 716 void FrameLoaderClientImpl::transitionToCommittedForNewPage() { | |
| 717 m_webFrame->createFrameView(); | |
| 718 } | |
| 719 | |
| 720 LocalFrame* FrameLoaderClientImpl::createFrame( | |
| 721 const FrameLoadRequest& request, | |
| 722 const AtomicString& name, | |
| 723 HTMLFrameOwnerElement* ownerElement) { | |
| 724 return m_webFrame->createChildFrame(request, name, ownerElement); | |
| 725 } | |
| 726 | |
| 727 bool FrameLoaderClientImpl::canCreatePluginWithoutRenderer( | |
| 728 const String& mimeType) const { | |
| 729 if (!m_webFrame->client()) | |
| 730 return false; | |
| 731 | |
| 732 return m_webFrame->client()->canCreatePluginWithoutRenderer(mimeType); | |
| 733 } | |
| 734 | |
| 735 Widget* FrameLoaderClientImpl::createPlugin(HTMLPlugInElement* element, | |
| 736 const KURL& url, | |
| 737 const Vector<String>& paramNames, | |
| 738 const Vector<String>& paramValues, | |
| 739 const String& mimeType, | |
| 740 bool loadManually, | |
| 741 DetachedPluginPolicy policy) { | |
| 742 if (!m_webFrame->client()) | |
| 743 return nullptr; | |
| 744 | |
| 745 WebPluginParams params; | |
| 746 params.url = url; | |
| 747 params.mimeType = mimeType; | |
| 748 params.attributeNames = paramNames; | |
| 749 params.attributeValues = paramValues; | |
| 750 params.loadManually = loadManually; | |
| 751 | |
| 752 WebPlugin* webPlugin = m_webFrame->client()->createPlugin(m_webFrame, params); | |
| 753 if (!webPlugin) | |
| 754 return nullptr; | |
| 755 | |
| 756 // The container takes ownership of the WebPlugin. | |
| 757 WebPluginContainerImpl* container = | |
| 758 WebPluginContainerImpl::create(element, webPlugin); | |
| 759 | |
| 760 if (!webPlugin->initialize(container)) | |
| 761 return nullptr; | |
| 762 | |
| 763 if (policy != AllowDetachedPlugin && !element->layoutObject()) | |
| 764 return nullptr; | |
| 765 | |
| 766 return container; | |
| 767 } | |
| 768 | |
| 769 std::unique_ptr<WebMediaPlayer> FrameLoaderClientImpl::createWebMediaPlayer( | |
| 770 HTMLMediaElement& htmlMediaElement, | |
| 771 const WebMediaPlayerSource& source, | |
| 772 WebMediaPlayerClient* client) { | |
| 773 WebLocalFrameImpl* webFrame = | |
| 774 WebLocalFrameImpl::fromFrame(htmlMediaElement.document().frame()); | |
| 775 | |
| 776 if (!webFrame || !webFrame->client()) | |
| 777 return nullptr; | |
| 778 | |
| 779 HTMLMediaElementEncryptedMedia& encryptedMedia = | |
| 780 HTMLMediaElementEncryptedMedia::from(htmlMediaElement); | |
| 781 WebString sinkId(HTMLMediaElementAudioOutputDevice::sinkId(htmlMediaElement)); | |
| 782 return WTF::wrapUnique(webFrame->client()->createMediaPlayer( | |
| 783 source, client, &encryptedMedia, encryptedMedia.contentDecryptionModule(), | |
| 784 sinkId)); | |
| 785 } | |
| 786 | |
| 787 WebRemotePlaybackClient* FrameLoaderClientImpl::createWebRemotePlaybackClient( | |
| 788 HTMLMediaElement& htmlMediaElement) { | |
| 789 return HTMLMediaElementRemotePlayback::remote(htmlMediaElement); | |
| 790 } | |
| 791 | |
| 792 ObjectContentType FrameLoaderClientImpl::getObjectContentType( | |
| 793 const KURL& url, | |
| 794 const String& explicitMimeType, | |
| 795 bool shouldPreferPlugInsForImages) { | |
| 796 // This code is based on Apple's implementation from | |
| 797 // WebCoreSupport/WebFrameBridge.mm. | |
| 798 | |
| 799 String mimeType = explicitMimeType; | |
| 800 if (mimeType.isEmpty()) { | |
| 801 // Try to guess the MIME type based off the extension. | |
| 802 String filename = url.lastPathComponent(); | |
| 803 int extensionPos = filename.reverseFind('.'); | |
| 804 if (extensionPos >= 0) { | |
| 805 String extension = filename.substring(extensionPos + 1); | |
| 806 mimeType = MIMETypeRegistry::getWellKnownMIMETypeForExtension(extension); | |
| 807 } | |
| 808 | |
| 809 if (mimeType.isEmpty()) | |
| 810 return ObjectContentFrame; | |
| 811 } | |
| 812 | |
| 813 // If Chrome is started with the --disable-plugins switch, pluginData is 0. | |
| 814 PluginData* pluginData = m_webFrame->frame()->pluginData(); | |
| 815 bool plugInSupportsMIMEType = | |
| 816 pluginData && pluginData->supportsMimeType(mimeType); | |
| 817 | |
| 818 if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) | |
| 819 return shouldPreferPlugInsForImages && plugInSupportsMIMEType | |
| 820 ? ObjectContentNetscapePlugin | |
| 821 : ObjectContentImage; | |
| 822 | |
| 823 if (plugInSupportsMIMEType) | |
| 824 return ObjectContentNetscapePlugin; | |
| 825 | |
| 826 if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) | |
| 827 return ObjectContentFrame; | |
| 828 | |
| 829 return ObjectContentNone; | |
| 830 } | |
| 831 | |
| 832 WebCookieJar* FrameLoaderClientImpl::cookieJar() const { | |
| 833 if (!m_webFrame->client()) | |
| 834 return 0; | |
| 835 return m_webFrame->client()->cookieJar(); | |
| 836 } | |
| 837 | |
| 838 void FrameLoaderClientImpl::frameFocused() const { | |
| 839 if (m_webFrame->client()) | |
| 840 m_webFrame->client()->frameFocused(); | |
| 841 } | |
| 842 | |
| 843 void FrameLoaderClientImpl::didChangeName(const String& name, | |
| 844 const String& uniqueName) { | |
| 845 if (!m_webFrame->client()) | |
| 846 return; | |
| 847 m_webFrame->client()->didChangeName(name, uniqueName); | |
| 848 } | |
| 849 | |
| 850 void FrameLoaderClientImpl::didEnforceInsecureRequestPolicy( | |
| 851 WebInsecureRequestPolicy policy) { | |
| 852 if (!m_webFrame->client()) | |
| 853 return; | |
| 854 m_webFrame->client()->didEnforceInsecureRequestPolicy(policy); | |
| 855 } | |
| 856 | |
| 857 void FrameLoaderClientImpl::didUpdateToUniqueOrigin() { | |
| 858 if (!m_webFrame->client()) | |
| 859 return; | |
| 860 DCHECK(m_webFrame->getSecurityOrigin().isUnique()); | |
| 861 m_webFrame->client()->didUpdateToUniqueOrigin( | |
| 862 m_webFrame->getSecurityOrigin().isPotentiallyTrustworthy()); | |
| 863 } | |
| 864 | |
| 865 void FrameLoaderClientImpl::didChangeSandboxFlags(Frame* childFrame, | |
| 866 SandboxFlags flags) { | |
| 867 if (!m_webFrame->client()) | |
| 868 return; | |
| 869 m_webFrame->client()->didChangeSandboxFlags( | |
| 870 WebFrame::fromFrame(childFrame), static_cast<WebSandboxFlags>(flags)); | |
| 871 } | |
| 872 | |
| 873 void FrameLoaderClientImpl::didSetFeaturePolicyHeader( | |
| 874 const WebParsedFeaturePolicyHeader& parsedHeader) { | |
| 875 if (m_webFrame->client()) | |
| 876 m_webFrame->client()->didSetFeaturePolicyHeader(parsedHeader); | |
| 877 } | |
| 878 | |
| 879 void FrameLoaderClientImpl::didAddContentSecurityPolicy( | |
| 880 const String& headerValue, | |
| 881 ContentSecurityPolicyHeaderType type, | |
| 882 ContentSecurityPolicyHeaderSource source, | |
| 883 const std::vector<WebContentSecurityPolicyPolicy>& policies) { | |
| 884 if (m_webFrame->client()) { | |
| 885 m_webFrame->client()->didAddContentSecurityPolicy( | |
| 886 headerValue, static_cast<WebContentSecurityPolicyType>(type), | |
| 887 static_cast<WebContentSecurityPolicySource>(source), policies); | |
| 888 } | |
| 889 } | |
| 890 | |
| 891 void FrameLoaderClientImpl::didChangeFrameOwnerProperties( | |
| 892 HTMLFrameElementBase* frameElement) { | |
| 893 if (!m_webFrame->client()) | |
| 894 return; | |
| 895 | |
| 896 m_webFrame->client()->didChangeFrameOwnerProperties( | |
| 897 WebFrame::fromFrame(frameElement->contentFrame()), | |
| 898 WebFrameOwnerProperties( | |
| 899 frameElement->browsingContextContainerName(), | |
| 900 frameElement->scrollingMode(), frameElement->marginWidth(), | |
| 901 frameElement->marginHeight(), frameElement->allowFullscreen(), | |
| 902 frameElement->allowPaymentRequest(), frameElement->csp(), | |
| 903 frameElement->delegatedPermissions(), | |
| 904 frameElement->allowedFeatures())); | |
| 905 } | |
| 906 | |
| 907 void FrameLoaderClientImpl::dispatchWillStartUsingPeerConnectionHandler( | |
| 908 WebRTCPeerConnectionHandler* handler) { | |
| 909 m_webFrame->client()->willStartUsingPeerConnectionHandler(handler); | |
| 910 } | |
| 911 | |
| 912 bool FrameLoaderClientImpl::allowWebGL(bool enabledPerSettings) { | |
| 913 if (m_webFrame->client()) | |
| 914 return m_webFrame->client()->allowWebGL(enabledPerSettings); | |
| 915 | |
| 916 return enabledPerSettings; | |
| 917 } | |
| 918 | |
| 919 void FrameLoaderClientImpl::dispatchWillInsertBody() { | |
| 920 if (m_webFrame->client()) | |
| 921 m_webFrame->client()->willInsertBody(m_webFrame); | |
| 922 } | |
| 923 | |
| 924 std::unique_ptr<WebServiceWorkerProvider> | |
| 925 FrameLoaderClientImpl::createServiceWorkerProvider() { | |
| 926 if (!m_webFrame->client()) | |
| 927 return nullptr; | |
| 928 return WTF::wrapUnique(m_webFrame->client()->createServiceWorkerProvider()); | |
| 929 } | |
| 930 | |
| 931 bool FrameLoaderClientImpl::isControlledByServiceWorker( | |
| 932 DocumentLoader& loader) { | |
| 933 return m_webFrame->client() && | |
| 934 m_webFrame->client()->isControlledByServiceWorker( | |
| 935 *WebDataSourceImpl::fromDocumentLoader(&loader)); | |
| 936 } | |
| 937 | |
| 938 int64_t FrameLoaderClientImpl::serviceWorkerID(DocumentLoader& loader) { | |
| 939 if (!m_webFrame->client()) | |
| 940 return -1; | |
| 941 return m_webFrame->client()->serviceWorkerID( | |
| 942 *WebDataSourceImpl::fromDocumentLoader(&loader)); | |
| 943 } | |
| 944 | |
| 945 SharedWorkerRepositoryClient* | |
| 946 FrameLoaderClientImpl::sharedWorkerRepositoryClient() { | |
| 947 return m_webFrame->sharedWorkerRepositoryClient(); | |
| 948 } | |
| 949 | |
| 950 std::unique_ptr<WebApplicationCacheHost> | |
| 951 FrameLoaderClientImpl::createApplicationCacheHost( | |
| 952 WebApplicationCacheHostClient* client) { | |
| 953 if (!m_webFrame->client()) | |
| 954 return nullptr; | |
| 955 return WTF::wrapUnique( | |
| 956 m_webFrame->client()->createApplicationCacheHost(client)); | |
| 957 } | |
| 958 | |
| 959 void FrameLoaderClientImpl::dispatchDidChangeManifest() { | |
| 960 if (m_webFrame->client()) | |
| 961 m_webFrame->client()->didChangeManifest(); | |
| 962 } | |
| 963 | |
| 964 unsigned FrameLoaderClientImpl::backForwardLength() { | |
| 965 WebViewImpl* webview = m_webFrame->viewImpl(); | |
| 966 if (!webview || !webview->client()) | |
| 967 return 0; | |
| 968 return webview->client()->historyBackListCount() + 1 + | |
| 969 webview->client()->historyForwardListCount(); | |
| 970 } | |
| 971 | |
| 972 void FrameLoaderClientImpl::suddenTerminationDisablerChanged( | |
| 973 bool present, | |
| 974 SuddenTerminationDisablerType type) { | |
| 975 if (m_webFrame->client()) { | |
| 976 m_webFrame->client()->suddenTerminationDisablerChanged( | |
| 977 present, | |
| 978 static_cast<WebFrameClient::SuddenTerminationDisablerType>(type)); | |
| 979 } | |
| 980 } | |
| 981 | |
| 982 BlameContext* FrameLoaderClientImpl::frameBlameContext() { | |
| 983 if (!m_webFrame->client()) | |
| 984 return nullptr; | |
| 985 return m_webFrame->client()->frameBlameContext(); | |
| 986 } | |
| 987 | |
| 988 LinkResource* FrameLoaderClientImpl::createServiceWorkerLinkResource( | |
| 989 HTMLLinkElement* owner) { | |
| 990 return ServiceWorkerLinkResource::create(owner); | |
| 991 } | |
| 992 | |
| 993 WebEffectiveConnectionType FrameLoaderClientImpl::getEffectiveConnectionType() { | |
| 994 if (m_webFrame->client()) | |
| 995 return m_webFrame->client()->getEffectiveConnectionType(); | |
| 996 return WebEffectiveConnectionType::TypeUnknown; | |
| 997 } | |
| 998 | |
| 999 WebDevToolsAgentImpl* FrameLoaderClientImpl::devToolsAgent() { | |
| 1000 return WebLocalFrameImpl::fromFrame(m_webFrame->frame()->localFrameRoot()) | |
| 1001 ->devToolsAgentImpl(); | |
| 1002 } | |
| 1003 | |
| 1004 KURL FrameLoaderClientImpl::overrideFlashEmbedWithHTML(const KURL& url) { | |
| 1005 return m_webFrame->client()->overrideFlashEmbedWithHTML(WebURL(url)); | |
| 1006 } | |
| 1007 | |
| 1008 void FrameLoaderClientImpl::setHasReceivedUserGesture() { | |
| 1009 if (m_webFrame->client()) | |
| 1010 m_webFrame->client()->setHasReceivedUserGesture(); | |
| 1011 } | |
| 1012 | |
| 1013 } // namespace blink | |
| OLD | NEW |