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

Issue 10381143: Add filtered event support to event.js. (Closed)

Created:
8 years, 7 months ago by koz (OOO until 15th September)
Modified:
7 years, 9 months ago
Reviewers:
Matt Perry, battre
CC:
chromium-reviews, Aaron Boodman, mihaip-chromium-reviews_chromium.org, darin-cc_chromium.org, brettw-cc_chromium.org, not at google - send to devlin, benwells
Visibility:
Public.

Description

Add filtered event support to event.js. BUG=121479

Patch Set 1 #

Total comments: 10

Patch Set 2 : respond to comments #

Patch Set 3 : respond to comments #

Total comments: 10

Patch Set 4 : respond to comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+267 lines, -42 lines) Patch
M chrome/renderer/extensions/event_unittest.cc View 1 2 3 3 chunks +154 lines, -0 lines 0 comments Download
M chrome/renderer/resources/extensions/event.js View 1 2 3 10 chunks +113 lines, -42 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
koz (OOO until 15th September)
8 years, 7 months ago (2012-05-15 03:38:28 UTC) #1
Matt Perry
https://chromiumcodereview.appspot.com/10381143/diff/1/chrome/renderer/extensions/event_unittest.cc File chrome/renderer/extensions/event_unittest.cc (right): https://chromiumcodereview.appspot.com/10381143/diff/1/chrome/renderer/extensions/event_unittest.cc#newcode157 chrome/renderer/extensions/event_unittest.cc:157: " 'hostSuffix': 'google.com'," this filter should be url: {etc} ...
8 years, 7 months ago (2012-05-15 19:28:27 UTC) #2
koz (OOO until 15th September)
https://chromiumcodereview.appspot.com/10381143/diff/1/chrome/renderer/extensions/event_unittest.cc File chrome/renderer/extensions/event_unittest.cc (right): https://chromiumcodereview.appspot.com/10381143/diff/1/chrome/renderer/extensions/event_unittest.cc#newcode157 chrome/renderer/extensions/event_unittest.cc:157: " 'hostSuffix': 'google.com'," On 2012/05/15 19:28:27, Matt Perry wrote: ...
8 years, 7 months ago (2012-05-16 01:26:12 UTC) #3
Matt Perry
https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/extensions/event_unittest.cc File chrome/renderer/extensions/event_unittest.cc (right): https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/extensions/event_unittest.cc#newcode157 chrome/renderer/extensions/event_unittest.cc:157: " url: [{hostSuffix: 'google.com'}]," url should not be an ...
8 years, 7 months ago (2012-05-16 20:44:58 UTC) #4
koz (OOO until 15th September)
https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/extensions/event_unittest.cc File chrome/renderer/extensions/event_unittest.cc (right): https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/extensions/event_unittest.cc#newcode157 chrome/renderer/extensions/event_unittest.cc:157: " url: [{hostSuffix: 'google.com'}]," On 2012/05/16 20:45:00, Matt Perry ...
8 years, 7 months ago (2012-05-18 04:50:07 UTC) #5
Matt Perry
I don't see the new snapshot.
8 years, 7 months ago (2012-05-18 19:10:12 UTC) #6
koz (OOO until 15th September)
Oops, should be up now.
8 years, 7 months ago (2012-05-21 00:14:17 UTC) #7
koz (OOO until 15th September)
https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/extensions/event_unittest.cc File chrome/renderer/extensions/event_unittest.cc (right): https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/extensions/event_unittest.cc#newcode157 chrome/renderer/extensions/event_unittest.cc:157: " url: [{hostSuffix: 'google.com'}]," On 2012/05/18 04:50:07, koz wrote: ...
8 years, 7 months ago (2012-05-21 01:27:50 UTC) #8
Matt Perry
+battre - We're adding request filters to certain events (specifically to use for webNavigation events). ...
8 years, 7 months ago (2012-05-22 19:20:52 UTC) #9
battre
https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/extensions/event_unittest.cc File chrome/renderer/extensions/event_unittest.cc (right): https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/extensions/event_unittest.cc#newcode157 chrome/renderer/extensions/event_unittest.cc:157: " url: [{hostSuffix: 'google.com'}]," On 2012/05/22 19:20:52, Matt Perry ...
8 years, 7 months ago (2012-05-22 20:19:44 UTC) #10
Matt Perry
8 years, 7 months ago (2012-05-22 20:43:59 UTC) #11
https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/ext...
File chrome/renderer/extensions/event_unittest.cc (right):

