Skip to content

Commit

Permalink
Merge pull request #421 from brave/pocket
Browse files Browse the repository at this point in the history
Exclude referrer patch code when url is chrome-extension
  • Loading branch information
bbondy committed Sep 8, 2018
1 parent 4d51cff commit ccda442
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,4 @@ TEST_F(BraveStaticRedirectNetworkDelegateHelperTest, ModifySafeBrowsingURLV5) {
EXPECT_EQ(ret, net::OK);
}


TEST_F(BraveStaticRedirectNetworkDelegateHelperTest, ModifyComponentUpdaterURL) {
net::TestDelegate test_delegate;
std::string query_string("?foo=bar");
GURL url(std::string(component_updater::kUpdaterDefaultUrl) + query_string);
std::unique_ptr<net::URLRequest> request =
context()->CreateRequest(url, net::IDLE, &test_delegate,
TRAFFIC_ANNOTATION_FOR_TESTS);
std::shared_ptr<brave::BraveRequestInfo>
before_url_context(new brave::BraveRequestInfo());
brave::ResponseCallback callback;
GURL new_url;
GURL expected_url(std::string(kBraveUpdatesExtensionsEndpoint + query_string));
int ret =
OnBeforeURLRequest_StaticRedirectWork(request.get(), &new_url, callback,
before_url_context);
EXPECT_EQ(new_url, expected_url);
EXPECT_EQ(ret, net::OK);
}


} // namespace
16 changes: 6 additions & 10 deletions patches/content-browser-frame_host-navigation_request.cc.patch
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index 37f6135b22a4472733afa38dbc3bd27ccfb60036..ea00172e369b134f4cd1cd19bf55c2e160d1e12a 100644
index 37f6135b22a4472733afa38dbc3bd27ccfb60036..8c7e366936bd8deb1ae4e4a39727bee920261fc8 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -1651,6 +1651,29 @@ void NavigationRequest::CommitNavigation() {
@@ -1651,6 +1651,25 @@ void NavigationRequest::CommitNavigation() {
}
associated_site_instance_id_.reset();
}
+
+ auto* pending_entry =
+ frame_tree_node_->navigator()->GetController()->GetPendingEntry();
+ if (pending_entry) {
+ if (!pending_entry->GetURL().is_empty()) {
+ common_params_.url = pending_entry->GetURL();
+ }
+ if (!pending_entry->GetReferrer().url.is_empty()) {
+ common_params_.referrer = pending_entry->GetReferrer();
+ common_params_.referrer =
+ Referrer::SanitizeForRequest(common_params_.url, pending_entry->GetReferrer());
+ }
+ } else {
+ auto* last_committed_entry =
+ frame_tree_node_->navigator()->GetController()->GetLastCommittedEntry();
+ if (last_committed_entry) {
+ if (!last_committed_entry->GetURL().is_empty()) {
+ common_params_.url = last_committed_entry->GetURL();
+ }
+ if (!last_committed_entry->GetReferrer().url.is_empty()) {
+ common_params_.referrer = last_committed_entry->GetReferrer();
+ common_params_.referrer =
+ Referrer::SanitizeForRequest(common_params_.url, last_committed_entry->GetReferrer());
+ }
+ }
+ }
Expand Down

0 comments on commit ccda442

Please sign in to comment.