Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/src/GeckoContentHandler.cpp
blob: c3785cfcb20afee87110116e09792e6ab23ad217 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <nsCExternalHandlerService.h>
#include <nsIFile.h>
#include <nsIFactory.h>

#include "GeckoContentHandler.h"

class GeckoContentHandler : public nsIHelperAppLauncherDialog
{
public:
    NS_DECL_ISUPPORTS
    NS_DECL_NSIHELPERAPPLAUNCHERDIALOG

    GeckoContentHandler();
    virtual ~GeckoContentHandler();
};

GeckoContentHandler::GeckoContentHandler()
{

}

GeckoContentHandler::~GeckoContentHandler()
{

}

NS_IMPL_ISUPPORTS1(GeckoContentHandler, nsIHelperAppLauncherDialog)

NS_IMETHODIMP
GeckoContentHandler::Show (nsIHelperAppLauncher *aLauncher,
						   nsISupports *aContext,
						   PRUint32 aReason)
{	
	nsCOMPtr<nsIFile> tmpFile;
	aLauncher->GetTargetFile(getter_AddRefs(tmpFile));
		
	aLauncher->SaveToDisk (tmpFile, PR_FALSE);

	return NS_OK;
}

NS_IMETHODIMP
GeckoContentHandler::PromptForSaveToFile (nsIHelperAppLauncher *aLauncher,			    
										  nsISupports *aWindowContext,
										  const PRUnichar *aDefaultFile,
										  const PRUnichar *aSuggestedFileExtension,
										  nsILocalFile **_retval)
{
	return NS_OK;
}

//*****************************************************************************
// GeckoContentHandlerFactory
//*****************************************************************************

class GeckoContentHandlerFactory : public nsIFactory {
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIFACTORY

  GeckoContentHandlerFactory();
  virtual ~GeckoContentHandlerFactory();
};

//*****************************************************************************

NS_IMPL_ISUPPORTS1(GeckoContentHandlerFactory, nsIFactory)

GeckoContentHandlerFactory::GeckoContentHandlerFactory() {
}

GeckoContentHandlerFactory::~GeckoContentHandlerFactory() {
}

NS_IMETHODIMP
GeckoContentHandlerFactory::CreateInstance(nsISupports *aOuter,
                                           const nsIID & aIID,
                                           void **aResult)
{
    NS_ENSURE_ARG_POINTER(aResult);

    *aResult = NULL;
    GeckoContentHandler *inst = new GeckoContentHandler;
    if (!inst)
        return NS_ERROR_OUT_OF_MEMORY;

    nsresult rv = inst->QueryInterface(aIID, aResult);
    if (rv != NS_OK) {
        // We didn't get the right interface, so clean up
        delete inst;
    }

    return rv;
}

NS_IMETHODIMP
GeckoContentHandlerFactory::LockFactory(PRBool lock)
{
    return NS_OK;
}

//*****************************************************************************

nsresult
NS_NewGeckoContentHandlerFactory(nsIFactory** aFactory)
{
    NS_ENSURE_ARG_POINTER(aFactory);
    *aFactory = nsnull;

    GeckoContentHandlerFactory *result = new GeckoContentHandlerFactory;
    if (!result)
        return NS_ERROR_OUT_OF_MEMORY;

    NS_ADDREF(result);
    *aFactory = result;

    return NS_OK;
}