Closed
Bug 125324
Opened 23 years ago
Closed 21 years ago
Improper use of nsIDirectoryServiceProvider
Categories
(SeaMonkey :: UI Design, defect)
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: ccarlen, Assigned: timeless)
Details
Attachments
(1 file, 2 obsolete files)
1.96 KB,
patch
|
ccarlen
:
review+
jag+mozilla
:
superreview+
|
Details | Diff | Splinter Review |
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/xpfe/components/filepicker/res/content/filepicker.js#133
This code is getting a file location directly from a provider instead of
nsIDirectoryService. It happens to work because the object with the conract ID
"@mozilla.org/file/directory_service;1" happens to implement
nsIDirectoryServiceProvider as well as nsIDirectoryService and that provider
happens to provide the "Home" location. The service should not be QI'able to a
provider. It breaks the contract that when the service is asked for a file
location, registered providers are consulted.
BTW, somebody just asked me why their js code using directory service wasn't
working. It was because they used this code as an example ;-)
The code should do something like this:
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService( Components.interfaces.nsIProperties );
homeDir = dirSvc.get("Home", Components.interfaces.nsIFile);
Comment on attachment 108513 [details] [diff] [review]
this should work
i ran the changes through xpcshell on windows, but someone should test the
xpfilepicker itself :)
Attachment #108513 -
Flags: superreview?(bzbarsky)
Attachment #108513 -
Flags: review?(akkana)
Reporter | ||
Comment 5•22 years ago
|
||
+ var dirServiceProvider = Components.classes[nsIDirectoryService_CONTRACTID]
+ .getService(nsIDirectoryService);
You want nsIProperties here, not nsIDirectoryService. The latter has no "get."
Also, I'd change the name of "dirServiceProvider" to "dirService."
var persistent = new Object();
- homeDir = dirServiceProvider.getFile("Home", persistent);
+ homeDir = dirServiceProvider.get("Home", Components.interfaces.nsIFile,
persistent);
per ccarlen
Attachment #108513 -
Attachment is obsolete: true
![]() |
||
Comment 7•22 years ago
|
||
Comment on attachment 108679 [details] [diff] [review]
better
homeDir is used elsewhere in this file; not initializing it is a bad idea.
Attachment #108679 -
Flags: superreview-
![]() |
||
Updated•22 years ago
|
Attachment #108513 -
Flags: superreview?(bzbarsky)
Attachment #108513 -
Flags: review?(akkana)
Attachment #108679 -
Attachment is obsolete: true
Attachment #129315 -
Flags: superreview?(jaggernaut)
Attachment #129315 -
Flags: review?(ccarlen)
Comment 9•22 years ago
|
||
Comment on attachment 129315 [details] [diff] [review]
ok
>Index: mozilla/xpfe/components/filepicker/res/content/filepicker.js
>===================================================================
>+const nsIProperties = Components.interfaces.nsIProperties;
>+const nsIDirectoryService_CONTRACTID = "@mozilla.org/file/directory_service;1";
This should really be |NS_DIRECTORYSERVICE_CONTRACTID|, or
|nsDirectoryService_CONTRACTID| to keep in this file's style. I think the only
accepted exceptions in our js code to "constants should be all uppercase" are
the interface consts which are used as shortcuts for Components.interfaces.*.
Attachment #129315 -
Flags: superreview?(jaggernaut) → superreview+
Reporter | ||
Comment 10•22 years ago
|
||
Comment on attachment 129315 [details] [diff] [review]
ok
thanks. r=ccarlen.
Attachment #129315 -
Flags: review?(ccarlen) → review+
Assignee | ||
Comment 11•21 years ago
|
||
mozilla/xpfe/components/filepicker/res/content/filepicker.js 1.86
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Verified FIXED
Status: RESOLVED → VERIFIED
Updated•20 years ago
|
Product: Core → Mozilla Application Suite
You need to log in
before you can comment on or make changes to this bug.
Description
•