Closed Bug 264648 Opened 20 years ago Closed 19 years ago

Implement nsOSHelperAppService::GetApplicationDescription for MacOS X

Categories

(Core Graveyard :: File Handling, defect, P2)

PowerPC
macOS
defect

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.8beta4

People

(Reporter: Biesinger, Assigned: asaf)

References

Details

Attachments

(1 file, 1 obsolete file)

to be able to show an application description in the confirmation dialog for
external protocols, nsOSHelperAppService::GetApplicationDescription should be
implemented.

this bug is about the OS X implementation.
Assignee: file-handling → bugs.mano
Priority: -- → P2
Target Milestone: --- → mozilla1.8beta4
Status: NEW → ASSIGNED
Attached patch patch v1 (obsolete) — Splinter Review
This leaks, releasing the bundle causes a crash on a second call (?) to this
method. I might fix it by checking its retain count, but I really shoudn't have
to...
Comment on attachment 189769 [details] [diff] [review]
patch v1

>Index: uriloader/exthandler/mac/nsOSHelperAppService.cpp
>===================================================================


>+    if (err == noErr) {
>+      CFBundleRef handlerBundle = ::CFBundleCreate(NULL, handlerBundleURL);

Is this the right way to get the bundle given a URL? Seems a little weird.

>+      if (handlerBundle) {
>+        // Get the human-readable name of the default handler bundle
>+        CFStringRef bundleName =
>+          (CFStringRef)::CFBundleGetValueForInfoDictionaryKey(handlerBundle,
>+                                                              kCFBundleNameKey);
>+        if (bundleName) {
>+          nsAutoBuffer<UniChar, 255> buffer;
>+          CFIndex bundleNameLength = ::CFStringGetLength(bundleName);
>+          buffer.EnsureElemCapacity(bundleNameLength);
>+          ::CFStringGetCharacters(bundleName, CFRangeMake(0, bundleNameLength),
>+                                  buffer.get());
>+          _retval.Assign(buffer.get(), bundleNameLength);
>+          rv = NS_OK;
>+          ::CFRelease(bundleName);

Don't release the result of CFBundleGetValueForInfoDictionaryKey! It't not a
'create' or 'copy' call, so it doesn't return a retained value!
Attached patch v1.1Splinter Review
Attachment #189769 - Attachment is obsolete: true
Attachment #189802 - Flags: superreview?(sfraser_bugs)
Attachment #189802 - Flags: review?(jhpedemonte)
(In reply to comment #2)

> >+    if (err == noErr) {
> >+      CFBundleRef handlerBundle = ::CFBundleCreate(NULL, handlerBundleURL);
> 
> Is this the right way to get the bundle given a URL? Seems a little weird.

AFAICT. As for using the bundle dictionary directly, this isn't really an option
-  we should take care of (per-loacle) InfoPlist.strings.
Blocks: deermac
Comment on attachment 189802 [details] [diff] [review]
v1.1

+  nsCAutoString scheme(aScheme);
+  CFStringRef schemeCFString = ::CFStringCreateWithBytes(kCFAllocatorDefault,
+							  (const UInt8
*)scheme.get(),
+							  scheme.Length(),
+							 
kCFStringEncodingUTF8,
+							  false);

It might be better to just use |PromiseFlatString()|:
  CFStringRef schemeCFString =
	    ::CFStringCreateWithBytes(kCFAllocatorDefault,
				(const UInt8*)
PromiseFlatString(aScheme).get(),
				aScheme.Length(), kCFStringEncodingUTF8,
false);

+    // Since the public API (LSGetApplicationForURL) fails every now and then,
+    // we're using undocumented _LSCopyDefaultSchemeHandlerURL

Can you remind me again: in which circumstances did |LSGetApplicationForURL|
fail?

I take it his new patch fixes the leak described earlier?

Nit: Try to keep lines around 80 chars or less.

With those fixes, r=jhpedemonte.
Attachment #189802 - Flags: review?(jhpedemonte) → review+
Flags: blocking1.8b4?
Comment on attachment 189802 [details] [diff] [review]
v1.1

sr with the review comments addressed.
Attachment #189802 - Flags: superreview?(sfraser_bugs) → superreview+
Attachment #189802 - Flags: approval1.8b4?
Attachment #189802 - Flags: approval1.8b4? → approval1.8b4+
(In reply to comment #5)

> Can you remind me again: in which circumstances did |LSGetApplicationForURL|
> fail?

The only obvious one is the case where your app is the defualt handler (at
least, it happens more often in this case). Sure, that's not an option here, but
there are were other cases it failed for me (in the mac shell service).
Checking in mac/nsOSHelperAppService.cpp;
/cvsroot/mozilla/uriloader/exthandler/mac/nsOSHelperAppService.cpp,v  <-- 
nsOSHelperAppService.cpp
new revision: 1.44; previous revision: 1.43
done
Checking in mac/nsOSHelperAppService.h;
/cvsroot/mozilla/uriloader/exthandler/mac/nsOSHelperAppService.h,v  <-- 
nsOSHelperAppService.h
new revision: 1.15; previous revision: 1.14
done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Flags: blocking1.8b4?
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: