OLD | NEW |
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 - (BOOL)processFindInPageResult:(id)result scrollPosition:(CGPoint*)point { | 171 - (BOOL)processFindInPageResult:(id)result scrollPosition:(CGPoint*)point { |
172 if (!result) | 172 if (!result) |
173 return NO; | 173 return NO; |
174 | 174 |
175 // Parse JSONs. | 175 // Parse JSONs. |
176 std::string json([result UTF8String]); | 176 std::string json([result UTF8String]); |
177 std::unique_ptr<base::Value> root(base::JSONReader::Read(json, false)); | 177 std::unique_ptr<base::Value> root(base::JSONReader::Read(json, false)); |
178 if (!root.get()) | 178 if (!root.get()) |
179 return YES; | 179 return YES; |
180 if (!root->IsType(base::Value::TYPE_LIST)) | 180 if (!root->IsType(base::Value::Type::LIST)) |
181 return YES; | 181 return YES; |
182 | 182 |
183 base::ListValue* resultList = static_cast<base::ListValue*>(root.get()); | 183 base::ListValue* resultList = static_cast<base::ListValue*>(root.get()); |
184 DCHECK(resultList); | 184 DCHECK(resultList); |
185 if (resultList) { | 185 if (resultList) { |
186 if (resultList->GetSize() == 2) { | 186 if (resultList->GetSize() == 2) { |
187 int numHighlighted = 0; | 187 int numHighlighted = 0; |
188 if (resultList->GetInteger(0, &numHighlighted)) { | 188 if (resultList->GetInteger(0, &numHighlighted)) { |
189 if (numHighlighted > 0) { | 189 if (numHighlighted > 0) { |
190 base::ListValue* position; | 190 base::ListValue* position; |
(...skipping 28 matching lines...) Expand all Loading... |
219 - (void)updateIndex:(NSInteger)index atPoint:(CGPoint)point { | 219 - (void)updateIndex:(NSInteger)index atPoint:(CGPoint)point { |
220 [self.findInPageModel updateIndex:index atPoint:point]; | 220 [self.findInPageModel updateIndex:index atPoint:point]; |
221 } | 221 } |
222 | 222 |
223 - (FindInPageEntry)findInPageEntryForJson:(NSString*)jsonStr { | 223 - (FindInPageEntry)findInPageEntryForJson:(NSString*)jsonStr { |
224 std::string json([jsonStr UTF8String]); | 224 std::string json([jsonStr UTF8String]); |
225 std::unique_ptr<base::Value> root(base::JSONReader::Read(json, false)); | 225 std::unique_ptr<base::Value> root(base::JSONReader::Read(json, false)); |
226 if (!root.get()) | 226 if (!root.get()) |
227 return kFindInPageEntryZero; | 227 return kFindInPageEntryZero; |
228 | 228 |
229 if (!root->IsType(base::Value::TYPE_LIST)) | 229 if (!root->IsType(base::Value::Type::LIST)) |
230 return kFindInPageEntryZero; | 230 return kFindInPageEntryZero; |
231 | 231 |
232 base::ListValue* position = static_cast<base::ListValue*>(root.get()); | 232 base::ListValue* position = static_cast<base::ListValue*>(root.get()); |
233 return [self entryForListValue:position]; | 233 return [self entryForListValue:position]; |
234 } | 234 } |
235 | 235 |
236 - (FindInPageEntry)entryForListValue:(base::ListValue*)position { | 236 - (FindInPageEntry)entryForListValue:(base::ListValue*)position { |
237 if (!position) | 237 if (!position) |
238 return kFindInPageEntryZero; | 238 return kFindInPageEntryZero; |
239 | 239 |
(...skipping 19 matching lines...) Expand all Loading... |
259 } | 259 } |
260 | 260 |
261 #pragma mark - | 261 #pragma mark - |
262 #pragma mark ProtectedMethods | 262 #pragma mark ProtectedMethods |
263 | 263 |
264 - (NSString*)scriptPath { | 264 - (NSString*)scriptPath { |
265 return @"find_in_page"; | 265 return @"find_in_page"; |
266 } | 266 } |
267 | 267 |
268 @end | 268 @end |
OLD | NEW |