Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Unified Diff: ios/chrome/browser/find_in_page/find_tab_helper.mm

Issue 2654433007: [ios] Moves find-in-page code out of Tab and into FindTabHelper. (Closed)
Patch Set: Null checks Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..7dfb527a5df5ee0bf650458f3581ea8ab98d4565
--- /dev/null
+++ b/ios/chrome/browser/find_in_page/find_tab_helper.mm
@@ -0,0 +1,42 @@
+// 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"
+
Eugene But (OOO till 7-30) 2017/01/31 19:03:48 Please add ARC ifdefs
rohitrao (ping after 24h) 2017/02/08 16:14:59 Done.
+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(),
+ new FindTabHelper(web_state, controller_delegate));
+}
+
+FindTabHelper::FindTabHelper(
+ web::WebState* web_state,
+ id<FindInPageControllerDelegate> controller_delegate)
+ : web_state_(web_state) {
+ controller_ =
+ [[FindInPageController alloc] initWithWebState:web_state
+ delegate:controller_delegate];
+}
+
+FindTabHelper::~FindTabHelper() {
+ [controller_ detachFromWebState];
Eugene But (OOO till 7-30) 2017/01/31 19:03:48 We should probably do this in |WebStateDestroyed|
rohitrao (ping after 24h) 2017/02/08 16:14:59 Done.
+ web_state_ = nullptr;
+}
+
+FindInPageController* FindTabHelper::GetController() {
+ return controller_;
+}
+
+void FindTabHelper::NavigationItemCommitted(
+ const web::LoadCommittedDetails& load_details) {
+ [controller_ disableFindInPageWithCompletionHandler:nil];
+}

Powered by Google App Engine
This is Rietveld 408576698