180e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu/* 280e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * Copyright 2009, The Android Open Source Project 380e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * 480e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * Redistribution and use in source and binary forms, with or without 580e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * modification, are permitted provided that the following conditions 680e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * are met: 780e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * * Redistributions of source code must retain the above copyright 880e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * notice, this list of conditions and the following disclaimer. 980e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * * Redistributions in binary form must reproduce the above copyright 1080e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * notice, this list of conditions and the following disclaimer in the 1180e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * documentation and/or other materials provided with the distribution. 1280e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * 1380e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 1480e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1580e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1680e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 1780e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1880e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1980e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2080e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 2180e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2280e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2380e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2480e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu */ 2580e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu 2680e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu#include <config.h> 2780e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu#include <ResourceLoaderAndroid.h> 2880e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu 29b84030fc8163cde1f8f055973ef63d3e1670bf52Steve Block#include "Frame.h" 3080e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu#include "FrameLoaderClientAndroid.h" 3180e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu#include "WebCoreFrameBridge.h" 328f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block#include "WebUrlLoader.h" 33b84030fc8163cde1f8f055973ef63d3e1670bf52Steve Block#include "WebViewCore.h" 3480e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu 3580e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescuusing namespace android; 3680e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu 3780e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescunamespace WebCore { 3880e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu 3980e68b43c3da64848db8edc7d8e8fe095888e42eAndrei PopescuPassRefPtr<ResourceLoaderAndroid> ResourceLoaderAndroid::start( 40b84030fc8163cde1f8f055973ef63d3e1670bf52Steve Block ResourceHandle* handle, const ResourceRequest& request, FrameLoaderClient* client, bool isMainResource, bool isSync) 4180e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu{ 428f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // Called on main thread 43b84030fc8163cde1f8f055973ef63d3e1670bf52Steve Block FrameLoaderClientAndroid* clientAndroid = static_cast<FrameLoaderClientAndroid*>(client); 44b84030fc8163cde1f8f055973ef63d3e1670bf52Steve Block WebViewCore* webViewCore = WebViewCore::getWebViewCore(clientAndroid->getFrame()->view()); 45990373e4c55ba4f0312b5ab7974388d717d1907cHuahui Wu bool isMainFrame = !(clientAndroid->getFrame()->tree() && clientAndroid->getFrame()->tree()->parent()); 46990373e4c55ba4f0312b5ab7974388d717d1907cHuahui Wu return WebUrlLoader::start(client, handle, request, isMainResource, isMainFrame, isSync, webViewCore->webRequestContext()); 4780e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu} 4880e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu 4980e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescubool ResourceLoaderAndroid::willLoadFromCache(const WebCore::KURL& url, int64_t identifier) 5080e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu{ 518f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // This method is used to determine if a POST request can be repeated from 528f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // cache, but you cannot really know until you actually try to read from the 538f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // cache. Even if we checked now, something else could come along and wipe 548f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // out the cache entry by the time we fetch it. 558f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // 568f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // So, we always say yes here, to prevent the FrameLoader from initiating a 578f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // reload. Then in FrameLoaderClientImpl::dispatchWillSendRequest, we 588f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block // fix-up the cache policy of the request to force a load from the cache. 598f71a88eb32d112e6277f0a0260df04e969d6f8aSteve Block return true; 6080e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu} 6180e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu 6280e68b43c3da64848db8edc7d8e8fe095888e42eAndrei Popescu} 63