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

Issue 2764773002: Add CWVUserContentController which enables injecting JavaScripts. (Closed)

Created:
3 years, 9 months ago by Hiroshi Ichikawa
Modified:
3 years, 8 months ago
CC:
chromium-reviews, ios-reviews+web_chromium.org, ios-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Add CWVUserContentController which enables injecting JavaScripts. BUG=698656 Review-Url: https://codereview.chromium.org/2764773002 Cr-Commit-Position: refs/heads/master@{#459093} Committed: https://chromium.googlesource.com/chromium/src/+/762b38b0d18bf44ad5f0381583f45c2598ab470d

Patch Set 1 #

Patch Set 2 : Add license. #

Total comments: 91

Patch Set 3 : Apply new comments. #

Total comments: 4

Patch Set 4 : Apply review comments. #

Patch Set 5 : Apply review comment. #

Patch Set 6 : Apply review comments. #

Patch Set 7 : Rebase. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+291 lines, -1 line) Patch
M ios/web/public/web_client.h View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M ios/web_view/BUILD.gn View 1 chunk +2 lines, -0 lines 0 comments Download
M ios/web_view/internal/BUILD.gn View 2 chunks +5 lines, -0 lines 0 comments Download
A ios/web_view/internal/cwv_user_content_controller.mm View 1 2 3 4 5 1 chunk +62 lines, -0 lines 0 comments Download
A ios/web_view/internal/cwv_user_content_controller_internal.h View 1 2 3 4 5 1 chunk +19 lines, -0 lines 0 comments Download
A ios/web_view/internal/cwv_user_script.mm View 1 2 3 4 5 1 chunk +23 lines, -0 lines 0 comments Download
M ios/web_view/internal/cwv_web_view.mm View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M ios/web_view/internal/cwv_web_view_configuration.mm View 3 chunks +5 lines, -0 lines 0 comments Download
A ios/web_view/internal/web_view_early_page_script_provider.h View 1 2 1 chunk +49 lines, -0 lines 0 comments Download
A ios/web_view/internal/web_view_early_page_script_provider.mm View 1 2 3 4 1 chunk +49 lines, -0 lines 0 comments Download
M ios/web_view/internal/web_view_web_client.h View 1 chunk +1 line, -0 lines 0 comments Download
M ios/web_view/internal/web_view_web_client.mm View 2 chunks +7 lines, -0 lines 0 comments Download
M ios/web_view/public/BUILD.gn View 1 chunk +2 lines, -0 lines 0 comments Download
A ios/web_view/public/cwv_user_content_controller.h View 1 2 3 4 5 1 chunk +30 lines, -0 lines 0 comments Download
A ios/web_view/public/cwv_user_script.h View 1 2 3 4 5 1 chunk +24 lines, -0 lines 0 comments Download
M ios/web_view/public/cwv_web_view.h View 1 2 3 4 5 6 1 chunk +3 lines, -0 lines 0 comments Download
M ios/web_view/public/cwv_web_view_configuration.h View 1 2 2 chunks +6 lines, -1 line 0 comments Download

Messages

