зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1432285 - Implement an nsPrintingPromptService::GetSingleton method and make XPCOM use that. r=bobowen
MozReview-Commit-ID: AsiAnJrxKlB
This commit is contained in:
Родитель
98d61a685f
Коммит
eec7e0d104
|
@ -5,12 +5,16 @@
|
|||
|
||||
#include "nsPrintingPromptService.h"
|
||||
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPrintDialogService.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
// Printing Progress Includes
|
||||
#if !defined(XP_MACOSX)
|
||||
|
@ -23,10 +27,31 @@ static const char* kPrtPrvProgressDialogURL =
|
|||
"chrome://global/content/printPreviewProgress.xul";
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsPrintingPromptService,
|
||||
nsIPrintingPromptService,
|
||||
nsIWebProgressListener)
|
||||
|
||||
|
||||
StaticRefPtr<nsPrintingPromptService> sSingleton;
|
||||
|
||||
/* static */ already_AddRefed<nsPrintingPromptService>
|
||||
nsPrintingPromptService::GetSingleton()
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess(),
|
||||
"The content process must use nsPrintingProxy");
|
||||
|
||||
if (!sSingleton) {
|
||||
sSingleton = new nsPrintingPromptService();
|
||||
sSingleton->Init();
|
||||
ClearOnShutdown(&sSingleton);
|
||||
}
|
||||
|
||||
return do_AddRef(sSingleton);
|
||||
}
|
||||
|
||||
|
||||
nsPrintingPromptService::nsPrintingPromptService() = default;
|
||||
|
||||
nsPrintingPromptService::~nsPrintingPromptService() = default;
|
||||
|
|
|
@ -31,22 +31,21 @@ class nsIDOMWindow;
|
|||
class nsIDialogParamBlock;
|
||||
#endif
|
||||
|
||||
class nsPrintingPromptService
|
||||
class nsPrintingPromptService final
|
||||
: public nsIPrintingPromptService
|
||||
, public nsIWebProgressListener
|
||||
{
|
||||
|
||||
public:
|
||||
nsPrintingPromptService();
|
||||
|
||||
nsresult Init();
|
||||
static already_AddRefed<nsPrintingPromptService> GetSingleton();
|
||||
|
||||
NS_DECL_NSIPRINTINGPROMPTSERVICE
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
protected:
|
||||
nsPrintingPromptService();
|
||||
virtual ~nsPrintingPromptService();
|
||||
nsresult Init();
|
||||
|
||||
private:
|
||||
#if !defined(XP_MACOSX)
|
||||
|
|
|
@ -38,7 +38,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsBaseCommandController)
|
|||
#ifdef MOZ_XUL
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock)
|
||||
#ifdef NS_PRINTING
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintingPromptService, Init)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPrintingPromptService,
|
||||
nsPrintingPromptService::GetSingleton)
|
||||
#ifdef PROXY_PRINTING
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPrintingProxy,
|
||||
nsPrintingProxy::GetInstance)
|
||||
|
|
Загрузка…
Ссылка в новой задаче