Closed
Bug 1045975
Opened 11 years ago
Closed 11 years ago
Use nsIDOMWindowUtils.askPermission in all types of permission request
Categories
(Core :: Permission Manager, defect)
Core
Permission Manager
Tracking
()
RESOLVED
FIXED
mozilla34
People
(Reporter: schien, Assigned: schien)
References
Details
Attachments
(1 file, 8 obsolete files)
74.46 KB,
patch
|
schien
:
review+
|
Details | Diff | Splinter Review |
nsIDOMWindowUtils.askPermission already takes care of permission prompt for both oop and non-oop case. Therefore, we don't have to inherit PCOMContentPermissionRequestChild anymore while implementing nsIContentPermissionRequest.
Here is the list of class that can be simplified:
- CameraPermissionRequest
- DeviceStorageCursorRequest
- DeviceStorageRequest
- nsDOMDeviceStorageCursor
- FileSystemPermissionRequest
- MediaPermissionRequest
- nsGeolocationRequest
- DesktopNotificationRequest
- NotificationPermissionRequest
Assignee | ||
Comment 2•11 years ago
|
||
summary of changes:
1. remove the inheritance of PCOMContentPermissionRequestChild from all nsIContentPermissionRequest subclasses
2. RemotePermissionRequest doesn't need to implement nsIContentPermissionRequest, nsDOMWindowUtils.askPermission() can use the passed-in request object directly for non-oop case.
3. remove PCOMContentPermissionRequestChild and make RemotePermissionRequest directly inherit PContentPermissionRequestChild
try: https://tbpl.mozilla.org/?tree=Try&rev=db7371eb7a54
Attachment #8464656 -
Attachment is obsolete: true
Attachment #8465359 -
Flags: review?(fabrice)
Comment 3•11 years ago
|
||
Comment on attachment 8465359 [details] [diff] [review]
use-nsidomwindowutils-askpermission.patch
Review of attachment 8465359 [details] [diff] [review]:
-----------------------------------------------------------------
Overall lgtm, less code is a win! You have some build failures on try (yeah for windows #define !). Also I'd like someone like smaug to do the review, since that touches code I'm not a peer of.
::: dom/base/nsContentPermissionHelper.h
@@ +123,4 @@
>
> nsCOMPtr<nsIContentPermissionRequest> mRequest;
> nsCOMPtr<nsPIDOMWindow> mWindow;
> + bool mIPCOpen;
nit: alignment
Attachment #8465359 -
Flags: review?(fabrice) → feedback+
Assignee | ||
Comment 4•11 years ago
|
||
fix windows build error (old #undef trick) and migrate nsPointerLockPermissionRequest to use nsIDOMWindowUtils.askPermission().
try: https://tbpl.mozilla.org/?tree=Try&rev=8925a29f3fdc
Attachment #8465359 -
Attachment is obsolete: true
Attachment #8466036 -
Flags: review?(bugs)
Comment 5•11 years ago
|
||
Comment on attachment 8466036 [details] [diff] [review]
use-nsidomwindowutils-askpermission.patch
I like the basic approach, but makes no sense to create DOMWindowUtils object
just for this. do_GetInterface(mWindow) creates a DOMWindowUtils object, if needed. (DOMWindowUtils is mainly for JS stuff).
Could you move whatever nsDOMWindowUtils::AskPermission does to be
a static method in nsContentUtils, and then
make nsDOMWindowUtils::AskPermission to call that.
All the C++ code should use nsContentUtils, and JS code can access the
same stuff via nsIDOMWindowUtils
Attachment #8466036 -
Flags: review?(bugs) → review-
Comment 6•11 years ago
|
||
Or other, perhaps better approach, is to put the static method to nsContentPermissionHelper.h.
Assignee | ||
Comment 7•11 years ago
|
||
update according to review comment, introduce |nsContentPermissionUtils| for aggregating all the static functions in nsContentPermissionHelper.cpp including |AskPermission|.
try: https://tbpl.mozilla.org/?tree=Try&rev=e0379e840593
Attachment #8466036 -
Attachment is obsolete: true
Attachment #8466649 -
Flags: review?(bugs)
Assignee | ||
Comment 8•11 years ago
|
||
minor fix for do_GetService compile error.
https://tbpl.mozilla.org/?tree=Try&rev=3bad9a2b69c8
Attachment #8466649 -
Attachment is obsolete: true
Attachment #8466649 -
Flags: review?(bugs)
Attachment #8466665 -
Flags: review?(bugs)
Comment 9•11 years ago
|
||
Comment on attachment 8466665 [details] [diff] [review]
use-nsidomwindowutils-askpermission.patch, v2.1
># HG changeset patch
># User Shih-Chiang Chien <schien@mozilla.com>
># Date 1406877740 -28800
># Fri Aug 01 15:22:20 2014 +0800
># Node ID d383d3ee9f213bebee921edcb06c4dad0490ef81
># Parent >- return NS_OK;
>+ nsCOMPtr<nsPIDOMWindow> window = doc->GetWindow();
>+ return nsContentPermissionUtils::AskPermission(this, window);
The old code never returns non-NS_OK, and I think we want that behavior here.
So,
nsContentPermissionUtils::AskPermission(this, GetInnerWindow());
return NS_OK;
>+nsContentPermissionUtils::AskPermission(nsIContentPermissionRequest* aRequest, nsPIDOMWindow* aWindow)
You should probably do
MOZ_ASSERT(!aWindow || aWindow->IsInnerWindow());
NS_ENSURE_STATE(aWindow && aWindow->IsCurrentInnerWindow());
>+ void IPDLAddRef() {
{ goes to its own line.
Same also elsewhere.
> class RequestPromptEvent : public nsRunnable
> {
> public:
>- RequestPromptEvent(nsGeolocationRequest* request)
>- : mRequest(request)
>+ RequestPromptEvent(nsGeolocationRequest* aRequest, nsWeakPtr aWindow)
>+ : mRequest(aRequest)
>+ , mWindow(aWindow)
> {
> }
>
> NS_IMETHOD Run() {
>- nsCOMPtr<nsIContentPermissionPrompt> prompt = do_CreateInstance(NS_CONTENT_PERMISSION_PROMPT_CONTRACTID);
>- if (prompt) {
>- prompt->Prompt(mRequest);
>+ nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
>+ if (!window) {
>+ return NS_OK;
> }
Is AskPermission was null-safe, you wouldn't need this if check.
> public:
> NS_DECL_ISUPPORTS_INHERITED
> NS_DECL_NSICONTENTPERMISSIONREQUEST
>
> DesktopNotificationRequest(DesktopNotification* notification)
> : mDesktopNotification(notification) {}
>
> NS_IMETHOD Run() MOZ_OVERRIDE
> {
>- nsCOMPtr<nsIContentPermissionPrompt> prompt =
>- do_CreateInstance(NS_CONTENT_PERMISSION_PROMPT_CONTRACTID);
>- if (prompt) {
>- prompt->Prompt(this);
>+ nsCOMPtr<nsPIDOMWindow> window = mDesktopNotification->GetOwner();
>+
>+ if (!window) {
>+ return NS_OK;
> }
Is AskPermission was null-safe, you wouldn't need this if check.
I could take still a quick look on an updated patch.
Attachment #8466665 -
Flags: review?(bugs) → review-
Assignee | ||
Comment 10•11 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #9)
> Comment on attachment 8466665 [details] [diff] [review]
> use-nsidomwindowutils-askpermission.patch, v2.1
>
> ># HG changeset patch
> ># User Shih-Chiang Chien <schien@mozilla.com>
> ># Date 1406877740 -28800
> ># Fri Aug 01 15:22:20 2014 +0800
> ># Node ID d383d3ee9f213bebee921edcb06c4dad0490ef81
> ># Parent >- return NS_OK;
> >+ nsCOMPtr<nsPIDOMWindow> window = doc->GetWindow();
> >+ return nsContentPermissionUtils::AskPermission(this, window);
> The old code never returns non-NS_OK, and I think we want that behavior here.
> So,
> nsContentPermissionUtils::AskPermission(this, GetInnerWindow());
> return NS_OK;
>
The old code will return non-NS_OK via those NS_ENSURE_SUCCESS statement, do you think we should change it to always return NS_OK?
Flags: needinfo?(bugs)
Assignee | ||
Comment 11•11 years ago
|
||
update according to review comments, except for making nsDOMWindowUtils::AskPermission() always return NS_OK.
Attachment #8466665 -
Attachment is obsolete: true
Comment 12•11 years ago
|
||
(In reply to Shih-Chiang Chien [:schien] (UTC+8) from comment #10)
> The old code will return non-NS_OK via those NS_ENSURE_SUCCESS statement, do
> you think we should change it to always return NS_OK?
The old code does
- nsCOMPtr<nsIContentPermissionPrompt> prompt =
- do_CreateInstance(NS_CONTENT_PERMISSION_PROMPT_CONTRACTID);
- if (prompt) {
- prompt->Prompt(this);
- }
-
- return NS_OK;
so it doesn't return non-NS_OK.
I was talking about the code in nsDocument.cpp, not WindowUtils.
Flags: needinfo?(bugs)
Assignee | ||
Comment 13•11 years ago
|
||
Sorry I misread your comment, nsDocument.cpp and FileSystemPermissionRequest.cpp is updated to always return NS_OK for the compliance of old code.
try: https://tbpl.mozilla.org/?tree=Try&rev=e9345ce80340
Attachment #8466888 -
Attachment is obsolete: true
Attachment #8467479 -
Flags: review?(bugs)
Comment 14•11 years ago
|
||
Comment on attachment 8467479 [details] [diff] [review]
use-nsidomwindowutils-askpermission.patch, v3.1
>+ nsCOMPtr<nsPIDOMWindow> window = doc->GetWindow();
You wan GetInnerWindow() here
Attachment #8467479 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 15•11 years ago
|
||
update according to review comment, carry r+.
Attachment #8467479 -
Attachment is obsolete: true
Attachment #8468964 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 16•11 years ago
|
||
Keywords: checkin-needed
Comment 17•11 years ago
|
||
Backed out for Windows non-unified bustage. You can disable unified builds locally by setting --disable-unified-compilation in your .mozconfig and on Try by adding it to build/mozconfig.common.override. Sorry for the hassle :(
https://hg.mozilla.org/integration/mozilla-inbound/rev/fcedb0c795f7
https://tbpl.mozilla.org/php/getParsedLog.php?id=45439732&tree=Mozilla-Inbound
Assignee | ||
Comment 18•11 years ago
|
||
windows.h is causing the trouble, again. GetDiskFreeSpace is been redefined to GetDisFreeSpaceW. Adjusting header file including sequence will solve our problem.
https://tbpl.mozilla.org/?tree=Try&rev=580d603cd045
Assignee | ||
Comment 19•11 years ago
|
||
fix windows build error on non-unified build setting, carry r+.
Attachment #8468964 -
Attachment is obsolete: true
Attachment #8469972 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 20•11 years ago
|
||
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in
before you can comment on or make changes to this bug.
Description
•