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

Side by Side Diff: ios/clean/chrome/browser/ui/find_in_page/find_in_page_mediator.mm

Issue 2904053002: [ios] Active web state observer in tab collection. (Closed)
Patch Set: Update unittest Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/clean/chrome/browser/ui/find_in_page/find_in_page_mediator.h" 5 #import "ios/clean/chrome/browser/ui/find_in_page/find_in_page_mediator.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/scoped_observer.h" 8 #include "base/scoped_observer.h"
9 #import "ios/chrome/browser/find_in_page/find_in_page_model.h" 9 #import "ios/chrome/browser/find_in_page/find_in_page_model.h"
10 #import "ios/chrome/browser/find_in_page/find_tab_helper.h" 10 #import "ios/chrome/browser/find_in_page/find_tab_helper.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 _scopedWebStateListObserver = base::MakeUnique< 65 _scopedWebStateListObserver = base::MakeUnique<
66 ScopedObserver<WebStateList, WebStateListObserverBridge>>( 66 ScopedObserver<WebStateList, WebStateListObserverBridge>>(
67 _webStateListObserver.get()); 67 _webStateListObserver.get());
68 _scopedWebStateListObserver->Add(_webStateList); 68 _scopedWebStateListObserver->Add(_webStateList);
69 } 69 }
70 return self; 70 return self;
71 } 71 }
72 72
73 - (void)stopFinding { 73 - (void)stopFinding {
74 web::WebState* webState = self.webStateList->GetActiveWebState(); 74 web::WebState* webState = self.webStateList->GetActiveWebState();
75 FindTabHelper* helper = FindTabHelper::FromWebState(webState); 75 if (webState) {
76 DCHECK(helper); 76 FindTabHelper* helper = FindTabHelper::FromWebState(webState);
77 helper->StopFinding(nil); 77 DCHECK(helper);
78 helper->StopFinding(nil);
79 }
78 } 80 }
79 81
80 - (void)findResultsAvailable:(FindInPageModel*)model { 82 - (void)findResultsAvailable:(FindInPageModel*)model {
81 id<FindInPageConsumer> consumer = self.provider.consumer; 83 id<FindInPageConsumer> consumer = self.provider.consumer;
82 [consumer setCurrentMatch:model.currentIndex ofTotalMatches:model.matches]; 84 [consumer setCurrentMatch:model.currentIndex ofTotalMatches:model.matches];
83 } 85 }
84 86
85 - (void)webStateList:(WebStateList*)webStateList 87 - (void)webStateList:(WebStateList*)webStateList
86 didChangeActiveWebState:(web::WebState*)newWebState 88 didChangeActiveWebState:(web::WebState*)newWebState
87 oldWebState:(web::WebState*)oldWebState 89 oldWebState:(web::WebState*)oldWebState
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 - (void)findPreviousInPage { 129 - (void)findPreviousInPage {
128 web::WebState* webState = self.webStateList->GetActiveWebState(); 130 web::WebState* webState = self.webStateList->GetActiveWebState();
129 FindTabHelper* helper = FindTabHelper::FromWebState(webState); 131 FindTabHelper* helper = FindTabHelper::FromWebState(webState);
130 DCHECK(helper); 132 DCHECK(helper);
131 helper->ContinueFinding(FindTabHelper::REVERSE, ^(FindInPageModel* model) { 133 helper->ContinueFinding(FindTabHelper::REVERSE, ^(FindInPageModel* model) {
132 [self findResultsAvailable:model]; 134 [self findResultsAvailable:model];
133 }); 135 });
134 } 136 }
135 137
136 @end 138 @end
OLDNEW
« no previous file with comments | « no previous file | ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698