unknown file type

kmeleon10_branch
binaryc 21 years ago
parent 994329e2ec
commit 9658575777
  1. 8
      k-meleon/KMeleon.dsp
  2. 15
      k-meleon/MfcEmbed.cpp
  3. 9
      k-meleon/StdAfx.h
  4. 74
      k-meleon/UnknownContentTypeHandler.cpp

@ -158,6 +158,10 @@ SOURCE=.\Dialogs.cpp
# End Source File
# Begin Source File
SOURCE=.\HiddenWnd.cpp
# End Source File
# Begin Source File
SOURCE=.\MenuParser.cpp
# End Source File
# Begin Source File
@ -211,6 +215,10 @@ SOURCE=.\ToolBarEx.cpp
# End Source File
# Begin Source File
SOURCE=.\UnknownContentTypeHandler.cpp
# End Source File
# Begin Source File
SOURCE=.\Utils.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File

@ -49,7 +49,7 @@
#include "BrowserImpl.h"
#include "nsIWindowWatcher.h"
#include "kmeleonConst.h"
//#include "UnknownContentTypeHandler.h"
#include "UnknownContentTypeHandler.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -132,7 +132,7 @@ nsresult CMfcEmbedApp::OverrideComponents()
} else
::FreeLibrary(overlib);
}
/*
// Override the UnknownContentHandler
nsCOMPtr<nsIFactory> unkFactory;
rv = NewUnknownContentHandlerFactory(getter_AddRefs(unkFactory));
@ -142,15 +142,13 @@ nsresult CMfcEmbedApp::OverrideComponents()
NS_IUNKNOWNCONTENTTYPEHANDLER_CONTRACTID ,
unkFactory,
PR_TRUE); // replace existing
*/
/*
rv = nsComponentManager::RegisterFactory(kUnknownContentTypeHandlerCID,
NS_IHELPERAPPLAUNCHERDLG_CLASSNAME,
NS_IHELPERAPPLAUNCHERDLG_CONTRACTID,
unkFactory,
PR_TRUE); // replace existing
*/
/*
// Override the nsIHelperAppLauncherDialog
nsCOMPtr<nsIFactory> helpFactory;
@ -326,6 +324,9 @@ CBrowserFrame* CMfcEmbedApp::CreateNewBrowserFrame(PRUint32 chromeMask,
// at the end of this function
CBrowserFrame* pOldRecentFrame = m_pMostRecentBrowserFrame;
theApp.m_pMostRecentBrowserFrame = pFrame;
if (!pOldRecentFrame)
pOldRecentFrame = pFrame;
// restore the saved window size
RECT winSize;
@ -509,8 +510,8 @@ BOOL CMfcEmbedApp::OnIdle(LONG lCount)
}
void CMfcEmbedApp::OnPreferences () {
CPreferencesDlg prefDlg;
prefDlg.DoModal();
CPreferencesDlg prefDlg;
prefDlg.DoModal();
}
void CMfcEmbedApp::OnManageProfiles()

@ -82,11 +82,18 @@
#include "nsIEmbeddingSiteWindow.h"
#include "nsIWebBrowserFind.h"
#include "nsIWebBrowserFocus.h"
#include "nsIWebProgress.h"
// Printing
#include "nsIPrintOptions.h"
#include "nsIWebBrowserPrint.h"
#include "nsIDOMWindow.h"
#include "nsIDOMWindow.h"
// Unknown Content Type Handler
#include "nsIUnkContentTypeHandler.h"
#include "nsIHelperAppLauncherDialog.h"
#include "nsIExternalHelperAppService.h"
#include "nsIHelperAppLauncherDialog.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

@ -31,6 +31,7 @@ extern CMfcEmbedApp theApp;
// HandleUnknownContentType (from nsIUnknownContentTypeHandler) implementation.
// XXX We can get the content type from the channel now so that arg could be dropped.
NS_IMETHODIMP
CUnknownContentTypeHandler::HandleUnknownContentType( nsIRequest *request,
const char *aContentType,
@ -41,8 +42,10 @@ CUnknownContentTypeHandler::HandleUnknownContentType( nsIRequest *request,
nsCOMPtr<nsISupports> channel;
nsCAutoString contentDisp;
MessageBox(NULL, "CHandleUnknownContentType()", NULL, MB_OK);
/*
// this function never seems to get called...
MessageBox(NULL, "CHandleUnknownContentType()", NULL, MB_OK);
/*
if ( request ) {
aChannel = do_QueryInterface(request);
@ -122,53 +125,20 @@ CUnknownContentTypeHandler::HandleUnknownContentType( nsIRequest *request,
rv = NS_ERROR_NULL_POINTER;
}
}
*/
*/
return rv;
}
NS_IMETHODIMP
CUnknownContentTypeHandler::ShowProgressDialog(nsIHelperAppLauncher *aLauncher, nsISupports *aContext ) {
nsresult rv = NS_ERROR_FAILURE;
// this is here because mozilla won't do anything untill we call this function
// eventually we should probably pop up a "file saving" box or something
aLauncher->SetWebProgressListener (NULL);
return NS_OK;
/*
// Get parent window (from context).
nsCOMPtr<nsIDOMWindowInternal> parent( do_GetInterface( aContext ) );
if ( parent ) {
// Get JS context from parent window.
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface( parent, &rv );
if ( NS_SUCCEEDED( rv ) && sgo ) {
nsCOMPtr<nsIScriptContext> context;
sgo->GetContext( getter_AddRefs( context ) );
if ( context ) {
// Get native context.
JSContext *jsContext = (JSContext*)context->GetNativeContext();
if ( jsContext ) {
// Set up window.arguments[0]...
void *stackPtr;
jsval *argv = JS_PushArguments( jsContext,
&stackPtr,
"sss%ip",
"chrome://global/content/helperAppDldProgress.xul",
"_blank",
"chrome,titlebar,minimizable",
(const nsIID*)(&NS_GET_IID(nsIHelperAppLauncher)),
(nsISupports*)aLauncher );
if ( argv ) {
// Open the dialog.
nsCOMPtr<nsIDOMWindowInternal> dialog;
rv = parent->OpenDialog( jsContext, argv, 4, getter_AddRefs( dialog ) );
// Pop arguments.
JS_PopArguments( jsContext, stackPtr );
}
}
}
}
}
*/
return rv;
}
// Show the helper app launch confirmation dialog as instructed.
@ -188,6 +158,8 @@ CUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher, nsISupports *
NS_IMETHODIMP
CUnknownContentTypeHandler::PromptForSaveToFile(nsISupports * aWindowContext, const PRUnichar * aDefaultFile, const PRUnichar * aSuggestedFileExtension, nsILocalFile ** aNewFile)
{
// change this to 0 to use the mozilla file picker
#if 1
USES_CONVERSION;
CString filter = W2T(aSuggestedFileExtension);
@ -213,23 +185,16 @@ CUnknownContentTypeHandler::PromptForSaveToFile(nsISupports * aWindowContext, co
}
return NS_ERROR_FAILURE;
#else
nsresult rv = NS_OK;
/*
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv);
if (filePicker)
{
nsCOMPtr<nsIStringBundleService> stringService = do_GetService(kStringBundleServiceCID);
nsCOMPtr<nsIStringBundle> stringBundle;
NS_ENSURE_TRUE(stringService, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(stringService->CreateBundle(HELPERAPP_DIALOG_URL, nsnull, getter_AddRefs(stringBundle)),
NS_ERROR_FAILURE);
nsXPIDLString windowTitle;
stringBundle->GetStringFromName(NS_LITERAL_STRING("saveDialogTitle").get(), getter_Copies(windowTitle));
nsAFlatString title = NS_LITERAL_STRING ("Save As:");
nsCOMPtr<nsIDOMWindowInternal> parent( do_GetInterface( aWindowContext ) );
filePicker->Init(parent, windowTitle, nsIFilePicker::modeSave);
filePicker->Init(parent, title.get(), nsIFilePicker::modeSave);
filePicker->SetDefaultString(aDefaultFile);
nsAutoString wildCardExtension (NS_LITERAL_STRING("*").get());
if (aSuggestedFileExtension) {
@ -273,9 +238,8 @@ CUnknownContentTypeHandler::PromptForSaveToFile(nsISupports * aWindowContext, co
}
}
}
*/
return NS_OK;
return NS_OK;
#endif
}

Loading…
Cancel
Save