Total messages: 36 (13 generated)
Hiroshi Ichikawa
3 years, 9 months ago (2017-03-21 04:01:58 UTC) #2
michaeldo
Thanks for this CL, looks great overall! https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm File ios/web_view/internal/cwv_user_content_controller.mm (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm#newcode3 ios/web_view/internal/cwv_user_content_controller.mm:3: // found ...
3 years, 9 months ago (2017-03-21 16:12:35 UTC) #3
Eugene But (OOO till 7-30)
Generally looks good https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm File ios/web_view/internal/cwv_user_content_controller.mm (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm#newcode23 ios/web_view/internal/cwv_user_content_controller.mm:23: _configuration = configuration; nit: Consider adding ...
3 years, 9 months ago (2017-03-21 16:47:55 UTC) #4
michaeldo
https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/public/cwv_web_view.h File ios/web_view/public/cwv_web_view.h (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/public/cwv_web_view.h#newcode23 ios/web_view/public/cwv_web_view.h:23: @property(readonly, copy) CWVWebViewConfiguration* configuration; On 2017/03/21 16:47:55, Eugene But ...
3 years, 9 months ago (2017-03-21 17:24:04 UTC) #5
Hiroshi Ichikawa
https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm File ios/web_view/internal/cwv_user_content_controller.mm (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm#newcode3 ios/web_view/internal/cwv_user_content_controller.mm:3: // found in the LICENSE file. On 2017/03/21 16:12:34, ...
3 years, 9 months ago (2017-03-22 04:52:53 UTC) #6
Eugene But (OOO till 7-30)
lgtm https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/web_view_early_page_script_provider.h File ios/web_view/internal/web_view_early_page_script_provider.h (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/web_view_early_page_script_provider.h#newcode38 ios/web_view/internal/web_view_early_page_script_provider.h:38: WebViewEarlyPageScriptProvider(); On 2017/03/22 04:52:52, Hiroshi Ichikawa wrote: > ...
3 years, 9 months ago (2017-03-22 15:08:51 UTC) #7
michaeldo
Thanks! lgtm with a few suggestions. https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm File ios/web_view/internal/cwv_user_content_controller.mm (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm#newcode23 ios/web_view/internal/cwv_user_content_controller.mm:23: _configuration = configuration; ...
3 years, 9 months ago (2017-03-22 23:03:33 UTC) #8
Eugene But (OOO till 7-30)
https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm File ios/web_view/internal/cwv_user_content_controller.mm (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm#newcode23 ios/web_view/internal/cwv_user_content_controller.mm:23: _configuration = configuration; On 2017/03/22 23:03:32, michaeldo wrote: > ...
3 years, 9 months ago (2017-03-22 23:09:50 UTC) #9
Hiroshi Ichikawa
https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/web_view_early_page_script_provider.mm File ios/web_view/internal/web_view_early_page_script_provider.mm (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/web_view_early_page_script_provider.mm#newcode32 ios/web_view/internal/web_view_early_page_script_provider.mm:32: std::unique_ptr<WebViewEarlyPageScriptProvider>( On 2017/03/22 23:03:32, michaeldo wrote: > On 2017/03/22 ...
3 years, 9 months ago (2017-03-23 02:18:40 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2764773002/80001
3 years, 9 months ago (2017-03-23 02:19:29 UTC) #13
Hiroshi Ichikawa
https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm File ios/web_view/internal/cwv_user_content_controller.mm (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/internal/cwv_user_content_controller.mm#newcode23 ios/web_view/internal/cwv_user_content_controller.mm:23: _configuration = configuration; On 2017/03/22 23:09:50, Eugene But wrote: ...
3 years, 9 months ago (2017-03-23 02:48:06 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2764773002/100001
3 years, 9 months ago (2017-03-23 02:48:30 UTC) #18
commit-bot: I haz the power
Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds/175780) ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, ...
3 years, 9 months ago (2017-03-23 02:51:00 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2764773002/120001
3 years, 9 months ago (2017-03-23 05:17:45 UTC) #23
commit-bot: I haz the power
Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_chromium_compile_only_ng/builds/304390)
3 years, 9 months ago (2017-03-23 05:31:19 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2764773002/120001
3 years, 9 months ago (2017-03-23 15:16:49 UTC) #27
commit-bot: I haz the power
Committed patchset #7 (id:120001) as https://chromium.googlesource.com/chromium/src/+/762b38b0d18bf44ad5f0381583f45c2598ab470d
3 years, 9 months ago (2017-03-23 15:44:55 UTC) #30
Eugene But (OOO till 7-30)
https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/public/cwv_web_view.h File ios/web_view/public/cwv_web_view.h (right): https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/public/cwv_web_view.h#newcode23 ios/web_view/public/cwv_web_view.h:23: @property(readonly, copy) CWVWebViewConfiguration* configuration; On 2017/03/23 02:18:40, Hiroshi Ichikawa ...
3 years, 9 months ago (2017-03-23 16:17:02 UTC) #31
Hiroshi Ichikawa
On 2017/03/23 16:17:02, Eugene But wrote: > https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/public/cwv_web_view.h > File ios/web_view/public/cwv_web_view.h (right): > > https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/public/cwv_web_view.h#newcode23 ...
3 years, 9 months ago (2017-03-24 02:49:04 UTC) #32
Eugene But (OOO till 7-30)
On 2017/03/24 02:49:04, Hiroshi Ichikawa wrote: > On 2017/03/23 16:17:02, Eugene But wrote: > > ...
3 years, 9 months ago (2017-03-24 15:39:51 UTC) #33
Hiroshi Ichikawa
On 2017/03/24 15:39:51, Eugene But wrote: > On 2017/03/24 02:49:04, Hiroshi Ichikawa wrote: > > ...
3 years, 8 months ago (2017-03-27 04:25:29 UTC) #34
Eugene But (OOO till 7-30)
On 2017/03/27 04:25:29, Hiroshi Ichikawa wrote: > On 2017/03/24 15:39:51, Eugene But wrote: > > ...
3 years, 8 months ago (2017-03-27 16:31:50 UTC) #35
Hiroshi Ichikawa
3 years, 8 months ago (2017-03-28 03:28:08 UTC) #36
Message was sent while issue was closed.
On 2017/03/27 16:31:50, Eugene But wrote:
> On 2017/03/27 04:25:29, Hiroshi Ichikawa wrote:
> > On 2017/03/24 15:39:51, Eugene But wrote:
> > > On 2017/03/24 02:49:04, Hiroshi Ichikawa wrote:
> > > > On 2017/03/23 16:17:02, Eugene But wrote:
> > > > >
> > > >
> > >
> >
>
https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/public/cwv...
> > > > > File ios/web_view/public/cwv_web_view.h (right):
> > > > > 
> > > > >
> > > >
> > >
> >
>
https://codereview.chromium.org/2764773002/diff/20001/ios/web_view/public/cwv...
> > > > > ios/web_view/public/cwv_web_view.h:23: @property(readonly, copy)
> > > > > CWVWebViewConfiguration* configuration;
> > > > > On 2017/03/23 02:18:40, Hiroshi Ichikawa wrote:
> > > > > > On 2017/03/22 15:08:50, Eugene But wrote:
> > > > > > > On 2017/03/22 04:52:53, Hiroshi Ichikawa wrote:
> > > > > > > > On 2017/03/21 16:47:55, Eugene But wrote:
> > > > > > > > > nonatomic?
> > > > > > > > 
> > > > > > > > Done.
> > > > > > > > 
> > > > > > > > BTW Many properties including this one are marked as (readonly,
> > copy)
> > > in
> > > > > the
> > > > > > > > API, but isn't it meaningless? Doesn't "copy" only affect the
> > setter,
> > > > not
> > > > > > > > getter?
> > > > > > > Copy affects getter, and will generate code similar to this:
> > > > > > > - (CWVWebViewConfiguration*)configuration {
> > > > > > >   return [[_configuration copy] autorelease];
> > > > > > > }
> > > > > > > The main value for using |copy| is documenting the ownership
> > > > > > 
> > > > > > Hmm it looks it doesn't affect the getter as far as I tested (see
the
> > test
> > > > > code
> > > > > > below). Am I missing something?
> > > > > >
> > > > >
> > > >
> > >
> >
>
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Pr...
> > > > > > also mentions only about the setter but not getter for |copy|.
> > > > > > 
> > > > > > Maybe |retain| is better for documentation purpose if it actually
> > doesn't
> > > > > copy?
> > > > > > 
> > > > > > #import <Foundation/Foundation.h>
> > > > > > 
> > > > > > @interface Foo : NSObject
> > > > > > @property(nonatomic, readonly, copy) NSObject* bar;
> > > > > > - (instancetype)init;
> > > > > > @end
> > > > > > 
> > > > > > @implementation Foo
> > > > > > 
> > > > > > - (instancetype)init {
> > > > > >   self = [super init];
> > > > > >   if (self) {
> > > > > >     _bar = [[NSObject alloc] init];
> > > > > >   }
> > > > > >   return self;
> > > > > > }
> > > > > > 
> > > > > > @end
> > > > > > 
> > > > > > int main() {
> > > > > >   Foo* foo = [[Foo alloc] init];
> > > > > >   NSObject* bar1 = foo.bar;
> > > > > >   NSObject* bar2 = foo.bar;
> > > > > >   NSLog(@"bar1 = %@", bar1);
> > > > > >   // => bar1 = <NSObject: 0x7fce2f400430>
> > > > > >   NSLog(@"bar2 = %@", bar2);
> > > > > >   // => bar2 = <NSObject: 0x7fce2f400430>
> > > > > >   return 0;
> > > > > > }
> > > > > Maybe this is an optimization for immutable objects, like NSObject? Or
> > maybe
> > > I
> > > > > don't understand Objective-C :)
> > > > 
> > > > Here is (I believe) a clearer example that it's not copied in the
getter:
> > > > 
> > > > #import <Foundation/Foundation.h>
> > > > 
> > > > @interface Foo : NSObject
> > > > @property(nonatomic, readonly, copy) NSMutableString* bar;
> > > > - (instancetype)init;
> > > > @end
> > > > 
> > > > @implementation Foo
> > > > 
> > > > - (instancetype)init {
> > > >   self = [super init];
> > > >   if (self) {
> > > >     _bar = [[NSMutableString alloc] init];
> > > >     [_bar appendString:@"aaa"];
> > > >   }
> > > >   return self;
> > > > }
> > > > 
> > > > @end
> > > > 
> > > > int main() {
> > > >   Foo* foo = [[Foo alloc] init];
> > > >   NSMutableString* bar1 = foo.bar;
> > > >   [bar1 appendString:@"bbb"];
> > > >   NSLog(@"bar1 = %@", bar1);
> > > >   // => bar1 = aaabbb
> > > >   mailto:NSLog(@"foo.bar = %@", foo.bar);
> > > >   // => foo.bar = aaabbb
> > > >   return 0;
> > > > }
> > > Thank you for sharing this. Apparently I do not understand Objective-C :)
> > 
> > No problem. Should we change (readonly, copy) to (readonly, retain) for
> > clarification?
> Keeping copy may still be useful. F.e. if the implementation wants to redefine
> the property as read-write, then the property needs be changed from "strong"
to
> "copy" in the header. However if you want to change properties from "copy" to
> "strong" feel free to to so (unless those properties and NSString*, in which
> case it still should be "copy" to match Objective-C Style Guide).

That makes sense. Then let's keep them as "copy". Thanks for the explanation.

Powered by Google App Engine
This is Rietveld 408576698