Chromium Code Reviews| Index: ios/chrome/browser/find_in_page/find_tab_helper.mm |
| diff --git a/ios/chrome/browser/find_in_page/find_tab_helper.mm b/ios/chrome/browser/find_in_page/find_tab_helper.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e4f7c26c5b6d3546b490b9a32dcc0c6ad92fb5ee |
| --- /dev/null |
| +++ b/ios/chrome/browser/find_in_page/find_tab_helper.mm |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/chrome/browser/find_in_page/find_tab_helper.h" |
| + |
| +#import "ios/chrome/browser/find_in_page/find_in_page_controller.h" |
| + |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +DEFINE_WEB_STATE_USER_DATA_KEY(FindTabHelper); |
| + |
| +// static |
| +void FindTabHelper::CreateForWebState( |
| + web::WebState* web_state, |
| + id<FindInPageControllerDelegate> controller_delegate) { |
| + DCHECK(web_state); |
| + if (!FromWebState(web_state)) |
| + web_state->SetUserData(UserDataKey(), |
|
Eugene But (OOO till 7-30)
2017/02/10 00:03:36
nit: do you want to add braces, because block is m
sdefresne
2017/02/10 09:39:51
Even though the style guide does not enforce this,
rohitrao (ping after 24h)
2017/02/10 13:52:18
I prefer braces for all conditionals, thanks =)
|
| + new FindTabHelper(web_state, controller_delegate)); |
| +} |
| + |
| +FindTabHelper::FindTabHelper( |
| + web::WebState* web_state, |
| + id<FindInPageControllerDelegate> controller_delegate) { |
| + controller_ = |
| + [[FindInPageController alloc] initWithWebState:web_state |
| + delegate:controller_delegate]; |
| +} |
| + |
| +FindTabHelper::~FindTabHelper() {} |
| + |
| +FindInPageController* FindTabHelper::GetController() { |
| + return controller_; |
| +} |
| + |
| +void FindTabHelper::NavigationItemCommitted( |
| + const web::LoadCommittedDetails& load_details) { |
| + [controller_ disableFindInPageWithCompletionHandler:nil]; |
| +} |
| + |
| +void FindTabHelper::WebStateDestroyed() { |
| + [controller_ detachFromWebState]; |
| +} |