accessible/build/nsAccessibilityFactory.cpp
author Ehsan Akhgari <ehsan@mozilla.com>
Wed, 23 May 2012 17:51:50 -0400
changeset 94806 26d651834b0eb13daeb92f8ba556c98b765a6576
parent 94475 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 100844 b5c4b792f3f2a047e3517472d72842a76afb77cd
permissions -rw-r--r--
Bug 757885 - Handle falling back to non-staged updates correctly when an update fails to be staged in the background; r=rstrong

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsCOMPtr.h"
#include "mozilla/ModuleUtils.h"

#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIAccessibilityService.h"
#include "nsIAccessibleRetrieval.h"
#include "nscore.h"

static nsresult
NS_ConstructAccessibilityService(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
    nsresult rv;
    NS_ASSERTION(aOuter == nsnull, "no aggregation");
    nsIAccessibilityService* accessibility;
    rv = NS_GetAccessibilityService(&accessibility);
    if (NS_FAILED(rv)) {
        NS_ERROR("Unable to construct accessibility service");
        return rv;
    }
    rv = accessibility->QueryInterface(aIID, aResult);
    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
    NS_RELEASE(accessibility);
    return rv;
}

NS_DEFINE_NAMED_CID(NS_ACCESSIBILITY_SERVICE_CID);

static const mozilla::Module::CIDEntry kA11yCIDs[] = {
    { &kNS_ACCESSIBILITY_SERVICE_CID, false, NULL, NS_ConstructAccessibilityService },
    { NULL }
};

static const mozilla::Module::ContractIDEntry kA11yContracts[] = {
    { "@mozilla.org/accessibilityService;1", &kNS_ACCESSIBILITY_SERVICE_CID },
    { "@mozilla.org/accessibleRetrieval;1", &kNS_ACCESSIBILITY_SERVICE_CID },
    { NULL }
};

static const mozilla::Module kA11yModule = {
    mozilla::Module::kVersion,
    kA11yCIDs,
    kA11yContracts
};

NSMODULE_DEFN(nsAccessibilityModule) = &kA11yModule;