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

Issue 154473002: Support redirectUrl at onHeadersReceived in WebRequest / DWR API (Closed)

Created:
6 years, 10 months ago by robwu
Modified:
6 years, 9 months ago
CC:
chromium-reviews, extensions-reviews_chromium.org, cbentzel+watch_chromium.org, jam, joi+watch-content_chromium.org, darin-cc_chromium.org, chromium-apps-reviews_chromium.org, jochen+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

Support redirectUrl at onHeadersReceived in WebRequest / DWR API Add support for extension-initiated redirects via the (declarative) Web Request API. The existing URL validation and conflict resolution logic of redirectUrl at onBeforeRequest is re-used for the implementation of redirectUrl at onHeadersReceived. To make sure that redirects to data:// and chrome-extension:// URLs are not blocked, a new parameter has been added to the network delegate (allowed_unsafe_redirect_url). BUG=280464, 115940 TEST=browser_tests: ExtensionWebRequestApiTest.WebRequestBlocking:ExtensionWebRequestApiTest.WebRequestDeclarative1 unit_tests: ExtensionWebRequestTest.*:WebRequestActionWithThreadsTest.* net_unittests: URLRequestTestHTTP.NetworkDelegateRedirectRequestOnHeadersReceived*: URLRequestTestHTTP.UnsafeRedirect*: URLRequestTestHTTP.*ReferenceFragment* Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=259546

Patch Set 1 #

Patch Set 2 : Rebased #

Total comments: 2

Patch Set 3 : +net test, fix nit #

Total comments: 1

Patch Set 4 : rebase #

Patch Set 5 : optimization and robustness #

Patch Set 6 : rebase #

Patch Set 7 : Pass new url via ResponseHeaders instead of method argument #

Patch Set 8 : replace boolean member with GURL #

Patch Set 9 : Add more tests #

Total comments: 23

Patch Set 10 : Pass allowed_unsafe_redirect_url via delegate parameter instead of HttpResponseHeaders + fragment t… #

Total comments: 10

Patch Set 11 : rebase + git cl format #

Patch Set 12 : address reviewer's comments, change 307 to 302 redirect #

Total comments: 6

Patch Set 13 : clarify documentation #

Total comments: 6

Patch Set 14 : address reviewer comments (mmenke) #

Total comments: 2

Patch Set 15 : move tests to similar tests #

Patch Set 16 : update formal parameters of url_request_context_peer.cc #

Patch Set 17 : fix WebRequestRulesRegistrySimpleTest.StageChecker test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+609 lines, -93 lines) Patch
M android_webview/browser/net/aw_network_delegate.h View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -2 lines 0 comments Download
M android_webview/browser/net/aw_network_delegate.cc View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/extensions/api/declarative_webrequest/webrequest_action.cc View 1 2 3 4 5 6 7 8 9 10 4 chunks +4 lines, -4 lines 0 comments Download
M chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc View 3 chunks +9 lines, -0 lines 0 comments Download
M chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +20 lines, -18 lines 0 comments Download
M chrome/browser/extensions/api/web_request/web_request_api.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +5 lines, -4 lines 0 comments Download
M chrome/browser/extensions/api/web_request/web_request_api.cc View 1 2 3 4 5 6 7 8 9 10 5 chunks +12 lines, -4 lines 0 comments Download
M chrome/browser/extensions/api/web_request/web_request_api_helpers.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +13 lines, -0 lines 0 comments Download
M chrome/browser/extensions/api/web_request/web_request_api_helpers.cc View 1 2 3 4 5 6 7 8 9 10 11 7 chunks +33 lines, -5 lines 0 comments Download
M chrome/browser/extensions/api/web_request/web_request_api_unittest.cc View 1 2 3 4 5 6 7 8 9 10 6 chunks +98 lines, -10 lines 0 comments Download
M chrome/browser/net/chrome_network_delegate.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/browser/net/chrome_network_delegate.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +9 lines, -3 lines 0 comments Download
M chrome/common/extensions/api/web_request.json View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -1 line 0 comments Download
M chrome/common/extensions/docs/templates/intros/declarativeWebRequest.html View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +12 lines, -7 lines 0 comments Download
M chrome/common/extensions/docs/templates/intros/webRequest.html View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M chrome/test/data/extensions/api_test/webrequest/test_blocking.js View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +85 lines, -0 lines 0 comments Download
M chrome/test/data/extensions/api_test/webrequest/test_declarative1.js View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +56 lines, -0 lines 0 comments Download
M content/shell/browser/shell_network_delegate.h View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -2 lines 0 comments Download
M content/shell/browser/shell_network_delegate.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -1 line 0 comments Download
M net/base/network_delegate.h View 1 2 3 4 5 6 7 8 9 2 chunks +4 lines, -2 lines 0 comments Download
M net/base/network_delegate.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +9 lines, -4 lines 0 comments Download
M net/cronet/android/url_request_context_peer.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +2 lines, -1 line 0 comments Download
M net/proxy/network_delegate_error_observer_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -1 line 0 comments Download
M net/proxy/proxy_script_fetcher_impl_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -2 lines 0 comments Download
M net/url_request/url_request_context_builder.cc View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -2 lines 0 comments Download
M net/url_request/url_request_http_job.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +3 lines, -0 lines 0 comments Download
M net/url_request/url_request_http_job.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +12 lines, -1 line 0 comments Download
M net/url_request/url_request_test_util.h View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +8 lines, -1 line 0 comments Download
M net/url_request/url_request_test_util.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +5 lines, -1 line 0 comments Download
M net/url_request/url_request_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 9 chunks +191 lines, -13 lines 0 comments Download

Messages