https://chromiumcodereview.appspot.com/10381143/diff/6001/chrome/renderer/ext...
chrome/renderer/extensions/event_unittest.cc:157: "  url: [{hostSuffix:
'google.com'}],"
On 2012/05/22 20:19:45, battre wrote:
> On 2012/05/22 19:20:52, Matt Perry wrote:
> > On 2012/05/21 01:27:50, koz wrote:
> > > On 2012/05/18 04:50:07, koz wrote:
> > > > On 2012/05/16 20:45:00, Matt Perry wrote:
> > > > > url should not be an array, it should be a single object. filter
itself
> > can
> > > be
> > > > > an array. i.e. filter = [
> > > > >   { url: {hostSuffix: 'google.com'} },
> > > > >   { url: {hostPrefix: 'mail.yahoo'} }
> > > > > ];
> > > > 
> > > > Done.
> > > 
> > > Thinking about this a bit I wonder if this is really what we want? Having
> > filter
> > > be a list of dictionaries of single values means that we have to handle
the
> > > general case every time, rather than the efficient case, which is the
common
> > > case.
> > > 
> > > By that I mean isn't it more common to want to specify the set of valid
URLs
> > and
> > > the set of valid tabIds for an event, rather than a set of individual
> filters?
> > > 
> > > addListener(cb, [
> > >   {url: {a}, tabId: 1},
> > >   {url: {b}, tabId: 2}]);
> > > 
> > > This seems like a rare scenario - we are interested in this URL for this
> tab,
> > > and this URL for that tab. To express what seems to me to be a much more
> > common
> > > scenario, that the user is interested in these URLs for this tab, you have
> to
> > > replicate tabId many times:
> > > 
> > > addListener(cb, [
> > >   {url: {a}, tabId: 1},
> > >   {url: {b}, tabId: 1},
> > >   {url: {c}, tabId: 1},
> > >   /* etc */]);
> > > 
> > > By having the url field be an array I think it would match user intent
more
> > > closely, and be simpler to implement (as we don't need to remember which
> URLs
> > > correspond to which other sets of constraints). The rare case above is
still
> > > expressable through multiple calls to addListener().
> > > 
> > > WDYT?
> > 
> > That's a good point. I was just trying to make it mirror the declarative
> > webrequest API as much as possible:
> > http://code.google.com/chrome/extensions/trunk/declarativeWebRequest.html
> > 
> > You're right, it's probably rare to want to filter on more than one tabId.
But
> > there are other filter criteria, like resource type (image, script, main
> frame,
> > etc).
> > 
> > Also, with your proposed way of organizing filters, there's no way to
express
> > something like "(url matches a AND resourceType matches x) OR (url matches b
> AND
> > resourceType matches y)".
> > 
> > Dominic, what do you think?
> 
> What do you think of providing 'url' and 'urls'.
> 
> addListener(cb, [
>   {url: {a}, tabId: 1},
>   {url: {b}, tabId: 1},
>   {url: {c}, tabId: 1},
>   /* etc */]);
> 
> and
> 
> addListener(cb, [
>   {urls: [{a}, {b}, {c}], tabId: 1},
>   ]);
> 
> would be equivalent. Extend the declarative webRequest API accordingly.
> 
> However, we cannot do this to an infinite degree.
> 
> E.g.
> addListener(cb, [
>   {urls: [{a, schemes: ['http']}, {b, schemes: ['http']}, {c, schemes:
> ['http']}], tabId: 1},
>   ]);
> could not be simplified any further.

That sounds like a good compromise to me.

Powered by Google App Engine
This is Rietveld 408576698