Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1646)

Unified Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2689653003: PlzNavigate: Enforce 'form-action' CSP on the browser-side. (Closed)
Patch Set: Rebase. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_handle_impl.cc
diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc
index 7609374b641605ce1dc0313dc564561b658cdeee..f5d52fe881ad79253d9f09a20e0e43efe364b553 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -15,6 +15,7 @@
#include "content/browser/devtools/render_frame_devtools_agent_host.h"
#include "content/browser/frame_host/ancestor_throttle.h"
#include "content/browser/frame_host/debug_urls.h"
+#include "content/browser/frame_host/form_submission_throttle.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/mixed_content_navigation_throttle.h"
#include "content/browser/frame_host/navigation_controller_impl.h"
@@ -66,11 +67,12 @@ std::unique_ptr<NavigationHandleImpl> NavigationHandleImpl::Create(
const base::TimeTicks& navigation_start,
int pending_nav_entry_id,
bool started_from_context_menu,
- bool should_bypass_main_world_csp) {
+ bool should_bypass_main_world_csp,
+ bool is_form_submission) {
return std::unique_ptr<NavigationHandleImpl>(new NavigationHandleImpl(
url, redirect_chain, frame_tree_node, is_renderer_initiated, is_same_page,
navigation_start, pending_nav_entry_id, started_from_context_menu,
- should_bypass_main_world_csp));
+ should_bypass_main_world_csp, is_form_submission));
}
NavigationHandleImpl::NavigationHandleImpl(
@@ -82,7 +84,8 @@ NavigationHandleImpl::NavigationHandleImpl(
const base::TimeTicks& navigation_start,
int pending_nav_entry_id,
bool started_from_context_menu,
- bool should_bypass_main_world_csp)
+ bool should_bypass_main_world_csp,
+ bool is_form_submission)
: url_(url),
has_user_gesture_(false),
transition_(ui::PAGE_TRANSITION_LINK),
@@ -113,6 +116,7 @@ NavigationHandleImpl::NavigationHandleImpl(
restore_type_(RestoreType::NONE),
navigation_type_(NAVIGATION_TYPE_UNKNOWN),
should_bypass_main_world_csp_(should_bypass_main_world_csp),
+ is_form_submission_(is_form_submission),
weak_factory_(this) {
DCHECK(!navigation_start.is_null());
if (redirect_chain_.empty())
@@ -466,6 +470,12 @@ NavigationData* NavigationHandleImpl::GetNavigationData() {
return navigation_data_.get();
}
+bool NavigationHandleImpl::is_form_submission() const {
+ DCHECK(IsBrowserSideNavigationEnabled())
+ << "This method is implemented only with PlzNavigate";
+ return is_form_submission_;
+}
+
const GlobalRequestID& NavigationHandleImpl::GetGlobalRequestID() {
DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE ||
state_ == READY_TO_COMMIT);
@@ -915,6 +925,11 @@ void NavigationHandleImpl::RegisterNavigationThrottles() {
if (ancestor_throttle)
throttles_.push_back(std::move(ancestor_throttle));
+ std::unique_ptr<content::NavigationThrottle> form_submission_throttle =
+ content::FormSubmissionThrottle::MaybeCreateThrottleFor(this);
+ if (form_submission_throttle)
+ throttles_.push_back(std::move(form_submission_throttle));
+
throttles_.insert(throttles_.begin(),
std::make_move_iterator(throttles_to_register.begin()),
std::make_move_iterator(throttles_to_register.end()));

Powered by Google App Engine
This is Rietveld 408576698