summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 23:55:57 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 23:55:57 +0000
commitd88bf0abc08d368fd615a645bd0125ee6ab4f7c2 (patch)
tree1468242a3927c53b9548463b8bcb02fc32d4f6f3 /content/common
parent3962ea98fe59edad2b2c1dcb1b1893304526369b (diff)
downloadchromium_src-d88bf0abc08d368fd615a645bd0125ee6ab4f7c2.zip
chromium_src-d88bf0abc08d368fd615a645bd0125ee6ab4f7c2.tar.gz
chromium_src-d88bf0abc08d368fd615a645bd0125ee6ab4f7c2.tar.bz2
Treat files downloaded from the address bar as "always safe" (including extensions per discussion with asargent and the extensions folks).
This required plumbing the PageTransition::Type from render_view.cc back up through various layers to the download system, as well as adding an extra state qualifier bit on the Type to mark navigations triggered "FROM_ADDRESS_BAR" (since the Type itself sans-qualifier cannot be used to reliably check this). This also fixes an inconsistency in IsDangerousFile() where "auto-open" lowered our safety checks for Dangerous files but not for AllowOnUserGesture files. BUG=87192,92345 TEST=Paste the PDF link from bug 87192 comment 0 into your address bar and hit enter. The file should download without triggering any warning UI in the download shelf. Review URL: http://codereview.chromium.org/7624031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98897 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/page_transition_types.h5
-rw-r--r--content/common/request_extra_data.cc11
-rw-r--r--content/common/request_extra_data.h12
-rw-r--r--content/common/resource_dispatcher.cc4
-rw-r--r--content/common/resource_dispatcher_unittest.cc2
-rw-r--r--content/common/resource_messages.h3
6 files changed, 26 insertions, 11 deletions
diff --git a/content/common/page_transition_types.h b/content/common/page_transition_types.h
index 5295d5e..d0c18d1 100644
--- a/content/common/page_transition_types.h
+++ b/content/common/page_transition_types.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -105,6 +105,9 @@ class PageTransition {
// User used the Forward or Back button to navigate among browsing history.
FORWARD_BACK = 0x01000000,
+ // User used the address bar to trigger this navigation.
+ FROM_ADDRESS_BAR = 0x02000000,
+
// The beginning of a navigation chain.
CHAIN_START = 0x10000000,
diff --git a/content/common/request_extra_data.cc b/content/common/request_extra_data.cc
index 0ce6a8d..690029c 100644
--- a/content/common/request_extra_data.cc
+++ b/content/common/request_extra_data.cc
@@ -4,10 +4,13 @@
#include "content/common/request_extra_data.h"
-RequestExtraData::~RequestExtraData() {}
-
RequestExtraData::RequestExtraData(bool is_main_frame,
- int64 frame_identifier)
+ int64 frame_id,
+ PageTransition::Type transition_type)
: is_main_frame_(is_main_frame),
- frame_identifier_(frame_identifier) {
+ frame_id_(frame_id),
+ transition_type_(transition_type) {
+}
+
+RequestExtraData::~RequestExtraData() {
}
diff --git a/content/common/request_extra_data.h b/content/common/request_extra_data.h
index d41b1a4..9ca3021a 100644
--- a/content/common/request_extra_data.h
+++ b/content/common/request_extra_data.h
@@ -6,22 +6,26 @@
#define CONTENT_COMMON_REQUEST_EXTRA_DATA_H_
#pragma once
+#include "content/common/page_transition_types.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
// The RenderView stores an instance of this class in the "extra data" of each
// ResourceRequest (see RenderView::willSendRequest).
class RequestExtraData : public WebKit::WebURLRequest::ExtraData {
public:
- RequestExtraData(bool is_main_frame, int64 frame_identifier);
+ RequestExtraData(bool is_main_frame,
+ int64 frame_id,
+ PageTransition::Type transition_type);
virtual ~RequestExtraData();
bool is_main_frame() const { return is_main_frame_; }
-
- int64 frame_identifier() const { return frame_identifier_; }
+ int64 frame_id() const { return frame_id_; }
+ PageTransition::Type transition_type() const { return transition_type_; }
private:
bool is_main_frame_;
- int64 frame_identifier_;
+ int64 frame_id_;
+ PageTransition::Type transition_type_;
DISALLOW_COPY_AND_ASSIGN(RequestExtraData);
};
diff --git a/content/common/resource_dispatcher.cc b/content/common/resource_dispatcher.cc
index 5cb6800..d3f5185 100644
--- a/content/common/resource_dispatcher.cc
+++ b/content/common/resource_dispatcher.cc
@@ -98,10 +98,12 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge(
RequestExtraData* extra_data =
static_cast<RequestExtraData*>(request_info.extra_data);
request_.is_main_frame = extra_data->is_main_frame();
- request_.frame_id = extra_data->frame_identifier();
+ request_.frame_id = extra_data->frame_id();
+ request_.transition_type = extra_data->transition_type();
} else {
request_.is_main_frame = false;
request_.frame_id = -1;
+ request_.transition_type = PageTransition::LINK;
}
}
diff --git a/content/common/resource_dispatcher_unittest.cc b/content/common/resource_dispatcher_unittest.cc
index 228633b..81ebb50 100644
--- a/content/common/resource_dispatcher_unittest.cc
+++ b/content/common/resource_dispatcher_unittest.cc
@@ -171,7 +171,7 @@ class ResourceDispatcherTest : public testing::Test,
request_info.request_type = ResourceType::SUB_RESOURCE;
request_info.appcache_host_id = appcache::kNoHostId;
request_info.routing_id = 0;
- RequestExtraData extra_data(true, 0);
+ RequestExtraData extra_data(true, 0, PageTransition::LINK);
request_info.extra_data = &extra_data;
return dispatcher_->CreateBridge(request_info);
diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h
index cd748b85..15d505b 100644
--- a/content/common/resource_messages.h
+++ b/content/common/resource_messages.h
@@ -6,6 +6,7 @@
// Multiply-included message file, hence no include guard.
#include "base/shared_memory.h"
+#include "content/common/page_transition_types.h"
#include "content/common/resource_response.h"
#include "ipc/ipc_message_macros.h"
#include "net/base/upload_data.h"
@@ -99,6 +100,8 @@ IPC_STRUCT_BEGIN(ResourceHostMsg_Request)
// Identifies the frame within the RenderView that sent the request.
// -1 if unknown / invalid.
IPC_STRUCT_MEMBER(int64, frame_id)
+
+ IPC_STRUCT_MEMBER(PageTransition::Type, transition_type)
IPC_STRUCT_END()
// Resource messages sent from the browser to the renderer.