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

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

Issue 2524383002: [ObjC ARC] Converts ios/chrome/browser/find_in_page:find_in_page to ARC.Automatically generated A… (Closed)
Patch Set: Created 4 years 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 #import "base/ios/weak_nsobject.h" 10 #import "base/ios/weak_nsobject.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/json/string_escape.h" 12 #include "base/json/string_escape.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #import "ios/chrome/browser/find_in_page/find_in_page_model.h" 17 #import "ios/chrome/browser/find_in_page/find_in_page_model.h"
18 18
19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support."
21 #endif
22
19 namespace { 23 namespace {
20 24
21 // Initializes Find In Page JavaScript with the width and height of the window. 25 // Initializes Find In Page JavaScript with the width and height of the window.
22 NSString* const kFindInPageInit = @"window.__gCrWeb.findInPage && " 26 NSString* const kFindInPageInit = @"window.__gCrWeb.findInPage && "
23 "window.__gCrWeb.findInPage.init(%.f, %.f);"; 27 "window.__gCrWeb.findInPage.init(%.f, %.f);";
24 28
25 // This will only do verbatim matches. 29 // This will only do verbatim matches.
26 // The timeout of 100ms is hardcoded into this string so we don't have 30 // The timeout of 100ms is hardcoded into this string so we don't have
27 // to spend any time at runtime to format this constant into another constant. 31 // to spend any time at runtime to format this constant into another constant.
28 NSString* const kFindInPageVerbatim = 32 NSString* const kFindInPageVerbatim =
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 [self moveHighlightByEvaluatingJavaScript:kFindInPagePrev 134 [self moveHighlightByEvaluatingJavaScript:kFindInPagePrev
131 completionHandler:completionHandler]; 135 completionHandler:completionHandler];
132 } 136 }
133 137
134 - (void)moveHighlightByEvaluatingJavaScript:(NSString*)script 138 - (void)moveHighlightByEvaluatingJavaScript:(NSString*)script
135 completionHandler: 139 completionHandler:
136 (void (^)(CGPoint))completionHandler { 140 (void (^)(CGPoint))completionHandler {
137 base::WeakNSObject<JsFindinpageManager> weakSelf(self); 141 base::WeakNSObject<JsFindinpageManager> weakSelf(self);
138 [self executeJavaScript:script 142 [self executeJavaScript:script
139 completionHandler:^(id result, NSError* error) { 143 completionHandler:^(id result, NSError* error) {
140 base::WeakNSObject<JsFindinpageManager> strongSelf([weakSelf retain]); 144 base::WeakNSObject<JsFindinpageManager> strongSelf(weakSelf);
noyau (Ping after 24h) 2016/11/25 10:27:46 Hu? A supposed "strongSelf" stored in a Weak? This
stkhapugin 2016/11/25 11:23:04 This is the coolest catch!
141 if (!strongSelf) 145 if (!strongSelf)
142 return; 146 return;
143 DCHECK(!error); 147 DCHECK(!error);
144 FindInPageEntry entry = kFindInPageEntryZero; 148 FindInPageEntry entry = kFindInPageEntryZero;
145 if (![result isEqual:kFindInPagePending]) { 149 if (![result isEqual:kFindInPagePending]) {
146 NSString* stringResult = 150 NSString* stringResult =
147 base::mac::ObjCCastStrict<NSString>(result); 151 base::mac::ObjCCastStrict<NSString>(result);
148 entry = [strongSelf findInPageEntryForJson:stringResult]; 152 entry = [strongSelf findInPageEntryForJson:stringResult];
149 } 153 }
150 CGPoint newPoint = entry.point; 154 CGPoint newPoint = entry.point;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 259 }
256 260
257 #pragma mark - 261 #pragma mark -
258 #pragma mark ProtectedMethods 262 #pragma mark ProtectedMethods
259 263
260 - (NSString*)scriptPath { 264 - (NSString*)scriptPath {
261 return @"find_in_page"; 265 return @"find_in_page";
262 } 266 }
263 267
264 @end 268 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698