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

Side by Side Diff: ios/chrome/browser/find_in_page/js_findinpage_manager.mm

Issue 2685393004: [ios] Hoists the FindInPageModel up into the controller. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/chrome/browser/find_in_page/js_findinpage_manager.h" 5 #import "ios/chrome/browser/find_in_page/js_findinpage_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 - (void)moveHighlightByEvaluatingJavaScript:(NSString*)script 73 - (void)moveHighlightByEvaluatingJavaScript:(NSString*)script
74 completionHandler: 74 completionHandler:
75 (void (^)(CGPoint))completionHandler; 75 (void (^)(CGPoint))completionHandler;
76 // Updates the current match index and its found position in the model. 76 // Updates the current match index and its found position in the model.
77 - (void)updateIndex:(NSInteger)index atPoint:(CGPoint)point; 77 - (void)updateIndex:(NSInteger)index atPoint:(CGPoint)point;
78 @end 78 @end
79 79
80 @implementation JsFindinpageManager 80 @implementation JsFindinpageManager
81 @synthesize findInPageModel = _findInPageModel; 81 @synthesize findInPageModel = _findInPageModel;
82 82
83 - (FindInPageModel*)findInPageModel {
84 if (!_findInPageModel)
85 _findInPageModel = [[FindInPageModel alloc] init];
86 return _findInPageModel;
87 }
88
89 - (void)setWidth:(CGFloat)width height:(CGFloat)height { 83 - (void)setWidth:(CGFloat)width height:(CGFloat)height {
90 NSString* javaScript = 84 NSString* javaScript =
91 [NSString stringWithFormat:kFindInPageInit, width, height]; 85 [NSString stringWithFormat:kFindInPageInit, width, height];
92 [self executeJavaScript:javaScript completionHandler:nil]; 86 [self executeJavaScript:javaScript completionHandler:nil];
93 } 87 }
94 88
95 - (void)findString:(NSString*)query 89 - (void)findString:(NSString*)query
96 completionHandler:(void (^)(BOOL, CGPoint))completionHandler { 90 completionHandler:(void (^)(BOOL, CGPoint))completionHandler {
97 DCHECK(completionHandler); 91 DCHECK(completionHandler);
98 // Save the query in the model before searching. 92 // Save the query in the model before searching.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 253 }
260 254
261 #pragma mark - 255 #pragma mark -
262 #pragma mark ProtectedMethods 256 #pragma mark ProtectedMethods
263 257
264 - (NSString*)scriptPath { 258 - (NSString*)scriptPath {
265 return @"find_in_page"; 259 return @"find_in_page";
266 } 260 }
267 261
268 @end 262 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698