Bug 797349 - Add support for metadata::download-uri for later display in file manager by GIO. r=Neil
authorJan Horak <jhorak@redhat.com>
Mon, 08 Oct 2012 01:46:00 -0700
changeset 109785 0008531f142915d1eb874731c387e26c2f072bf6
parent 109784 4210c1f677e5985bc2ee79344ce7fd0ebb5d2ab3
child 109786 7bf353b1ae55d5328f8d1e029c2939eb77351a76
push id16199
push usermozilla@noorenberghe.ca
push dateTue, 09 Oct 2012 20:54:15 +0000
treeherdermozilla-inbound@0008531f1429 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs797349
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 797349 - Add support for metadata::download-uri for later display in file manager by GIO. r=Neil
toolkit/components/downloads/nsDownloadManager.cpp
--- a/toolkit/components/downloads/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/nsDownloadManager.cpp
@@ -2321,16 +2321,28 @@ nsDownload::SetState(DownloadState aStat
             gchar* uri = g_filename_to_uri(NS_ConvertUTF16toUTF8(path).get(),
                                            NULL, NULL);
             if (uri) {
               gtk_recent_manager_add_item(manager, uri);
               g_free(uri);
             }
 #endif
           }
+#ifdef MOZ_ENABLE_GIO
+          // Use GIO to store the source URI for later display in the file manager.
+          GFile* gio_file = g_file_new_for_path(NS_ConvertUTF16toUTF8(path).get());
+          nsCString source_uri;
+          mSource->GetSpec(source_uri);
+
+          g_file_set_attribute(gio_file, "metadata::download-uri",
+                               G_FILE_ATTRIBUTE_TYPE_STRING,
+                               (gpointer)source_uri.get(),
+                               G_FILE_QUERY_INFO_NONE, NULL, NULL);
+          g_object_unref(gio_file);
+#endif
         }
 #endif
 #ifdef XP_MACOSX
         // On OS X, make the downloads stack bounce.
         CFStringRef observedObject = ::CFStringCreateWithCString(kCFAllocatorDefault,
                                                  NS_ConvertUTF16toUTF8(path).get(),
                                                  kCFStringEncodingUTF8);
         CFNotificationCenterRef center = ::CFNotificationCenterGetDistributedCenter();