Bug 77690

Summary: Add UserGestureIndicator capability to Chromium API.
Product: WebKit Reporter: Greg Billock <gbillock>
Component: New BugsAssignee: Greg Billock <gbillock>
Status: RESOLVED FIXED    
Severity: Normal CC: bbudge, fishd, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Greg Billock
Reported 2012-02-02 16:30:32 PST
Add UserGestureIndicator capability to Chromium API.
Attachments
Patch (7.51 KB, patch)
2012-02-02 16:30 PST, Greg Billock
no flags
Patch (7.88 KB, patch)
2012-02-03 11:19 PST, Greg Billock
no flags
Patch (7.29 KB, patch)
2012-02-06 12:29 PST, Greg Billock
no flags
Patch (8.38 KB, patch)
2012-02-08 10:52 PST, Greg Billock
no flags
Patch (8.05 KB, patch)
2012-02-13 13:28 PST, Greg Billock
no flags
Patch (7.93 KB, patch)
2012-02-15 16:12 PST, Greg Billock
no flags
Patch (6.86 KB, patch)
2012-02-16 11:09 PST, Greg Billock
no flags
Greg Billock
Comment 1 2012-02-02 16:30:56 PST
WebKit Review Bot
Comment 2 2012-02-02 16:33:39 PST
Please wait for approval from fishd@chromium.org before submitting because this patch contains changes to the Chromium public API.
Darin Fisher (:fishd, Google)
Comment 3 2012-02-03 10:50:51 PST
Comment on attachment 125208 [details] Patch Can you say more about what you need? We already have WebFrame::isProcessingUserGesture(). Usually, web platform features that depend on user gesture checking perform their user gesture checking within WebKit. That won't work for WebIntents?
Greg Billock
Comment 4 2012-02-03 11:14:42 PST
(In reply to comment #3) > (From update of attachment 125208 [details]) > Can you say more about what you need? We already have WebFrame::isProcessingUserGesture(). Usually, web platform features that depend on user gesture checking perform their user gesture checking within WebKit. That won't work for WebIntents? This is for setting the user gesture indicator, not for reading it. The need we have for this is that when executing a script in an extension context menu context, we are in a user-caused gesture situation, but the indicator doesn't realize that (because it hasn't been told). There are probably other situations where we execute code in extensions that is user-caused, but which we don't set the indicator to reflect that.
Greg Billock
Comment 5 2012-02-03 11:19:12 PST
Darin Fisher (:fishd, Google)
Comment 6 2012-02-03 21:46:58 PST
Comment on attachment 125368 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=125368&action=review > Source/WebKit/chromium/public/WebUserGestureIndicator.h:45 > +class WebUserGestureIndicator { I think you should do a more traditional WebKit API wrapper for a reference counted type. That way, users can either lay one of these down on the stack to get a scoped gesture, or they can heap allocate a copy to extend its lifetime. Do you really need all of these variants exposed to Chrome? I also recall that bbudge was needing to simulate a user-gesture for something. Hmm...
Bill Budge
Comment 7 2012-02-05 09:44:22 PST
*** Bug 69190 has been marked as a duplicate of this bug. ***
Bill Budge
Comment 8 2012-02-05 09:45:53 PST
We will need this for plugins that need to respond to a user gesture and are running on an asynchronous out-of-process proxy (Chrome IPC when we switch).
Greg Billock
Comment 9 2012-02-06 09:25:38 PST
Comment on attachment 125368 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=125368&action=review >> Source/WebKit/chromium/public/WebUserGestureIndicator.h:45 >> +class WebUserGestureIndicator { > > I think you should do a more traditional WebKit API wrapper for a reference counted type. > That way, users can either lay one of these down on the stack to get a scoped gesture, > or they can heap allocate a copy to extend its lifetime. > > Do you really need all of these variants exposed to Chrome? > > I also recall that bbudge was needing to simulate a user-gesture for something. Hmm... You can do that with scoped_ptr<WUGI>(WUGI::xxx()); The underlying UserGestureIndicator isn't ref-counted, though. I can make this class look like it is, though, but it'd mean doing internal shenanigans to correctly maintain ownership of the internal pointer, or simply disallowing refcount-style object sharing. I'm not sure how much scope expansion will be useful; I don't need it for my immediate use. Bill, do you need to pass these objects between scopes?
Greg Billock
Comment 10 2012-02-06 12:29:43 PST
Darin Fisher (:fishd, Google)
Comment 11 2012-02-06 15:51:47 PST
Oh, I see. I misread WebPrivateOwnPtr as WebPrivatePtr. Sorry for the confusion!
Greg Billock
Comment 12 2012-02-08 10:52:58 PST
Greg Billock
Comment 13 2012-02-08 10:53:58 PST
As discussed, I added the state accessor to WebUserGestureIndicator. I also re-pointed the WebFrame method to use it. Follow-ups will repoint users of that API here, and then remove it.
Greg Billock
Comment 14 2012-02-13 13:28:04 PST
Darin Fisher (:fishd, Google)
Comment 15 2012-02-15 14:00:02 PST
Comment on attachment 126817 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=126817&action=review > Source/WebKit/chromium/public/WebScopedUserGesture.h:44 > +// WebCore user gesture indicator. To use, create one, perform whatever actions no need to mention WebCore in the comments. > Source/WebKit/chromium/public/WebScopedUserGesture.h:47 > +class WebScopedUserGesture : public WebNonCopyable { nit: no need to extend from WebNonCopyable since you have a member variable of type WebPrivateOwnPtr. that already makes this class non-copyable. > Source/WebKit/chromium/public/WebScopedUserGesture.h:50 > + // DefinitelyProcessingUserGesture. DefinitelyProcessingUserGesture is a WebCore thing. it is meaningless to someone who only reads the WebKit API. please avoid mentioning WebCore things since your comments can easily get stale, and we want consumers to be insulated from WebCore details. > Source/WebKit/chromium/public/WebScopedUserGesture.h:54 > + WEBKIT_EXPORT static bool isProcessingUserGesture(); do you need to expose this method? > Source/WebKit/chromium/public/WebScopedUserGesture.h:56 > + WEBKIT_EXPORT virtual ~WebScopedUserGesture(); nit: no need for a virtual destructor. nit: we have the convention of implement constructors and destructors inline in terms of other exported functions. here, i'd recommend the following: class WebScopedUserGesture { public: WebScopedUserGesture() { initialize(); } ~WebScopedUserGesture() { reset(); } private: WEBKIT_EXPORT void initialize(); WEBKIT_EXPORT void reset(); WebPrivateOwnPtr<WebCore::UserGestureIndicator> m_indicator; }; > Source/WebKit/chromium/src/WebFrameImpl.cpp:1116 > + return WebScopedUserGesture::isProcessingUserGesture(); we don't normally implement WebKit APIs in terms of other WebKit APIs. we generally just go directly to WebCore.
Greg Billock
Comment 16 2012-02-15 16:12:43 PST
Greg Billock
Comment 17 2012-02-15 16:17:22 PST
Comment on attachment 126817 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=126817&action=review >> Source/WebKit/chromium/public/WebScopedUserGesture.h:44 >> +// WebCore user gesture indicator. To use, create one, perform whatever actions > > no need to mention WebCore in the comments. Done >> Source/WebKit/chromium/public/WebScopedUserGesture.h:47 >> +class WebScopedUserGesture : public WebNonCopyable { > > nit: no need to extend from WebNonCopyable since you have a member variable > of type WebPrivateOwnPtr. that already makes this class non-copyable. Done >> Source/WebKit/chromium/public/WebScopedUserGesture.h:50 >> + // DefinitelyProcessingUserGesture. > > DefinitelyProcessingUserGesture is a WebCore thing. it is meaningless to someone > who only reads the WebKit API. please avoid mentioning WebCore things since your > comments can easily get stale, and we want consumers to be insulated from WebCore > details. Done >> Source/WebKit/chromium/public/WebScopedUserGesture.h:54 >> + WEBKIT_EXPORT static bool isProcessingUserGesture(); > > do you need to expose this method? Our plan was to move WebFrameImpl callers to call this. Shall we abort that plan? >> Source/WebKit/chromium/public/WebScopedUserGesture.h:56 >> + WEBKIT_EXPORT virtual ~WebScopedUserGesture(); > > nit: no need for a virtual destructor. > > nit: we have the convention of implement constructors and destructors inline > in terms of other exported functions. here, i'd recommend the following: > > class WebScopedUserGesture { > public: > WebScopedUserGesture() { initialize(); } > ~WebScopedUserGesture() { reset(); } > > private: > WEBKIT_EXPORT void initialize(); > WEBKIT_EXPORT void reset(); > > WebPrivateOwnPtr<WebCore::UserGestureIndicator> m_indicator; > }; Done. >> Source/WebKit/chromium/src/WebFrameImpl.cpp:1116 >> + return WebScopedUserGesture::isProcessingUserGesture(); > > we don't normally implement WebKit APIs in terms of other WebKit APIs. we generally just go directly to WebCore. Here our plan was to move all callers of WebFrameImpl::isProcessingUserGesture to calling WebScopedUserGestuer::isProcessingUserGesture. I made this change so that refactor will be a no-op.
Darin Fisher (:fishd, Google)
Comment 18 2012-02-15 16:53:01 PST
(In reply to comment #17) > >> Source/WebKit/chromium/public/WebScopedUserGesture.h:54 > >> + WEBKIT_EXPORT static bool isProcessingUserGesture(); > > > > do you need to expose this method? > > Our plan was to move WebFrameImpl callers to call this. Shall we abort that plan? I'm sorry, I recall discussing that too. I think we probably should abort since the name of this class is WebScopedUserGesture. I assume you don't really need isProcessingUserGesture, right?
Greg Billock
Comment 19 2012-02-16 10:36:08 PST
OK (In reply to comment #18) > (In reply to comment #17) > > >> Source/WebKit/chromium/public/WebScopedUserGesture.h:54 > > >> + WEBKIT_EXPORT static bool isProcessingUserGesture(); > > > > > > do you need to expose this method? > > > > Our plan was to move WebFrameImpl callers to call this. Shall we abort that plan? > > I'm sorry, I recall discussing that too. I think we probably should abort > since the name of this class is WebScopedUserGesture. I assume you don't > really need isProcessingUserGesture, right?
Greg Billock
Comment 20 2012-02-16 11:09:17 PST
Greg Billock
Comment 21 2012-02-17 12:43:24 PST
OK, I think this is ready.
WebKit Review Bot
Comment 22 2012-02-23 13:05:59 PST
Comment on attachment 127412 [details] Patch Clearing flags on attachment: 127412 Committed r108665: <http://trac.webkit.org/changeset/108665>
WebKit Review Bot
Comment 23 2012-02-23 13:06:04 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.