Commit cb0091b9 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Chromium LUCI CQ

[iOS] Don't stop loading when editing omnibox

This CL change the behaviour when editing a the omnibox to not stop the
load of the page when typing in the omnibox.

Bug: 818649, 1159147
Change-Id: If4e71aee5a8ad5367122058630a54039399d7040
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627490
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843091}
parent 276601dd
...@@ -397,8 +397,6 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -397,8 +397,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// YES if Voice Search should be started when the new tab animation is // YES if Voice Search should be started when the new tab animation is
// finished. // finished.
BOOL _startVoiceSearchAfterNewTabAnimation; BOOL _startVoiceSearchAfterNewTabAnimation;
// YES if a load was cancelled due to typing in the location bar.
BOOL _locationBarEditCancelledLoad;
// YES if waiting for a foreground tab due to expectNewForegroundTab. // YES if waiting for a foreground tab due to expectNewForegroundTab.
BOOL _expectingForegroundTab; BOOL _expectingForegroundTab;
...@@ -4356,28 +4354,9 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -4356,28 +4354,9 @@ NSString* const kBrowserViewControllerSnackbarCategory =
[[OmniboxGeolocationController sharedInstance] [[OmniboxGeolocationController sharedInstance]
locationBarDidResignFirstResponder:self.browserState]; locationBarDidResignFirstResponder:self.browserState];
// If a load was cancelled by an omnibox edit, but nothing is loading when
// editing ends (i.e., editing was cancelled), restart the cancelled load.
if (_locationBarEditCancelledLoad) {
_locationBarEditCancelledLoad = NO;
web::WebState* webState = self.currentWebState;
if (!_isShutdown && webState && ![self.helper isToolbarLoading:webState])
webState->GetNavigationManager()->Reload(web::ReloadType::NORMAL,
false /* check_for_repost */);
}
[self.primaryToolbarCoordinator transitionToLocationBarFocusedState:NO]; [self.primaryToolbarCoordinator transitionToLocationBarFocusedState:NO];
} }
- (void)locationBarBeganEdit {
// On handsets, if a page is currently loading it should be stopped.
if (![self canShowTabStrip] &&
[self.helper isToolbarLoading:self.currentWebState]) {
WebNavigationBrowserAgent::FromBrowser(self.browser)->StopLoading();
_locationBarEditCancelledLoad = YES;
}
}
- (LocationBarModel*)locationBarModel { - (LocationBarModel*)locationBarModel {
return _locationBarModel.get(); return _locationBarModel.get();
} }
......
...@@ -224,22 +224,6 @@ TEST_F(BrowserViewControllerTest, TestWebStateSelected) { ...@@ -224,22 +224,6 @@ TEST_F(BrowserViewControllerTest, TestWebStateSelected) {
EXPECT_TRUE(ActiveWebState()->IsVisible()); EXPECT_TRUE(ActiveWebState()->IsVisible());
} }
// Verifies that editing the omnimbox while the page is loading will stop the
// load on a handset, but not stop the load on a tablet.
TEST_F(BrowserViewControllerTest,
TestLocationBarBeganEdit_whenPageLoadIsInProgress) {
// Have the TestLocationBarModel indicate that a page load is in progress.
id partialMock = OCMPartialMock(bvcHelper_);
OCMExpect([partialMock isToolbarLoading:static_cast<web::WebState*>(
[OCMArg anyPointer])])
.andReturn(YES);
// The tab should stop loading on iPhones.
[bvc_ locationBarBeganEdit];
if (!IsIPadIdiom())
EXPECT_FALSE(ActiveWebState()->IsLoading());
}
TEST_F(BrowserViewControllerTest, TestClearPresentedState) { TEST_F(BrowserViewControllerTest, TestClearPresentedState) {
EXPECT_CALL(*this, OnCompletionCalled()); EXPECT_CALL(*this, OnCompletionCalled());
[bvc_ [bvc_
......
...@@ -369,10 +369,6 @@ ...@@ -369,10 +369,6 @@
[self.delegate locationBarDidResignFirstResponder]; [self.delegate locationBarDidResignFirstResponder];
} }
- (void)locationBarBeganEdit {
[self.delegate locationBarBeganEdit];
}
- (web::WebState*)webState { - (web::WebState*)webState {
return self.webStateList->GetActiveWebState(); return self.webStateList->GetActiveWebState();
} }
......
...@@ -47,8 +47,6 @@ using variations::VariationsIdsProvider; ...@@ -47,8 +47,6 @@ using variations::VariationsIdsProvider;
} }
- (void)locationBarDidResignFirstResponder { - (void)locationBarDidResignFirstResponder {
} }
- (void)locationBarBeganEdit {
}
- (LocationBarModel*)locationBarModel { - (LocationBarModel*)locationBarModel {
if (!_model) { if (!_model) {
......
...@@ -17,7 +17,6 @@ class WebState; ...@@ -17,7 +17,6 @@ class WebState;
@protocol LocationBarDelegate @protocol LocationBarDelegate
- (void)locationBarHasBecomeFirstResponder; - (void)locationBarHasBecomeFirstResponder;
- (void)locationBarHasResignedFirstResponder; - (void)locationBarHasResignedFirstResponder;
- (void)locationBarBeganEdit;
- (web::WebState*)webState; - (web::WebState*)webState;
- (LocationBarModel*)locationBarModel; - (LocationBarModel*)locationBarModel;
@end @end
......
...@@ -38,7 +38,6 @@ class WebOmniboxEditControllerImpl : public WebOmniboxEditController { ...@@ -38,7 +38,6 @@ class WebOmniboxEditControllerImpl : public WebOmniboxEditController {
AutocompleteMatchType::Type match_type, AutocompleteMatchType::Type match_type,
base::TimeTicks match_selection_timestamp, base::TimeTicks match_selection_timestamp,
bool destination_url_entered_without_scheme) override; bool destination_url_entered_without_scheme) override;
void OnInputInProgress(bool in_progress) override;
void OnChanged() override; void OnChanged() override;
LocationBarModel* GetLocationBarModel() override; LocationBarModel* GetLocationBarModel() override;
const LocationBarModel* GetLocationBarModel() const override; const LocationBarModel* GetLocationBarModel() const override;
......
...@@ -53,12 +53,6 @@ void WebOmniboxEditControllerImpl::OnAutocompleteAccept( ...@@ -53,12 +53,6 @@ void WebOmniboxEditControllerImpl::OnAutocompleteAccept(
} }
} }
void WebOmniboxEditControllerImpl::OnInputInProgress(bool in_progress) {
// TODO(crbug.com/818649): see if this is really used.
if (in_progress)
[delegate_ locationBarBeganEdit];
}
void WebOmniboxEditControllerImpl::OnChanged() { void WebOmniboxEditControllerImpl::OnChanged() {
// Called when anything is changed. Since the Mediator already observes the // Called when anything is changed. Since the Mediator already observes the
// WebState for security status changes, no need to do anything. // WebState for security status changes, no need to do anything.
......
...@@ -17,8 +17,6 @@ class LocationBarModel; ...@@ -17,8 +17,6 @@ class LocationBarModel;
- (void)locationBarDidBecomeFirstResponder; - (void)locationBarDidBecomeFirstResponder;
// Called when the location bar loses keyboard focus. // Called when the location bar loses keyboard focus.
- (void)locationBarDidResignFirstResponder; - (void)locationBarDidResignFirstResponder;
// Called when the location bar receives a key press.
- (void)locationBarBeganEdit;
// Returns the location bar model. // Returns the location bar model.
- (LocationBarModel*)locationBarModel; - (LocationBarModel*)locationBarModel;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment