Commit 3c6103ec authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Remove FindInPageControllerDelegate.

This is no longer necessary, as the new fullscreen implementation
already ignored scrolls originating from fullscreen.

Bug: 810896
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I6da22780ef46f5866e698e967e6b3c62e4b2148c
Reviewed-on: https://chromium-review.googlesource.com/912428
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#535907}
parent 8ac10d7a
...@@ -18,20 +18,13 @@ class WebState; ...@@ -18,20 +18,13 @@ class WebState;
extern NSString* const kFindBarTextFieldWillBecomeFirstResponderNotification; extern NSString* const kFindBarTextFieldWillBecomeFirstResponderNotification;
extern NSString* const kFindBarTextFieldDidResignFirstResponderNotification; extern NSString* const kFindBarTextFieldDidResignFirstResponderNotification;
@protocol FindInPageControllerDelegate<NSObject>
// Informs the delegate when the scroll position is about to be changed on the
// page.
- (void)willAdjustScrollPosition;
@end
@interface FindInPageController : NSObject @interface FindInPageController : NSObject
// Find In Page model. // Find In Page model.
@property(nonatomic, readonly, strong) FindInPageModel* findInPageModel; @property(nonatomic, readonly, strong) FindInPageModel* findInPageModel;
// Designated initializer. // Designated initializer.
- (id)initWithWebState:(web::WebState*)webState - (id)initWithWebState:(web::WebState*)webState;
delegate:(id<FindInPageControllerDelegate>)delegate;
// Inject the find in page scripts into the web state. // Inject the find in page scripts into the web state.
- (void)initFindInPage; - (void)initFindInPage;
// Is Find In Page available right now (given the state of the WebState)? // Is Find In Page available right now (given the state of the WebState)?
......
...@@ -39,8 +39,6 @@ static NSString* gSearchTerm; ...@@ -39,8 +39,6 @@ static NSString* gSearchTerm;
} }
@interface FindInPageController () <DOMAltering, CRWWebStateObserver> @interface FindInPageController () <DOMAltering, CRWWebStateObserver>
// The find in page controller delegate. Can be nil.
@property(nonatomic, readonly) id<FindInPageControllerDelegate> delegate;
// The web view's scroll view. // The web view's scroll view.
- (CRWWebViewScrollViewProxy*)webViewScrollView; - (CRWWebViewScrollViewProxy*)webViewScrollView;
...@@ -73,7 +71,6 @@ static NSString* gSearchTerm; ...@@ -73,7 +71,6 @@ static NSString* gSearchTerm;
@implementation FindInPageController { @implementation FindInPageController {
// Object that manages find_in_page.js injection into the web view. // Object that manages find_in_page.js injection into the web view.
__weak JsFindinpageManager* _findInPageJsManager; __weak JsFindinpageManager* _findInPageJsManager;
__weak id<FindInPageControllerDelegate> _delegate;
// Access to the web view from the web state. // Access to the web view from the web state.
id<CRWWebViewProxy> _webViewProxy; id<CRWWebViewProxy> _webViewProxy;
...@@ -90,7 +87,6 @@ static NSString* gSearchTerm; ...@@ -90,7 +87,6 @@ static NSString* gSearchTerm;
std::unique_ptr<web::WebStateObserverBridge> _webStateObserverBridge; std::unique_ptr<web::WebStateObserverBridge> _webStateObserverBridge;
} }
@synthesize delegate = _delegate;
@synthesize findInPageModel = _findInPageModel; @synthesize findInPageModel = _findInPageModel;
+ (void)setSearchTerm:(NSString*)string { + (void)setSearchTerm:(NSString*)string {
...@@ -101,8 +97,7 @@ static NSString* gSearchTerm; ...@@ -101,8 +97,7 @@ static NSString* gSearchTerm;
return gSearchTerm; return gSearchTerm;
} }
- (id)initWithWebState:(web::WebState*)webState - (id)initWithWebState:(web::WebState*)webState {
delegate:(id<FindInPageControllerDelegate>)delegate {
self = [super init]; self = [super init];
if (self) { if (self) {
DCHECK(webState); DCHECK(webState);
...@@ -112,7 +107,6 @@ static NSString* gSearchTerm; ...@@ -112,7 +107,6 @@ static NSString* gSearchTerm;
[_webState->GetJSInjectionReceiver() [_webState->GetJSInjectionReceiver()
instanceOfClass:[JsFindinpageManager class]]); instanceOfClass:[JsFindinpageManager class]]);
_findInPageJsManager.findInPageModel = _findInPageModel; _findInPageJsManager.findInPageModel = _findInPageModel;
_delegate = delegate;
_webStateObserverBridge = _webStateObserverBridge =
std::make_unique<web::WebStateObserverBridge>(self); std::make_unique<web::WebStateObserverBridge>(self);
_webState->AddObserver(_webStateObserverBridge.get()); _webState->AddObserver(_webStateObserverBridge.get());
...@@ -171,7 +165,6 @@ static NSString* gSearchTerm; ...@@ -171,7 +165,6 @@ static NSString* gSearchTerm;
scrollPoint:(CGPoint)scrollPoint scrollPoint:(CGPoint)scrollPoint
completionHandler:(ProceduralBlock)completionHandler { completionHandler:(ProceduralBlock)completionHandler {
if (finished) { if (finished) {
[_delegate willAdjustScrollPosition];
scrollPoint = [self limitOverscroll:[_webViewProxy scrollViewProxy] scrollPoint = [self limitOverscroll:[_webViewProxy scrollViewProxy]
atPoint:scrollPoint]; atPoint:scrollPoint];
[[_webViewProxy scrollViewProxy] setContentOffset:scrollPoint animated:YES]; [[_webViewProxy scrollViewProxy] setContentOffset:scrollPoint animated:YES];
...@@ -234,7 +227,6 @@ static NSString* gSearchTerm; ...@@ -234,7 +227,6 @@ static NSString* gSearchTerm;
CGPoint point) { CGPoint point) {
FindInPageController* strongSelf = weakSelf; FindInPageController* strongSelf = weakSelf;
if (finished) { if (finished) {
[[strongSelf delegate] willAdjustScrollPosition];
point = [strongSelf limitOverscroll:[strongSelf webViewScrollView] point = [strongSelf limitOverscroll:[strongSelf webViewScrollView]
atPoint:point]; atPoint:point];
[[strongSelf webViewScrollView] setContentOffset:point animated:YES]; [[strongSelf webViewScrollView] setContentOffset:point animated:YES];
...@@ -249,7 +241,6 @@ static NSString* gSearchTerm; ...@@ -249,7 +241,6 @@ static NSString* gSearchTerm;
__weak FindInPageController* weakSelf = self; __weak FindInPageController* weakSelf = self;
[_findInPageJsManager nextMatchWithCompletionHandler:^(CGPoint point) { [_findInPageJsManager nextMatchWithCompletionHandler:^(CGPoint point) {
FindInPageController* strongSelf = weakSelf; FindInPageController* strongSelf = weakSelf;
[[strongSelf delegate] willAdjustScrollPosition];
point = [strongSelf limitOverscroll:[strongSelf webViewScrollView] point = [strongSelf limitOverscroll:[strongSelf webViewScrollView]
atPoint:point]; atPoint:point];
[[strongSelf webViewScrollView] setContentOffset:point animated:YES]; [[strongSelf webViewScrollView] setContentOffset:point animated:YES];
...@@ -265,7 +256,6 @@ static NSString* gSearchTerm; ...@@ -265,7 +256,6 @@ static NSString* gSearchTerm;
__weak FindInPageController* weakSelf = self; __weak FindInPageController* weakSelf = self;
[_findInPageJsManager previousMatchWithCompletionHandler:^(CGPoint point) { [_findInPageJsManager previousMatchWithCompletionHandler:^(CGPoint point) {
FindInPageController* strongSelf = weakSelf; FindInPageController* strongSelf = weakSelf;
[[strongSelf delegate] willAdjustScrollPosition];
point = [strongSelf limitOverscroll:[strongSelf webViewScrollView] point = [strongSelf limitOverscroll:[strongSelf webViewScrollView]
atPoint:point]; atPoint:point];
[[strongSelf webViewScrollView] setContentOffset:point animated:YES]; [[strongSelf webViewScrollView] setContentOffset:point animated:YES];
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#import "ios/web/public/web_state/web_state_user_data.h" #import "ios/web/public/web_state/web_state_user_data.h"
@class FindInPageController; @class FindInPageController;
@protocol FindInPageControllerDelegate;
@class FindInPageModel; @class FindInPageModel;
typedef void (^FindInPageCompletionBlock)(FindInPageModel*); typedef void (^FindInPageCompletionBlock)(FindInPageModel*);
...@@ -29,12 +28,6 @@ class FindTabHelper : public web::WebStateObserver, ...@@ -29,12 +28,6 @@ class FindTabHelper : public web::WebStateObserver,
REVERSE, REVERSE,
}; };
// Creates a FindTabHelper and attaches it to the given |web_state|.
// |controller_delegate| can be nil.
static void CreateForWebState(
web::WebState* web_state,
id<FindInPageControllerDelegate> controller_delegate);
// Starts an asynchronous Find operation that will call the given completion // Starts an asynchronous Find operation that will call the given completion
// handler with results. Highlights matches on the current page. Always // handler with results. Highlights matches on the current page. Always
// searches in the FORWARD direction. // searches in the FORWARD direction.
...@@ -73,9 +66,10 @@ class FindTabHelper : public web::WebStateObserver, ...@@ -73,9 +66,10 @@ class FindTabHelper : public web::WebStateObserver,
private: private:
friend class FindTabHelperTest; friend class FindTabHelperTest;
friend class web::WebStateUserData<FindTabHelper>;
FindTabHelper(web::WebState* web_state, // Private constructor used by CreateForWebState().
id<FindInPageControllerDelegate> controller_delegate); FindTabHelper(web::WebState* web_state);
// web::WebStateObserver. // web::WebStateObserver.
void NavigationItemCommitted( void NavigationItemCommitted(
......
...@@ -14,24 +14,9 @@ ...@@ -14,24 +14,9 @@
DEFINE_WEB_STATE_USER_DATA_KEY(FindTabHelper); DEFINE_WEB_STATE_USER_DATA_KEY(FindTabHelper);
// static FindTabHelper::FindTabHelper(web::WebState* web_state) {
void FindTabHelper::CreateForWebState(
web::WebState* web_state,
id<FindInPageControllerDelegate> controller_delegate) {
DCHECK(web_state);
if (!FromWebState(web_state)) {
web_state->SetUserData(UserDataKey(), base::WrapUnique(new FindTabHelper(
web_state, controller_delegate)));
}
}
FindTabHelper::FindTabHelper(
web::WebState* web_state,
id<FindInPageControllerDelegate> controller_delegate) {
web_state->AddObserver(this); web_state->AddObserver(this);
controller_ = controller_ = [[FindInPageController alloc] initWithWebState:web_state];
[[FindInPageController alloc] initWithWebState:web_state
delegate:controller_delegate];
} }
FindTabHelper::~FindTabHelper() {} FindTabHelper::~FindTabHelper() {}
......
...@@ -29,7 +29,7 @@ class FindTabHelperTest : public ChromeWebTest { ...@@ -29,7 +29,7 @@ class FindTabHelperTest : public ChromeWebTest {
protected: protected:
void SetUp() override { void SetUp() override {
ChromeWebTest::SetUp(); ChromeWebTest::SetUp();
FindTabHelper::CreateForWebState(web_state(), nil); FindTabHelper::CreateForWebState(web_state());
} }
void TearDown() override { void TearDown() override {
......
...@@ -31,7 +31,6 @@ class GURL; ...@@ -31,7 +31,6 @@ class GURL;
@class Tab; @class Tab;
@protocol TabHeadersDelegate; @protocol TabHeadersDelegate;
@class TabModel; @class TabModel;
@protocol FindInPageControllerDelegate;
namespace ios { namespace ios {
class ChromeBrowserState; class ChromeBrowserState;
...@@ -98,8 +97,6 @@ extern NSString* const kProxyPassthroughHeaderValue; ...@@ -98,8 +97,6 @@ extern NSString* const kProxyPassthroughHeaderValue;
@property(nonatomic, readonly) BOOL canGoForward; @property(nonatomic, readonly) BOOL canGoForward;
@property(nonatomic, weak) id<TabDelegate> delegate; @property(nonatomic, weak) id<TabDelegate> delegate;
@property(nonatomic, weak) id<TabHeadersDelegate> tabHeadersDelegate; @property(nonatomic, weak) id<TabHeadersDelegate> tabHeadersDelegate;
@property(nonatomic, readonly) id<FindInPageControllerDelegate>
findInPageControllerDelegate;
@property(nonatomic, readonly) @property(nonatomic, readonly)
OverscrollActionsController* overscrollActionsController; OverscrollActionsController* overscrollActionsController;
......
...@@ -143,7 +143,7 @@ bool IsItemRedirectItem(web::NavigationItem* item) { ...@@ -143,7 +143,7 @@ bool IsItemRedirectItem(web::NavigationItem* item) {
} }
} // namespace } // namespace
@interface Tab ()<CRWWebStateObserver, FindInPageControllerDelegate> { @interface Tab ()<CRWWebStateObserver> {
__weak TabModel* _parentTabModel; __weak TabModel* _parentTabModel;
ios::ChromeBrowserState* _browserState; ios::ChromeBrowserState* _browserState;
...@@ -262,10 +262,6 @@ bool IsItemRedirectItem(web::NavigationItem* item) { ...@@ -262,10 +262,6 @@ bool IsItemRedirectItem(web::NavigationItem* item) {
return self.navigationManager && self.navigationManager->CanGoForward(); return self.navigationManager && self.navigationManager->CanGoForward();
} }
- (id<FindInPageControllerDelegate>)findInPageControllerDelegate {
return self;
}
- (void)setOverscrollActionsControllerDelegate: - (void)setOverscrollActionsControllerDelegate:
(id<OverscrollActionsControllerDelegate>) (id<OverscrollActionsControllerDelegate>)
overscrollActionsControllerDelegate { overscrollActionsControllerDelegate {
...@@ -464,11 +460,6 @@ bool IsItemRedirectItem(web::NavigationItem* item) { ...@@ -464,11 +460,6 @@ bool IsItemRedirectItem(web::NavigationItem* item) {
webState:self.webState]; webState:self.webState];
} }
#pragma mark - FindInPageControllerDelegate protocol
- (void)willAdjustScrollPosition {
}
#pragma mark - CRWWebStateObserver protocol #pragma mark - CRWWebStateObserver protocol
- (void)webState:(web::WebState*)webState - (void)webState:(web::WebState*)webState
......
...@@ -73,7 +73,7 @@ void AttachTabHelpers(web::WebState* web_state, bool for_prerender) { ...@@ -73,7 +73,7 @@ void AttachTabHelpers(web::WebState* web_state, bool for_prerender) {
InfoBarManagerImpl::CreateForWebState(web_state); InfoBarManagerImpl::CreateForWebState(web_state);
IOSSecurityStateTabHelper::CreateForWebState(web_state); IOSSecurityStateTabHelper::CreateForWebState(web_state);
BlockedPopupTabHelper::CreateForWebState(web_state); BlockedPopupTabHelper::CreateForWebState(web_state);
FindTabHelper::CreateForWebState(web_state, tab.findInPageControllerDelegate); FindTabHelper::CreateForWebState(web_state);
StoreKitTabHelper::CreateForWebState(web_state); StoreKitTabHelper::CreateForWebState(web_state);
HistoryTabHelper::CreateForWebState(web_state); HistoryTabHelper::CreateForWebState(web_state);
LoadTimingTabHelper::CreateForWebState(web_state); LoadTimingTabHelper::CreateForWebState(web_state);
......
...@@ -20,7 +20,7 @@ BrowserWebStateListDelegate::BrowserWebStateListDelegate() = default; ...@@ -20,7 +20,7 @@ BrowserWebStateListDelegate::BrowserWebStateListDelegate() = default;
BrowserWebStateListDelegate::~BrowserWebStateListDelegate() = default; BrowserWebStateListDelegate::~BrowserWebStateListDelegate() = default;
void BrowserWebStateListDelegate::WillAddWebState(web::WebState* web_state) { void BrowserWebStateListDelegate::WillAddWebState(web::WebState* web_state) {
FindTabHelper::CreateForWebState(web_state, nil); FindTabHelper::CreateForWebState(web_state);
SadTabTabHelper::CreateForWebState(web_state, nil); SadTabTabHelper::CreateForWebState(web_state, nil);
IOSChromeSessionTabHelper::CreateForWebState(web_state); IOSChromeSessionTabHelper::CreateForWebState(web_state);
IOSSecurityStateTabHelper::CreateForWebState(web_state); IOSSecurityStateTabHelper::CreateForWebState(web_state);
......
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