browser/metro/components/DirectoryProvider.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 const Cc = Components.classes;
     6 const Ci = Components.interfaces;
     8 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    10 // -----------------------------------------------------------------------
    11 // Directory Provider for special browser folders and files
    12 // -----------------------------------------------------------------------
    14 const NS_APP_CACHE_PARENT_DIR = "cachePDir";
    16 function DirectoryProvider() {}
    18 DirectoryProvider.prototype = {
    19   classID: Components.ID("{ef0f7a87-c1ee-45a8-8d67-26f586e46a4b}"),
    21   QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider]),
    23   getFile: function(prop, persistent) {
    24     if (prop == NS_APP_CACHE_PARENT_DIR) {
    25       let dirsvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
    26       let profile = dirsvc.get("ProfD", Ci.nsIFile);
    28       let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
    29       let device = sysInfo.get("device");
    30       switch (device) {
    31         default:
    32           return profile;
    33       }
    34     }
    36     // We are retuning null to show failure instead for throwing an error. The
    37     // interface is called quite a bit and throwing an error is noisy. Returning
    38     // null works with the way the interface is called [see bug 529077]
    39     return null;
    40   }
    41 };
    43 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DirectoryProvider]);

mercurial