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

Unified Diff: ios/web/web_state/ui/web_view_js_utils.mm

Issue 2281803002: [ios] Removed deprecated JS execution API. (Closed)
Patch Set: Merged with master Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/ui/web_view_js_utils.h ('k') | ios/web/web_state/ui/web_view_js_utils_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/web_view_js_utils.mm
diff --git a/ios/web/web_state/ui/web_view_js_utils.mm b/ios/web/web_state/ui/web_view_js_utils.mm
index 78ce1d861694ff252cc6eaa73f6282b25d8e678e..77817a1f0176d12abcd8c32d0ba8760a0764672f 100644
--- a/ios/web/web_state/ui/web_view_js_utils.mm
+++ b/ios/web/web_state/ui/web_view_js_utils.mm
@@ -13,33 +13,6 @@
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
-namespace {
-
-// Converts result of WKWebView script evaluation to a string.
-NSString* StringResultFromWKResult(id result) {
- if (!result)
- return @"";
-
- CFTypeID result_type = CFGetTypeID(result);
- if (result_type == CFStringGetTypeID())
- return result;
-
- if (result_type == CFNumberGetTypeID())
- return [result stringValue];
-
- if (result_type == CFBooleanGetTypeID())
- return [result boolValue] ? @"true" : @"false";
-
- if (result_type == CFNullGetTypeID())
- return @"";
-
- // TODO(stuartmorgan): Stringify other types.
- NOTREACHED();
- return nil;
-}
-
-} // namespace
-
namespace web {
NSString* const kJSEvaluationErrorDomain = @"JSEvaluationError";
@@ -79,23 +52,6 @@ std::unique_ptr<base::Value> ValueResultFromWKResult(id wk_result) {
return result;
}
-void EvaluateJavaScript(WKWebView* web_view,
- NSString* script,
- JavaScriptCompletion completion_handler) {
- void (^web_view_completion_handler)(id, NSError*) = nil;
- // Do not create a web_view_completion_handler if no |completion_handler| is
- // passed to this function. WKWebView guarantees to call all completion
- // handlers before deallocation. Passing nil as completion handler (when
- // appropriate) may speed up web view deallocation, because there will be no
- // need to call those completion handlers.
- if (completion_handler) {
- web_view_completion_handler = ^(id result, NSError* error) {
- completion_handler(StringResultFromWKResult(result), error);
- };
- }
- ExecuteJavaScript(web_view, script, web_view_completion_handler);
-}
-
void ExecuteJavaScript(WKWebView* web_view,
NSString* script,
JavaScriptResultBlock completion_handler) {
« no previous file with comments | « ios/web/web_state/ui/web_view_js_utils.h ('k') | ios/web/web_state/ui/web_view_js_utils_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698