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

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

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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 <string> 8 #include <string>
8 9
9 #import "base/ios/weak_nsobject.h" 10 #import "base/ios/weak_nsobject.h"
10 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
11 #include "base/json/string_escape.h" 12 #include "base/json/string_escape.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #import "ios/chrome/browser/find_in_page/find_in_page_model.h" 16 #import "ios/chrome/browser/find_in_page/find_in_page_model.h"
17 17
18 namespace { 18 namespace {
19 19
20 // Global variable defined in find_in_page.js that can be used for testing 20 // Global variable defined in find_in_page.js that can be used for testing
21 // whether JavaScript bas heen loaded. 21 // whether JavaScript bas heen loaded.
22 NSString* const kFindInPageBeacon = @"window.__gCrWeb.findInPage"; 22 NSString* const kFindInPageBeacon = @"window.__gCrWeb.findInPage";
23 23
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 #pragma mark - 166 #pragma mark -
167 #pragma mark FindInPageEntry 167 #pragma mark FindInPageEntry
168 168
169 - (BOOL)processFindInPageResult:(NSString*)result 169 - (BOOL)processFindInPageResult:(NSString*)result
170 scrollPosition:(CGPoint*)point { 170 scrollPosition:(CGPoint*)point {
171 if (!result) 171 if (!result)
172 return NO; 172 return NO;
173 173
174 // Parse JSONs. 174 // Parse JSONs.
175 std::string json([result UTF8String]); 175 std::string json([result UTF8String]);
176 scoped_ptr<base::Value> root(base::JSONReader::Read(json, false)); 176 std::unique_ptr<base::Value> root(base::JSONReader::Read(json, false));
177 if (!root.get()) 177 if (!root.get())
178 return YES; 178 return YES;
179 if (!root->IsType(base::Value::TYPE_LIST)) 179 if (!root->IsType(base::Value::TYPE_LIST))
180 return YES; 180 return YES;
181 181
182 base::ListValue* resultList = static_cast<base::ListValue*>(root.get()); 182 base::ListValue* resultList = static_cast<base::ListValue*>(root.get());
183 DCHECK(resultList); 183 DCHECK(resultList);
184 if (resultList) { 184 if (resultList) {
185 if (resultList->GetSize() == 2) { 185 if (resultList->GetSize() == 2) {
186 int numHighlighted = 0; 186 int numHighlighted = 0;
(...skipping 27 matching lines...) Expand all
214 [self processFindInPageResult:result scrollPosition:&point]; 214 [self processFindInPageResult:result scrollPosition:&point];
215 completionHandler(processFIPResult, point); 215 completionHandler(processFIPResult, point);
216 } 216 }
217 217
218 - (void)updateIndex:(NSInteger)index atPoint:(CGPoint)point { 218 - (void)updateIndex:(NSInteger)index atPoint:(CGPoint)point {
219 [findInPageModel_ updateIndex:index atPoint:point]; 219 [findInPageModel_ updateIndex:index atPoint:point];
220 } 220 }
221 221
222 - (FindInPageEntry)findInPageEntryForJson:(NSString*)jsonStr { 222 - (FindInPageEntry)findInPageEntryForJson:(NSString*)jsonStr {
223 std::string json([jsonStr UTF8String]); 223 std::string json([jsonStr UTF8String]);
224 scoped_ptr<base::Value> root(base::JSONReader::Read(json, false)); 224 std::unique_ptr<base::Value> root(base::JSONReader::Read(json, false));
225 if (!root.get()) 225 if (!root.get())
226 return kFindInPageEntryZero; 226 return kFindInPageEntryZero;
227 227
228 if (!root->IsType(base::Value::TYPE_LIST)) 228 if (!root->IsType(base::Value::TYPE_LIST))
229 return kFindInPageEntryZero; 229 return kFindInPageEntryZero;
230 230
231 base::ListValue* position = static_cast<base::ListValue*>(root.get()); 231 base::ListValue* position = static_cast<base::ListValue*>(root.get());
232 return [self entryForListValue:position]; 232 return [self entryForListValue:position];
233 } 233 }
234 234
(...skipping 27 matching lines...) Expand all
262 262
263 - (NSString*)scriptPath { 263 - (NSString*)scriptPath {
264 return @"find_in_page"; 264 return @"find_in_page";
265 } 265 }
266 266
267 - (NSString*)presenceBeacon { 267 - (NSString*)presenceBeacon {
268 return kFindInPageBeacon; 268 return kFindInPageBeacon;
269 } 269 }
270 270
271 @end 271 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698