summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-21 18:45:33 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-21 18:45:33 +0000
commitd9ffd55d3a85e3e543bd97f89ff46fd7dc228455 (patch)
treed70e93b879eef49a5dbbeccb2001ea5564bfebcb /chrome_frame
parentdcc7b326b585c5de60590cd808aed91342311d05 (diff)
downloadchromium_src-d9ffd55d3a85e3e543bd97f89ff46fd7dc228455.zip
chromium_src-d9ffd55d3a85e3e543bd97f89ff46fd7dc228455.tar.gz
chromium_src-d9ffd55d3a85e3e543bd97f89ff46fd7dc228455.tar.bz2
Refreshing pages in ChromeFrame would basically always fetch the pages from the cache. We need
to emulate Chrome and MSHTML where in the cache is resynchronized, i.e. new content is fetched from the server if it has been modified. To achieve this we now pass the load flags from Chrome when we initiate a HTTP request and basically or in the BINDF_RESYNCHRONIZE and BINDF_GETNEWESTVERSION flags based on the value of the load flags. Fixes bug http://code.google.com/p/chromium/issues/detail?id=41508 Test=Covered by new ChromeFrame test. Review URL: http://codereview.chromium.org/4000001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/npapi_url_request.cc3
-rw-r--r--chrome_frame/plugin_url_request.cc6
-rw-r--r--chrome_frame/plugin_url_request.h3
-rw-r--r--chrome_frame/test/navigation_test.cc41
-rw-r--r--chrome_frame/test/url_request_test.cc12
-rw-r--r--chrome_frame/urlmon_url_request.cc13
6 files changed, 69 insertions, 9 deletions
diff --git a/chrome_frame/npapi_url_request.cc b/chrome_frame/npapi_url_request.cc
index ad2416c..878f0ed6 100644
--- a/chrome_frame/npapi_url_request.cc
+++ b/chrome_frame/npapi_url_request.cc
@@ -223,7 +223,8 @@ void NPAPIUrlRequestManager::StartRequest(int request_id,
request_info.extra_request_headers,
request_info.upload_data,
static_cast<ResourceType::Type>(request_info.resource_type),
- enable_frame_busting_)) {
+ enable_frame_busting_,
+ request_info.load_flags)) {
DCHECK(request_map_.find(request_id) == request_map_.end());
if (new_request->Start()) {
request_map_[request_id] = new_request;
diff --git a/chrome_frame/plugin_url_request.cc b/chrome_frame/plugin_url_request.cc
index ad223a9..c4bf932 100644
--- a/chrome_frame/plugin_url_request.cc
+++ b/chrome_frame/plugin_url_request.cc
@@ -12,7 +12,8 @@ PluginUrlRequest::PluginUrlRequest()
remote_request_id_(-1),
post_data_len_(0),
enable_frame_busting_(false),
- resource_type_(ResourceType::MAIN_FRAME) {
+ resource_type_(ResourceType::MAIN_FRAME),
+ load_flags_(0) {
}
PluginUrlRequest::~PluginUrlRequest() {
@@ -22,7 +23,7 @@ bool PluginUrlRequest::Initialize(PluginUrlRequestDelegate* delegate,
int remote_request_id, const std::string& url, const std::string& method,
const std::string& referrer, const std::string& extra_headers,
net::UploadData* upload_data, ResourceType::Type resource_type,
- bool enable_frame_busting) {
+ bool enable_frame_busting, int load_flags) {
delegate_ = delegate;
remote_request_id_ = remote_request_id;
url_ = url;
@@ -30,6 +31,7 @@ bool PluginUrlRequest::Initialize(PluginUrlRequestDelegate* delegate,
referrer_ = referrer;
extra_headers_ = extra_headers;
resource_type_ = resource_type;
+ load_flags_ = load_flags;
if (upload_data) {
// We store a pointer to UrlmonUploadDataStream and not net::UploadData
diff --git a/chrome_frame/plugin_url_request.h b/chrome_frame/plugin_url_request.h
index 0026ade..2d25b94 100644
--- a/chrome_frame/plugin_url_request.h
+++ b/chrome_frame/plugin_url_request.h
@@ -123,7 +123,7 @@ class PluginUrlRequest {
int remote_request_id, const std::string& url, const std::string& method,
const std::string& referrer, const std::string& extra_headers,
net::UploadData* upload_data, ResourceType::Type resource_type,
- bool enable_frame_busting_);
+ bool enable_frame_busting_, int load_flags);
// Accessors.
int id() const {
@@ -180,6 +180,7 @@ class PluginUrlRequest {
std::string referrer_;
std::string extra_headers_;
ResourceType::Type resource_type_;
+ int load_flags_;
ScopedComPtr<IStream> upload_data_;
};
diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc
index f11f3e6..2cedf3e 100644
--- a/chrome_frame/test/navigation_test.cc
+++ b/chrome_frame/test/navigation_test.cc
@@ -899,4 +899,45 @@ TEST_F(HttpHeaderTest, ImageSvgXml) {
HeaderTestWithData("image/svg+xml", kImageSvg);
}
+// Tests refreshing causes a page load.
+TEST_P(FullTabNavigationTest, RefreshContents) {
+ bool in_cf = GetParam().invokes_cf();
+ if (!in_cf) {
+ LOG(INFO) << "Disabled for this configuration";
+ return;
+ }
+
+ std::wstring src_url = server_mock_.Resolve(L"/refresh_src.html");
+
+ EXPECT_CALL(server_mock_, Get(_, StrEq(L"/refresh_src.html"), _))
+ .Times(2)
+ .WillRepeatedly(
+ SendFast(
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Type: text/html\r\n",
+ "<html>"
+ "<head><meta http-equiv=\"x-ua-compatible\" content=\"chrome=1\""
+ "/></head>"
+ "<body>Hi there. Got new content?"
+ "</body></html>"));
+
+ EXPECT_CALL(ie_mock_, OnFileDownload(_, _)).Times(testing::AnyNumber());
+
+ EXPECT_CALL(ie_mock_,
+ OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
+ StrEq(src_url)),
+ _, _, _, _, _));
+ EXPECT_CALL(ie_mock_,
+ OnNavigateComplete2(_, testing::Field(&VARIANT::bstrVal,
+ StrEq(src_url))))
+ .WillOnce(testing::DoAll(
+ DelayRefresh(&ie_mock_, &loop_, 2000),
+ DelayCloseBrowserMock(&loop_, 4000, &ie_mock_)));
+
+ EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(src_url)))
+ .Times(2);
+
+ LaunchIEAndNavigate(src_url);
+}
+
} // namespace chrome_frame_test
diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc
index 699ea61..127bec2 100644
--- a/chrome_frame/test/url_request_test.cc
+++ b/chrome_frame/test/url_request_test.cc
@@ -84,7 +84,8 @@ TEST(UrlmonUrlRequestTest, Simple1) {
"", // extra request
NULL, // upload data
ResourceType::MAIN_FRAME, // resource type
- true); // frame busting
+ true,
+ 0); // frame busting
testing::InSequence s;
EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
@@ -131,7 +132,8 @@ TEST(UrlmonUrlRequestTest, Head) {
"", // extra request
NULL, // upload data
ResourceType::MAIN_FRAME, // resource type
- true); // frame busting
+ true,
+ 0); // frame busting
testing::InSequence s;
EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
@@ -172,7 +174,8 @@ TEST(UrlmonUrlRequestTest, UnreachableUrl) {
"", // extra request
NULL, // upload data
ResourceType::MAIN_FRAME, // resource type
- true); // frame busting
+ true,
+ 0); // frame busting
// Expect headers
EXPECT_CALL(mock, OnResponseStarted(1, testing::_,
@@ -209,7 +212,8 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) {
"", // extra request
NULL, // upload data
ResourceType::MAIN_FRAME, // resource type
- true); // frame busting
+ true,
+ 0); // frame busting
// Expect headers
EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc
index 105e3bd..77cdc87 100644
--- a/chrome_frame/urlmon_url_request.cc
+++ b/chrome_frame/urlmon_url_request.cc
@@ -20,6 +20,7 @@
#include "chrome_frame/urlmon_url_request_private.h"
#include "chrome_frame/urlmon_upload_data_stream.h"
#include "chrome_frame/utils.h"
+#include "net/base/load_flags.h"
#include "net/http/http_util.h"
#include "net/http/http_response_headers.h"
@@ -426,6 +427,15 @@ STDMETHODIMP UrlmonUrlRequest::GetBindInfo(DWORD* bind_flags,
*bind_flags = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
+ // TODO(ananta)
+ // Look into whether the other load flags need to be supported in chrome
+ // frame.
+ if (load_flags_ & net::LOAD_VALIDATE_CACHE)
+ *bind_flags |= BINDF_RESYNCHRONIZE;
+
+ if (load_flags_ & net::LOAD_BYPASS_CACHE)
+ *bind_flags |= BINDF_GETNEWESTVERSION;
+
bool upload_data = false;
if (LowerCaseEqualsASCII(method(), "get")) {
@@ -990,7 +1000,8 @@ void UrlmonUrlRequestManager::StartRequest(int request_id,
request_info.extra_request_headers,
request_info.upload_data,
static_cast<ResourceType::Type>(request_info.resource_type),
- enable_frame_busting_);
+ enable_frame_busting_,
+ request_info.load_flags);
new_request->set_parent_window(notification_window_);
new_request->set_privileged_mode(privileged_mode_);