namespace content {}Please fix this WARNING reported by autoreview issue finding: This empty namespace declaration seems to be a leftover and can be removed.
}Please fix this WARNING reported by autoreview issue finding: If the redirect is to a URL that is NOT a search provider, the 'X-Geo' header added in a previous hop will still be sent because SetRequestHeader persists across redirects. You should call navigation_handle()->RemoveRequestHeader(\"X-Geo\") here to prevent leaking location data to non-search URLs during redirects.
Is there anything to this autoreview finding?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Please fix this WARNING reported by autoreview issue finding: This empty namespace declaration seems to be a leftover and can be removed.
Done
Please fix this WARNING reported by autoreview issue finding: If the redirect is to a URL that is NOT a search provider, the 'X-Geo' header added in a previous hop will still be sent because SetRequestHeader persists across redirects. You should call navigation_handle()->RemoveRequestHeader(\"X-Geo\") here to prevent leaking location data to non-search URLs during redirects.
Is there anything to this autoreview finding?
Yeah this is a good catch. I added logic to remove the header if it redirects to a non-DSE origin and added some tests.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
navigation_handle()->SetRequestHeader("X-Geo", *geo_header);nit: pull this out into a named constant
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
if (!is_android) {Entire source set should be !is_android? Maybe for now? The long term question is whether android_browsertests and browser_tests will share this source set.
if (request.relative_url.find("/search?q=redirect-non-dse") == 0) {In C++20, there's std::string::starts_with(), which is more readable and probably also faster. Other parts of this CL is using that already.
if (request.headers.find("X-Geo") != request.headers.end()) {Reuse the iterator find() returns instead of doing the same lookup twice.
void WaitForSearchRequest() {This is dead code.
std::string GetXGeoHeader() const { return xgeo_header_; }Since `xgeo_header_` is only `protected`, all the test cases can actually access it directly. So this isn't needed?
As-is: Return a const-ref, and don't bother making a copy in the callers when not needed.
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(Unit tests should clean up after themselves in TearDown(), and not leave global resources in a modified state.
#if !BUILDFLAG(IS_IOS)Put this after all the non-conditional includes.
Entire source set should be !is_android? Maybe for now? The long term question is whether android_browsertests and browser_tests will share this source set.
I don't think this source set will ever be on Android since interactive tests use a different framework on Android (in Java). So I put the whole source set in the condition, and slightly reworked the chrome/test/BUILD.gn DEPS include to make sure it's only included on !Android.
if (request.relative_url.find("/search?q=redirect-non-dse") == 0) {In C++20, there's std::string::starts_with(), which is more readable and probably also faster. Other parts of this CL is using that already.
Done
if (request.headers.find("X-Geo") != request.headers.end()) {Reuse the iterator find() returns instead of doing the same lookup twice.
Done
void WaitForSearchRequest() {Andy PaicuThis is dead code.
Done
std::string GetXGeoHeader() const { return xgeo_header_; }Since `xgeo_header_` is only `protected`, all the test cases can actually access it directly. So this isn't needed?
As-is: Return a const-ref, and don't bother making a copy in the callers when not needed.
Done
navigation_handle()->SetRequestHeader("X-Geo", *geo_header);nit: pull this out into a named constant
Done
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(Unit tests should clean up after themselves in TearDown(), and not leave global resources in a modified state.
Done
Put this after all the non-conditional includes.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
if (!(navigation_handle()->GetPageTransition() &optional: probably worth explicitly checking for the validity of the URL and HTTPS scheme
should we also check if the URL is a search URL from the DSE?
`TURLService::IsSearchResultsPageFromDefaultSearchProvider()`
return WillStartRequest();optional: prefer a `ProcessNavigation()` helper method that both WillStartRequest and WillRedirectRequest call.
optional: probably worth explicitly checking for the validity of the URL and HTTPS scheme
All of these checks are done in the GeolocationHeaderService, because it's more robust than to rely on multiple different call sites to be diligent about doing the same checks.
should we also check if the URL is a search URL from the DSE?
`TURLService::IsSearchResultsPageFromDefaultSearchProvider()`
The GeolocationHeaderService checks that the URL is part of the DSE
optional: prefer a `ProcessNavigation()` helper method that both WillStartRequest and WillRedirectRequest call.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
base::test::ScopedFeatureList feature_list_;It's generally better to put this at the top, so it gets destroyed last. If the ScopedFeatureList gets destroyed first, the destructors for other members may behave incorrectly since the feature state changed out from under them.
#if !BUILDFLAG(IS_IOS)Still need to move down a bit further.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
It's generally better to put this at the top, so it gets destroyed last. If the ScopedFeatureList gets destroyed first, the destructors for other members may behave incorrectly since the feature state changed out from under them.
Done
Still need to move down a bit further.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
11 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: chrome/browser/omnibox/geolocation_navigation_throttle.h
Insertions: 3, Deletions: 0.
The diff is too large to show. Please review the diff.
```
```
The name of the file: chrome/browser/omnibox/geolocation_navigation_throttle.cc
Insertions: 15, Deletions: 10.
The diff is too large to show. Please review the diff.
```
```
The name of the file: chrome/browser/omnibox/geolocation_header_browsertest.cc
Insertions: 87, Deletions: 2.
The diff is too large to show. Please review the diff.
```
```
The name of the file: components/omnibox/browser/search_provider.cc
Insertions: 1, Deletions: 2.
The diff is too large to show. Please review the diff.
```
Add navigation throttle to send the X-Geo header on all platforms
As part of the work to port the X-Geo header on all platforms, this CL
will make use of the previously added GeolocationHeaderService to
retrieve and attach the X-Geo HTTP header to appropriate navigation
HTTP requests.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |