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

Side by Side Diff: ios/web_view/internal/web_view_early_page_script_provider.mm

Issue 2764773002: Add CWVUserContentController which enables injecting JavaScripts. (Closed)
Patch Set: Add license. Created 3 years, 9 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ios/web_view/internal/web_view_early_page_script_provider.h"
6
7 #import <Foundation/Foundation.h>
8
9 #include "ios/web/public/browser_state.h"
10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
15 namespace ios_web_view {
16
17 namespace {
18 // A key used to associate a WebViewEarlyPageScriptProvider with a BrowserState.
19 const char kWebViewEarlyPageScriptProviderKeyName[] =
20 "web_view_early_page_script_provider";
21
22 } // namespace
23
24 // static
25 WebViewEarlyPageScriptProvider&
26 WebViewEarlyPageScriptProvider::FromBrowserState(
27 web::BrowserState* browser_state) {
28 DCHECK([NSThread isMainThread]);
michaeldo 2017/03/21 16:12:34 Why is this bound to the main thread? Should we DC
Hiroshi Ichikawa 2017/03/22 04:52:52 Well, I just copied implementation of: https://cs.
michaeldo 2017/03/22 23:03:32 Got it, that makes sense, either is likely ok. How
29 DCHECK(browser_state);
30 if (!browser_state->GetUserData(kWebViewEarlyPageScriptProviderKeyName)) {
31 browser_state->SetUserData(kWebViewEarlyPageScriptProviderKeyName,
32 std::unique_ptr<WebViewEarlyPageScriptProvider>(
michaeldo 2017/03/21 16:12:34 please use base::MakeUnique instead of new
Hiroshi Ichikawa 2017/03/22 04:52:52 MakeUnique() causes an error in this case because
michaeldo 2017/03/22 23:03:32 I see, no using new is OK then. However, is the st
Hiroshi Ichikawa 2017/03/23 02:18:40 That's true. But I found this comment: https://cs.
33 new WebViewEarlyPageScriptProvider()));
34 }
35 return *(static_cast<WebViewEarlyPageScriptProvider*>(
36 browser_state->GetUserData(kWebViewEarlyPageScriptProviderKeyName)));
37 }
38
39 WebViewEarlyPageScriptProvider::WebViewEarlyPageScriptProvider() {
Eugene But (OOO till 7-30) 2017/03/21 16:47:55 WebViewEarlyPageScriptProvider::WebViewEarlyPageSc
Hiroshi Ichikawa 2017/03/22 04:52:52 Done. But just curious, why? Is [[NSString alloc]
Eugene But (OOO till 7-30) 2017/03/22 15:08:50 Sorry, my comment was mostly about using initializ
Hiroshi Ichikawa 2017/03/23 02:18:40 Thanks for clarification!
40 script_ = @"";
41 }
42
43 WebViewEarlyPageScriptProvider::~WebViewEarlyPageScriptProvider() {}
michaeldo 2017/03/21 16:12:34 please use "= default;" instead of {}
Hiroshi Ichikawa 2017/03/22 04:52:52 Done.
44
45 } // namespace ios_web_view
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698