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

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

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 #ifndef IOS_WEB_VIEW_INTERNAL_WEB_VIEW_EARLY_PAGE_SCRIPT_PROVIDER_H_
6 #define IOS_WEB_VIEW_INTERNAL_WEB_VIEW_EARLY_PAGE_SCRIPT_PROVIDER_H_
7
8 #include <Foundation/Foundation.h>
9
10 #include "base/macros.h"
11 #include "base/supports_user_data.h"
12
13 namespace web {
14 class BrowserState;
15 }
16
17 namespace ios_web_view {
18
19 // A provider class associated with a single web::BrowserState object. Keeps
20 // an early page script, a JavaScript injected into all pages as early as
21 // possible.
22 //
23 // Not threadsafe. Must be used only on the main thread.
24 class WebViewEarlyPageScriptProvider : public base::SupportsUserData::Data {
25 public:
26 ~WebViewEarlyPageScriptProvider() override;
27
28 // Returns a provider for the given |browser_state|. Lazily attaches one if it
29 // does not exist. |browser_state| can not be null.
30 static WebViewEarlyPageScriptProvider& FromBrowserState(
31 web::BrowserState* browser_state);
32
33 // Getter and Setter for the JavaScript source code.
34 NSString* GetScript() { return script_; }
35 void SetScript(NSString* script) { script_ = script; }
michaeldo 2017/03/21 16:12:34 Please document setter as script must be nonnull.
Eugene But (OOO till 7-30) 2017/03/21 16:47:55 script_ = [script copy];
Hiroshi Ichikawa 2017/03/22 04:52:52 Done.
Hiroshi Ichikawa 2017/03/22 04:52:52 I *documented* the requirement by adding _Nonnull
michaeldo 2017/03/22 23:03:32 I found at least one other reference to _Nonnull s
Hiroshi Ichikawa 2017/03/23 02:48:05 Acknowledged.
36
37 private:
38 WebViewEarlyPageScriptProvider();
michaeldo 2017/03/21 16:12:34 please move to immediately after public: above
Hiroshi Ichikawa 2017/03/22 04:52:52 Shouldn't the constructor be private so that it ca
Eugene But (OOO till 7-30) 2017/03/22 15:08:50 Private constructor seems like a better choice
michaeldo 2017/03/22 23:03:32 Sorry, you're right. I didn't see why it was priva
39
40 // The JavaScript source code.
41 NSString* script_;
michaeldo 2017/03/21 16:12:34 Please use: base::scoped_nsobject<NSString> scrip
Hiroshi Ichikawa 2017/03/22 04:52:52 Done. What is the benefit using scoped_nsobject co
michaeldo 2017/03/22 23:03:32 I mostly suggested based on style and consistency.
Hiroshi Ichikawa 2017/03/23 02:48:05 Acknowledged.
42
43 DISALLOW_COPY_AND_ASSIGN(WebViewEarlyPageScriptProvider);
44 };
45
46 } // namespace ios_web_view
47
48 #endif // IOS_WEB_VIEW_INTERNAL_WEB_VIEW_EARLY_PAGE_SCRIPT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698