Total messages: 53 (0 generated)
robwu
(sorry if you receive this mail twice, the previous one was submitted with the wrong ...
6 years, 10 months ago (2014-02-04 21:36:22 UTC) #1
robwu
battre: Please review chrome/* ((D)WR API and docs) You can use the new tests to ...
6 years, 10 months ago (2014-02-11 21:46:47 UTC) #2
battre
chrome/* LGTM https://codereview.chromium.org/154473002/diff/90001/net/url_request/url_request_http_job.cc File net/url_request/url_request_http_job.cc (right): https://codereview.chromium.org/154473002/diff/90001/net/url_request/url_request_http_job.cc#newcode1042 net/url_request/url_request_http_job.cc:1042: int* http_status_code) { nit: indentation. https://codereview.chromium.org/154473002/diff/90001/net/url_request/url_request_unittest.cc File ...
6 years, 10 months ago (2014-02-12 11:54:47 UTC) #3
robwu
On 2014/02/12 11:54:47, battre wrote: > https://codereview.chromium.org/154473002/diff/90001/net/url_request/url_request_http_job.cc#newcode1042 > net/url_request/url_request_http_job.cc:1042: int* http_status_code) { > nit: indentation. ...
6 years, 10 months ago (2014-02-12 17:35:20 UTC) #4
darin (slow to review)
LGTM for the parts you asked me to review.
6 years, 10 months ago (2014-02-12 18:29:30 UTC) #5
battre
https://codereview.chromium.org/154473002/diff/150001/net/url_request/url_request_unittest.cc File net/url_request/url_request_unittest.cc (right): https://codereview.chromium.org/154473002/diff/150001/net/url_request/url_request_unittest.cc#newcode3055 net/url_request/url_request_unittest.cc:3055: EXPECT_EQ(1, network_delegate.destroyed_requests()); This looks suspicious. Shouldn't there be a) ...
6 years, 10 months ago (2014-02-13 15:30:32 UTC) #6
robwu
On 2014/02/13 15:30:32, battre wrote: > https://codereview.chromium.org/154473002/diff/150001/net/url_request/url_request_unittest.cc > File net/url_request/url_request_unittest.cc (right): > > https://codereview.chromium.org/154473002/diff/150001/net/url_request/url_request_unittest.cc#newcode3055 > ...
6 years, 10 months ago (2014-02-13 15:45:26 UTC) #7
robwu
eroman: Could you also review net/url_request/url_request_http_job.cc? It's the last thing that needs to be reviewed ...
6 years, 10 months ago (2014-02-19 23:27:59 UTC) #8
darin (slow to review)
I defer to Eric to review the URLRequestHttpJob changes. He's been in that code more ...
6 years, 10 months ago (2014-02-20 22:30:20 UTC) #9
robwu
Ping Eric, please review net/url_request/url_request_http_job.cc .
6 years, 9 months ago (2014-02-28 11:27:42 UTC) #10
eroman
I'm not sure that I understand why a new parameter is needed. The extensions already ...
6 years, 9 months ago (2014-02-28 19:50:48 UTC) #11
mmenke
On 2014/02/28 19:50:48, eroman wrote: > I'm not sure that I understand why a new ...
6 years, 9 months ago (2014-02-28 20:17:37 UTC) #12
robwu
On 2014/02/28 20:17:37, mmenke wrote: > On 2014/02/28 19:50:48, eroman wrote: > > I'm not ...
6 years, 9 months ago (2014-02-28 20:49:31 UTC) #13
robwu
Updated CL, the redirect url is communicated to the network stack via the ResponseHeaders instead ...
6 years, 9 months ago (2014-03-02 14:52:08 UTC) #14
robwu
Eric, please review net/*.
6 years, 9 months ago (2014-03-11 09:22:10 UTC) #15
robwu
+mmenke as reviewer for net/* since Eric admitted that you are more familiar with the ...
6 years, 9 months ago (2014-03-12 15:21:04 UTC) #16
mmenke
On 2014/03/12 15:21:04, robwu wrote: > +mmenke as reviewer for net/* since Eric admitted that ...
6 years, 9 months ago (2014-03-12 15:30:40 UTC) #17
mmenke
So sorry for the slow response. I've been deluged with reviews this week. I don't ...
6 years, 9 months ago (2014-03-14 16:19:25 UTC) #18
mmenke
On 2014/03/14 16:19:25, mmenke wrote: > So sorry for the slow response. I've been deluged ...
6 years, 9 months ago (2014-03-14 16:20:49 UTC) #19
robwu
On 2014/03/14 16:20:49, mmenke wrote: > On 2014/03/14 16:19:25, mmenke wrote: > > So sorry ...
6 years, 9 months ago (2014-03-14 17:36:21 UTC) #20
mmenke
On 2014/03/14 17:36:21, robwu wrote: > On 2014/03/14 16:20:49, mmenke wrote: > > On 2014/03/14 ...
6 years, 9 months ago (2014-03-14 18:33:09 UTC) #21
mmenke
On 2014/03/14 18:33:09, mmenke wrote: > On 2014/03/14 17:36:21, robwu wrote: > > On 2014/03/14 ...
6 years, 9 months ago (2014-03-17 19:10:27 UTC) #22
robwu
On 2014/03/17 19:10:27, mmenke wrote: > On 2014/03/14 18:33:09, mmenke wrote: > > On 2014/03/14 ...
6 years, 9 months ago (2014-03-17 21:25:23 UTC) #23
mmenke
On 2014/03/17 21:25:23, robwu wrote: > On 2014/03/17 19:10:27, mmenke wrote: > > On 2014/03/14 ...
6 years, 9 months ago (2014-03-18 17:00:06 UTC) #24
mmenke
On 2014/03/18 17:00:06, mmenke wrote: > On 2014/03/17 21:25:23, robwu wrote: > > On 2014/03/17 ...
6 years, 9 months ago (2014-03-18 17:03:37 UTC) #25
robwu
On 2014/03/18 17:03:37, mmenke wrote: > On 2014/03/18 17:00:06, mmenke wrote: > > On 2014/03/17 ...
6 years, 9 months ago (2014-03-18 18:00:14 UTC) #26
mmenke
So here's what I think we should do... Almost just what you suggest, except the ...
6 years, 9 months ago (2014-03-19 15:02:57 UTC) #27
robwu
On 2014/03/19 15:02:57, mmenke wrote: > So here's what I think we should do... Almost ...
6 years, 9 months ago (2014-03-19 22:59:26 UTC) #28
mmenke
Looks pretty good. Good job on the tests! https://codereview.chromium.org/154473002/diff/560001/net/url_request/url_request_http_job.cc File net/url_request/url_request_http_job.cc (right): https://codereview.chromium.org/154473002/diff/560001/net/url_request/url_request_http_job.cc#newcode294 net/url_request/url_request_http_job.cc:294: transaction_->StopCaching(); ...
6 years, 9 months ago (2014-03-20 15:22:24 UTC) #29
mmenke
Looks pretty good. Good job on the tests!
6 years, 9 months ago (2014-03-20 15:22:26 UTC) #30
mmenke
One more comment. https://codereview.chromium.org/154473002/diff/560001/net/http/http_response_headers.cc File net/http/http_response_headers.cc (right): https://codereview.chromium.org/154473002/diff/560001/net/http/http_response_headers.cc#newcode921 net/http/http_response_headers.cc:921: replacements.ClearRef(); Hrm... Is this needed?
6 years, 9 months ago (2014-03-20 16:13:32 UTC) #31
robwu
Some replies (I will fix the nits without commenting on those). https://codereview.chromium.org/154473002/diff/560001/net/http/http_response_headers.cc File net/http/http_response_headers.cc (right): ...
6 years, 9 months ago (2014-03-20 16:21:10 UTC) #32
mmenke
https://codereview.chromium.org/154473002/diff/560001/net/http/http_response_headers.cc File net/http/http_response_headers.cc (right): https://codereview.chromium.org/154473002/diff/560001/net/http/http_response_headers.cc#newcode921 net/http/http_response_headers.cc:921: replacements.ClearRef(); On 2014/03/20 16:21:11, robwu wrote: > On 2014/03/20 ...
6 years, 9 months ago (2014-03-20 16:40:27 UTC) #33
mmenke
https://codereview.chromium.org/154473002/diff/560001/net/url_request/url_request_http_job.cc File net/url_request/url_request_http_job.cc (right): https://codereview.chromium.org/154473002/diff/560001/net/url_request/url_request_http_job.cc#newcode294 net/url_request/url_request_http_job.cc:294: transaction_->StopCaching(); On 2014/03/20 16:40:28, mmenke wrote: > On 2014/03/20 ...
6 years, 9 months ago (2014-03-20 17:22:37 UTC) #34
robwu
https://codereview.chromium.org/154473002/diff/560001/net/http/http_response_headers.cc File net/http/http_response_headers.cc (right): https://codereview.chromium.org/154473002/diff/560001/net/http/http_response_headers.cc#newcode921 net/http/http_response_headers.cc:921: replacements.ClearRef(); On 2014/03/20 16:40:28, mmenke wrote: > On 2014/03/20 ...
6 years, 9 months ago (2014-03-20 17:28:14 UTC) #35
mmenke
https://codereview.chromium.org/154473002/diff/560001/net/url_request/url_request_http_job.cc File net/url_request/url_request_http_job.cc (right): https://codereview.chromium.org/154473002/diff/560001/net/url_request/url_request_http_job.cc#newcode1045 net/url_request/url_request_http_job.cc:1045: if (GetResponseHeaders()->IsSafeRedirect(location)) { On 2014/03/20 17:28:14, robwu wrote: > ...
6 years, 9 months ago (2014-03-20 17:31:58 UTC) #36
robwu
mmenke, could you review: net/url_request/url_request_http_job.cc and net/url_request/url_request_unittest.cc I have moved the allowed_safe_redirect_url from the headers ...
6 years, 9 months ago (2014-03-21 14:39:51 UTC) #37
mmenke
This looks pretty good. I'll want to land my CL first, just so we never ...
6 years, 9 months ago (2014-03-21 18:15:02 UTC) #38
robwu
Dominic, PTAL. I have changed 307 to 302 redirects at onHeadersReceived, because I cannot imagine ...
6 years, 9 months ago (2014-03-25 00:03:59 UTC) #39
battre
I think that the 307 redirects were intentional so that extensions like HTTPS everywhere can ...
6 years, 9 months ago (2014-03-25 00:47:29 UTC) #40
robwu
On 2014/03/25 00:47:29, battre wrote: > I think that the 307 redirects were intentional so ...
6 years, 9 months ago (2014-03-25 10:08:14 UTC) #41
mmenke
https://codereview.chromium.org/154473002/diff/640001/net/url_request/url_request_unittest.cc File net/url_request/url_request_unittest.cc (right): https://codereview.chromium.org/154473002/diff/640001/net/url_request/url_request_unittest.cc#newcode2728 net/url_request/url_request_unittest.cc:2728: EXPECT_EQ(0, r.status().error()); This should be net::OK instead of 0. ...
6 years, 9 months ago (2014-03-25 15:08:33 UTC) #42
robwu
https://codereview.chromium.org/154473002/diff/640001/net/url_request/url_request_unittest.cc File net/url_request/url_request_unittest.cc (right): https://codereview.chromium.org/154473002/diff/640001/net/url_request/url_request_unittest.cc#newcode2728 net/url_request/url_request_unittest.cc:2728: EXPECT_EQ(0, r.status().error()); On 2014/03/25 15:08:34, mmenke wrote: > This ...
6 years, 9 months ago (2014-03-25 15:59:34 UTC) #43
mmenke
net/ and chrome/browser/net LGTM https://codereview.chromium.org/154473002/diff/690001/net/url_request/url_request_unittest.cc File net/url_request/url_request_unittest.cc (right): https://codereview.chromium.org/154473002/diff/690001/net/url_request/url_request_unittest.cc#newcode2708 net/url_request/url_request_unittest.cc:2708: TEST_F(URLRequestTestHTTP, UnsafeRedirectToWhitelistedUnsafeURL) { nit: These ...
6 years, 9 months ago (2014-03-25 20:27:37 UTC) #44
robwu
Dominic: Using 302 instead of 307 for the implementation of redirectUrl at onHeadersReceived is a ...
6 years, 9 months ago (2014-03-25 21:23:18 UTC) #45
battre
Yes, still LGTM. Thanks and kudos. Great job! Best regards, Dominic
6 years, 9 months ago (2014-03-25 23:19:19 UTC) #46
robwu
The CQ bit was checked by rob@robwu.nl
6 years, 9 months ago (2014-03-25 23:19:53 UTC) #47
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rob@robwu.nl/154473002/740001
6 years, 9 months ago (2014-03-25 23:20:18 UTC) #48
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 9 months ago (2014-03-26 00:24:07 UTC) #49
commit-bot: I haz the power
Retried try job too often on android_clang_dbg for step(s) slave_steps http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=android_clang_dbg&number=126774
6 years, 9 months ago (2014-03-26 00:24:07 UTC) #50
robwu
The CQ bit was checked by rob@robwu.nl
6 years, 9 months ago (2014-03-26 08:37:17 UTC) #51
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rob@robwu.nl/154473002/990001
6 years, 9 months ago (2014-03-26 08:37:21 UTC) #52
commit-bot: I haz the power
6 years, 9 months ago (2014-03-26 10:41:27 UTC) #53
Message was sent while issue was closed.
Change committed as 259546

Powered by Google App Engine
This is Rietveld 408576698