Auto-Submit | +1 |
Commit-Queue | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This change will be blocked from submission as there are files which do not meet the coverage criteria. Following files have incremental coverage(all tests) < 70%.
Please add tests for uncovered lines, or add Low-Coverage-Reason:<reason> in the change description to bypass. See https://bit.ly/46jhjS9 to understand when it is okay to bypass. If you think coverage is underreported, file a bug at https://bit.ly/3ENM7Pe
Code-Coverage | -1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
!net::IsGoogleHostWithAlpnH3(base::SysNSStringToUTF8(request.URL.host))) {
the comment on this method is "This should only be used for histograms and shouldn't be used to affect behavior."
DCHECK(!URL.IsAboutBlank());
should this be CHECK()? Or should we just add handling for this? (e.g. allow navigation?)
/// Called when the result page opens a new tab.
- (void)resultPageDidOpenNewTab;
This should be unnecessary. Instead, I think we can rely on https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/lens_overlay/model/lens_overlay_tab_helper.mm;l=38?q=lens_overlay_tab_helper to hide the UI
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
- (void)shouldAllowRequest:(NSURLRequest*)request
requestInfo:(web::WebStatePolicyDecider::RequestInfo)requestInfo
decisionHandler:(PolicyDecisionHandler)decisionHandler {
Can you add tests for this?
@property(nonatomic, weak) id<ApplicationCommands> applicationCommandsHandler;
Nit: remove "commands" go/bling-best-practices.
DCHECK(!URL.IsAboutBlank());
should this be CHECK()? Or should we just add handling for this? (e.g. allow navigation?)
No new DCHECK should be added. Use CHECK or early return.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Auto-Submit | +1 |
Commit-Queue | +1 |
@property(nonatomic, weak) id<ApplicationCommands> applicationCommandsHandler;
Christian XuNit: remove "commands" go/bling-best-practices.
Done
- (void)shouldAllowRequest:(NSURLRequest*)request
requestInfo:(web::WebStatePolicyDecider::RequestInfo)requestInfo
decisionHandler:(PolicyDecisionHandler)decisionHandler {
Can you add tests for this?
Done
!net::IsGoogleHostWithAlpnH3(base::SysNSStringToUTF8(request.URL.host))) {
the comment on this method is "This should only be used for histograms and shouldn't be used to affect behavior."
Done
should this be CHECK()? Or should we just add handling for this? (e.g. allow navigation?)
Done, I was using the wrong OpenNewTab command.
/// Called when the result page opens a new tab.
- (void)resultPageDidOpenNewTab;
This should be unnecessary. Instead, I think we can rely on https://source.chromium.org/chromium/chromium/src/+/main:ios/chrome/browser/lens_overlay/model/lens_overlay_tab_helper.mm;l=38?q=lens_overlay_tab_helper to hide the UI
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
@interface LensResultPageMediator (Testing)
Instead of that, I think I would rather:
1. Assert that the mediator is conforming to `CRWWebStatePolicyDecider` in a test
2. Cast it to `id<CRWWebStatePolicyDecider>` and then call the method on it.
And remove this file.
[mock_application_handler_ verify];
Nit: Use EXPECT_OCMOCK_VERIFY. Otherwise it won't play nicely with gtest.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Auto-Submit | +1 |
Commit-Queue | +1 |
Instead of that, I think I would rather:
1. Assert that the mediator is conforming to `CRWWebStatePolicyDecider` in a test
2. Cast it to `id<CRWWebStatePolicyDecider>` and then call the method on it.And remove this file.
Done
Nit: Use EXPECT_OCMOCK_VERIFY. Otherwise it won't play nicely with gtest.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This change will be blocked from submission as there are files which do not meet the coverage criteria. Following files have incremental coverage(all tests) < 70%.
Please add tests for uncovered lines, or add Low-Coverage-Reason:<reason> in the change description to bypass. See https://bit.ly/46jhjS9 to understand when it is okay to bypass. If you think coverage is underreported, file a bug at https://bit.ly/3ENM7Pe
Code-Coverage | -1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
EXPECT_TRUE(
Nit: this should be an ASSERT_TRUE, not EXPECT. Assert will stop the execution of the test and will prevent a crash after if it doesn't conform.
[(id<CRWWebStatePolicyDecider>)mediator_
Nit: use a static_cast and an intermediate variable.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Auto-Submit | +1 |
Nit: this should be an ASSERT_TRUE, not EXPECT. Assert will stop the execution of the test and will prevent a crash after if it doesn't conform.
ASSERT_TRUE will fails to void, which doesn't conform to the function's return type. Replaced with an if condition to avoid crash. The `EXPECT_TRUE(callback_called)` below should be sufficient.
Nit: use a static_cast and an intermediate variable.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This change will be blocked from submission as there are files which do not meet the coverage criteria. Following files have incremental coverage(all tests) < 70%.
Please add tests for uncovered lines, or add Low-Coverage-Reason:<reason> in the change description to bypass. See https://bit.ly/46jhjS9 to understand when it is okay to bypass. If you think coverage is underreported, file a bug at https://bit.ly/3ENM7Pe
Code-Coverage | -1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
isIncognito:browser->GetBrowserState()->IsOffTheRecord()];
I think we're not planning for the feature to be available in incognito, but let's keep this for now.
BOOL IsNavigationAllowed(const GURL& URL) {
nit, naming: "allowed" sounds like the antonym is "blocked", not "open in new tab".
How about `IsValidURLToOpenInResultsPage` or we reverse the return arg and `URLShouldOpenInNewTab` ?
[[nodiscard]] bool TestShouldAllowRequest(
nit: add comment
ui::PageTransition transition_type =
ui::PageTransition::PAGE_TRANSITION_LINK) {
optional nit: do we need this, even if we never override this?
// Tests that any navigation that's not on main frame is allowed.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Auto-Submit | +1 |
Commit-Queue | +2 |
nit, naming: "allowed" sounds like the antonym is "blocked", not "open in new tab".
How about `IsValidURLToOpenInResultsPage` or we reverse the return arg and `URLShouldOpenInNewTab` ?
Done
[[nodiscard]] bool TestShouldAllowRequest(
Christian Xunit: add comment
Done
ui::PageTransition transition_type =
ui::PageTransition::PAGE_TRANSITION_LINK) {
optional nit: do we need this, even if we never override this?
Done
// Tests that any navigation that's not on main frame is allowed.
since it's "any" navigation, can we also test with google.com here?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Auto-Submit | +1 |
Commit-Queue | +2 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This change will be blocked from submission as there are files which do not meet the coverage criteria. Following files have incremental coverage(all tests) < 70%.
Please add tests for uncovered lines, or add Low-Coverage-Reason:<reason> in the change description to bypass. See https://bit.ly/46jhjS9 to understand when it is okay to bypass. If you think coverage is underreported, file a bug at https://bit.ly/3ENM7Pe
Code-Coverage | -1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
12 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: ios/chrome/browser/lens_overlay/coordinator/lens_result_page_mediator.mm
Insertions: 2, Deletions: 2.
@@ -23,7 +23,7 @@
namespace {
/// Returns whether the navigation is allowed inside of the result page.
-BOOL IsNavigationAllowed(const GURL& URL) {
+BOOL IsValidURLToOpenInResultsPage(const GURL& URL) {
std::string_view host = URL.host_piece();
return base::EqualsCaseInsensitiveASCII(host, "google.com") ||
base::EqualsCaseInsensitiveASCII(host, "www.google.com");
@@ -93,7 +93,7 @@
requestInfo:(web::WebStatePolicyDecider::RequestInfo)requestInfo
decisionHandler:(PolicyDecisionHandler)decisionHandler {
GURL URL = net::GURLWithNSURL(request.URL);
- if (requestInfo.target_frame_is_main && !IsNavigationAllowed(URL)) {
+ if (requestInfo.target_frame_is_main && !IsValidURLToOpenInResultsPage(URL)) {
decisionHandler(web::WebStatePolicyDecider::PolicyDecision::Cancel());
OpenNewTabCommand* command =
[[OpenNewTabCommand alloc] initWithURL:URL
```
```
The name of the file: ios/chrome/browser/lens_overlay/coordinator/lens_result_page_mediator_unittest.mm
Insertions: 6, Deletions: 6.
@@ -58,14 +58,12 @@
PlatformTest::TearDown();
}
- [[nodiscard]] bool TestShouldAllowRequest(
- NSString* url_string,
- bool target_frame_is_main,
- ui::PageTransition transition_type =
- ui::PageTransition::PAGE_TRANSITION_LINK) {
+ // Tests whether the navigation is allowed by the policy provider.
+ [[nodiscard]] bool TestShouldAllowRequest(NSString* url_string,
+ bool target_frame_is_main) {
NSURL* url = [NSURL URLWithString:url_string];
const web::WebStatePolicyDecider::RequestInfo request_info(
- transition_type, target_frame_is_main,
+ ui::PageTransition::PAGE_TRANSITION_LINK, target_frame_is_main,
/*target_frame_is_cross_origin=*/false,
/*target_window_is_cross_origin=*/false,
/*is_user_initiated=*/true,
@@ -128,6 +126,8 @@
TEST_F(LensResultPageMediatorTest, ShouldAllowAnyNavigationNotInMainFrame) {
EXPECT_TRUE(TestShouldAllowRequest(@"https://www.chromium.com",
/*target_frame_is_main=*/false));
+ EXPECT_TRUE(TestShouldAllowRequest(@"https://www.google.com",
+ /*target_frame_is_main=*/false));
}
} // namespace
```
[iOS][LO][LRP] Add web state policy decider
Add a web state policy decider in LensResultPageMediator to block
navigation to non-LRP links. These links are opened in a new tab.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |