mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-07 11:56:51 +00:00
Added preliminary cookie support. Enabled preferences to be read from the default preference file. Corrected/Added DWebBrowser events: DownloadBegin, DownloadComplete, StatusTextChange, and TitleChange. Added support for ExecWB->SaveAs.
This commit is contained in:
parent
7666a6499e
commit
49ed694236
@ -23,6 +23,8 @@
|
||||
#include "stdafx.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <objidl.h>
|
||||
#include <comdef.h>
|
||||
|
||||
#include "MozillaControl.h"
|
||||
#include "MozillaBrowser.h"
|
||||
@ -77,6 +79,7 @@ CMozillaBrowser::CMozillaBrowser()
|
||||
|
||||
// Initialize layout interfaces
|
||||
m_pIWebShell = nsnull;
|
||||
|
||||
m_pIPref = nsnull;
|
||||
m_pIServiceManager = nsnull;
|
||||
|
||||
@ -132,7 +135,7 @@ STDMETHODIMP CMozillaBrowser::InterfaceSupportsErrorInfo(REFIID riid)
|
||||
&IID_IWebBrowser2,
|
||||
&IID_IWebBrowserApp
|
||||
};
|
||||
for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
|
||||
for (int i=0;i<(sizeof(arr)/sizeof(arr[0]));i++)
|
||||
{
|
||||
if (InlineIsEqualGUID(*arr[i],riid))
|
||||
return S_OK;
|
||||
@ -263,6 +266,8 @@ LRESULT CMozillaBrowser::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
|
||||
// Handle WM_PAINT windows message (and IViewObject::Draw)
|
||||
HRESULT CMozillaBrowser::OnDraw(ATL_DRAWINFO& di)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnDraw);
|
||||
|
||||
if (m_pIWebShell == nsnull)
|
||||
{
|
||||
RECT& rc = *(RECT*)di.prcBounds;
|
||||
@ -273,19 +278,22 @@ HRESULT CMozillaBrowser::OnDraw(ATL_DRAWINFO& di)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
// Handle ID_PAGESETUP command
|
||||
LRESULT CMozillaBrowser::OnPageSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnPageSetup);
|
||||
MessageBox(_T("No page setup yet!"), _T("Control Message"), MB_OK);
|
||||
|
||||
// TODO show the page setup dialog
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Handle ID_PRINT command
|
||||
LRESULT CMozillaBrowser::OnPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnPrint);
|
||||
|
||||
nsresult res;
|
||||
|
||||
// Print the contents
|
||||
@ -306,13 +314,107 @@ LRESULT CMozillaBrowser::OnPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
|
||||
|
||||
LRESULT CMozillaBrowser::OnSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
MessageBox(_T("No Save As Yet!"), _T("Control Message"), MB_OK);
|
||||
// TODO show the save as dialog
|
||||
return 0;
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnSaveAs);
|
||||
|
||||
OPENFILENAME SaveFileName;
|
||||
|
||||
char szFile[256];
|
||||
char szFileTitle[256];
|
||||
BSTR pageName = NULL;
|
||||
|
||||
SaveFileName.lStructSize = sizeof(SaveFileName);
|
||||
SaveFileName.hwndOwner = m_hWnd;
|
||||
SaveFileName.hInstance = NULL;
|
||||
SaveFileName.lpstrFilter = "Web Page, HTML Only (*.htm;*.html)\0*.htm;*.html\0Text File (*.txt)\0*.txt\0";
|
||||
//TODO: The IE control allows you to also save as "Web Page, complete" where all of the page's images are saved
|
||||
// in a directory along with the web page. This doesn't appear to be directly supported by Mozilla, but
|
||||
// could be implemented here if deemed necessary. (Web Page, complete (*.htm;*.html)\0*.htm;*.html\0)
|
||||
SaveFileName.lpstrCustomFilter = NULL;
|
||||
SaveFileName.nMaxCustFilter = NULL;
|
||||
SaveFileName.nFilterIndex = 1;
|
||||
SaveFileName.lpstrFile = szFile;
|
||||
SaveFileName.nMaxFile = sizeof(szFile);
|
||||
SaveFileName.lpstrFileTitle = szFileTitle;
|
||||
SaveFileName.nMaxFileTitle = sizeof(szFileTitle);
|
||||
SaveFileName.lpstrInitialDir = NULL;
|
||||
SaveFileName.lpstrTitle = NULL;
|
||||
SaveFileName.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
||||
SaveFileName.nFileOffset = NULL;
|
||||
SaveFileName.nFileExtension = NULL;
|
||||
SaveFileName.lpstrDefExt = "htm";
|
||||
SaveFileName.lCustData = NULL;
|
||||
SaveFileName.lpfnHook = NULL;
|
||||
SaveFileName.lpTemplateName = NULL;
|
||||
|
||||
|
||||
//Get the title of the current web page to set as the default filename.
|
||||
char szTmp[256];
|
||||
get_LocationName(&pageName);
|
||||
strcpy(szTmp, _bstr_t(pageName));
|
||||
|
||||
int j = 0; //The SaveAs dialog will fail if szFile contains any "bad" characters.
|
||||
for (int i=0; szTmp[i]!='\0'; i++) { //This hunk of code attempts to mimick the IE way of replacing "bad"
|
||||
switch(szTmp[i]) { //characters with "good" characters.
|
||||
case '\\':
|
||||
case '*':
|
||||
case '|':
|
||||
case ':':
|
||||
case '"':
|
||||
case '>':
|
||||
case '<':
|
||||
case '?':
|
||||
break;
|
||||
case '.':
|
||||
if (szTmp[i+1] != '\0') {
|
||||
szFile[j] = '_';
|
||||
j++;
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
szFile[j] = '-';
|
||||
j++;
|
||||
break;
|
||||
default:
|
||||
szFile[j] = szTmp[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
szFile[j] = '\0';
|
||||
|
||||
HRESULT res = S_OK;
|
||||
if ( GetSaveFileName(&SaveFileName) ) {
|
||||
//Get the current DOM document
|
||||
nsIDOMDocument* pDocument = nsnull;
|
||||
res = GetDOMDocument(&pDocument);
|
||||
if ( FAILED(res) )
|
||||
return res;
|
||||
|
||||
//Get an nsIDiskDocument interface to the DOM document
|
||||
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(pDocument);
|
||||
if (!diskDoc)
|
||||
return E_NOINTERFACE;
|
||||
|
||||
//Set the file type specified by the user
|
||||
//Add the correct file extension if none is specified
|
||||
nsIDiskDocument::ESaveFileType saveFileType;
|
||||
if ( SaveFileName.nFilterIndex == 2 ) //SaveAs text file
|
||||
saveFileType = nsIDiskDocument::eSaveFileText;
|
||||
else //SaveAs html file
|
||||
saveFileType = nsIDiskDocument::eSaveFileHTML;
|
||||
|
||||
//Create an nsFilelSpec from the selected file path.
|
||||
nsFileSpec fileSpec(szFile, PR_FALSE);
|
||||
|
||||
//Save the file.
|
||||
res = diskDoc->SaveFile(&fileSpec, PR_TRUE, PR_TRUE, saveFileType, "");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
LRESULT CMozillaBrowser::OnProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnProperties);
|
||||
|
||||
MessageBox(_T("No Properties Yet!"), _T("Control Message"), MB_OK);
|
||||
// TODO show the properties dialog
|
||||
return 0;
|
||||
@ -320,6 +422,8 @@ LRESULT CMozillaBrowser::OnProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl,
|
||||
|
||||
LRESULT CMozillaBrowser::OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnCut);
|
||||
|
||||
nsresult res;
|
||||
|
||||
nsIPresShell* pIPresShell = nsnull;
|
||||
@ -345,6 +449,8 @@ LRESULT CMozillaBrowser::OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
|
||||
|
||||
LRESULT CMozillaBrowser::OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnCopy);
|
||||
|
||||
nsresult res;
|
||||
|
||||
nsIPresShell* pIPresShell = nsnull;
|
||||
@ -362,6 +468,8 @@ LRESULT CMozillaBrowser::OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
|
||||
|
||||
LRESULT CMozillaBrowser::OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnPaste);
|
||||
|
||||
MessageBox(_T("No Paste Yet!"), _T("Control Message"), MB_OK);
|
||||
// TODO enable pasting
|
||||
return 0;
|
||||
@ -369,6 +477,8 @@ LRESULT CMozillaBrowser::OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
|
||||
|
||||
LRESULT CMozillaBrowser::OnSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnSelectAll);
|
||||
|
||||
MessageBox(_T("No Select All Yet!"), _T("Control Message"), MB_OK);
|
||||
// TODO enable Select All
|
||||
return 0;
|
||||
@ -376,7 +486,9 @@ LRESULT CMozillaBrowser::OnSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, B
|
||||
|
||||
// Handle ID_VIEWSOURCE command
|
||||
LRESULT CMozillaBrowser::OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
|
||||
{
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnViewSource);
|
||||
|
||||
// Get the url from the web shell
|
||||
const PRUnichar *pszUrl = nsnull;
|
||||
PRInt32 aHistoryIndex;
|
||||
@ -438,10 +550,11 @@ LRESULT CMozillaBrowser::OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl,
|
||||
// Test if the browser is in a valid state
|
||||
BOOL CMozillaBrowser::IsValid()
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::IsValid);
|
||||
|
||||
return (m_pIWebShell == nsnull) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
@ -525,7 +638,7 @@ HRESULT CMozillaBrowser::TermWebShell()
|
||||
|
||||
// Create and initialise the web shell
|
||||
HRESULT CMozillaBrowser::CreateWebShell()
|
||||
{
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::CreateWebShell);
|
||||
|
||||
if (m_pIWebShell != nsnull)
|
||||
@ -544,7 +657,7 @@ HRESULT CMozillaBrowser::CreateWebShell()
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// Load preferences
|
||||
// Load preferences service
|
||||
rv = nsServiceManager::GetService(kPrefCID,
|
||||
nsIPref::GetIID(),
|
||||
(nsISupports **)&m_pIPref);
|
||||
@ -555,6 +668,10 @@ HRESULT CMozillaBrowser::CreateWebShell()
|
||||
m_sErrorMessage = _T("Error - could not create preference object");
|
||||
return E_FAIL;
|
||||
}
|
||||
else {
|
||||
rv = m_pIPref->StartUp(); //Initialize the preference service
|
||||
rv = m_pIPref->ReadUserPrefs(); //Reads from default_prefs.js
|
||||
}
|
||||
|
||||
// Create the web shell object
|
||||
rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull,
|
||||
@ -568,6 +685,13 @@ HRESULT CMozillaBrowser::CreateWebShell()
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Register the cookie service
|
||||
NS_WITH_SERVICE(nsICookieService, cookieService, kCookieServiceCID, &rv);
|
||||
if (NS_FAILED(rv) || (cookieService == nsnull)) {
|
||||
NG_TRACE(_T("Could not register the cookie manager. rv=%08x\n"), (int) rv);
|
||||
}
|
||||
// TODO make the cookie service persistent. Currently does not save or load cookies to/from disk.
|
||||
|
||||
// Initialise the web shell, making it fit the control dimensions
|
||||
|
||||
nsRect r;
|
||||
@ -585,6 +709,7 @@ HRESULT CMozillaBrowser::CreateWebShell()
|
||||
nsScrollPreference_kAuto,
|
||||
aAllowPlugins,
|
||||
aIsSunkenBorder);
|
||||
|
||||
NG_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
// Create the container object
|
||||
@ -606,6 +731,8 @@ HRESULT CMozillaBrowser::CreateWebShell()
|
||||
// Turns the editor mode on or off
|
||||
HRESULT CMozillaBrowser::SetEditorMode(BOOL bEnabled)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::SetEditorMode);
|
||||
|
||||
m_bEditorMode = FALSE;
|
||||
if (bEnabled && m_pEditor == nsnull)
|
||||
{
|
||||
@ -663,6 +790,8 @@ HRESULT CMozillaBrowser::SetEditorMode(BOOL bEnabled)
|
||||
|
||||
HRESULT CMozillaBrowser::OnEditorCommand(DWORD nCmdID)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::OnEditorCommand);
|
||||
|
||||
static nsIAtom * propB = NS_NewAtom("b");
|
||||
static nsIAtom * propI = NS_NewAtom("i");
|
||||
static nsIAtom * propU = NS_NewAtom("u");
|
||||
@ -731,6 +860,7 @@ HRESULT CMozillaBrowser::OnEditorCommand(DWORD nCmdID)
|
||||
HRESULT CMozillaBrowser::GetPresShell(nsIPresShell **pPresShell)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::GetPresShell);
|
||||
|
||||
nsresult res;
|
||||
|
||||
// Test for stupid args
|
||||
@ -776,6 +906,7 @@ HRESULT CMozillaBrowser::GetPresShell(nsIPresShell **pPresShell)
|
||||
HRESULT CMozillaBrowser::GetDOMDocument(nsIDOMDocument **pDocument)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::GetDOMDocument);
|
||||
|
||||
nsresult res;
|
||||
|
||||
// Test for stupid args
|
||||
@ -921,6 +1052,8 @@ HRESULT CMozillaBrowser::UnloadBrowserHelpers()
|
||||
|
||||
HRESULT CMozillaBrowser::InPlaceActivate(LONG iVerb, const RECT* prcPosRect)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::InPlaceActivate);
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
if (m_spClientSite == NULL)
|
||||
@ -1055,6 +1188,8 @@ HRESULT CMozillaBrowser::InPlaceActivate(LONG iVerb, const RECT* prcPosRect)
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMozillaBrowser::GetClientSite(IOleClientSite **ppClientSite)
|
||||
{
|
||||
NG_TRACE_METHOD(CMozillaBrowser::GetClientSite);
|
||||
|
||||
NG_ASSERT(ppClientSite);
|
||||
|
||||
// This fixes a problem in the base class which asserts if the client
|
||||
@ -1140,7 +1275,6 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoHome(void)
|
||||
sUrl = A2T(szBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
// Navigate to the home page
|
||||
Navigate(T2OLE(sUrl), NULL, NULL, NULL, NULL);
|
||||
|
||||
@ -1167,7 +1301,6 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoSearch(void)
|
||||
// TODO find and navigate to the search page stored in prefs
|
||||
// and not this hard coded address
|
||||
}
|
||||
|
||||
Navigate(T2OLE(sUrl), NULL, NULL, NULL, NULL);
|
||||
|
||||
return S_OK;
|
||||
@ -1215,7 +1348,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR
|
||||
Flags->vt != VT_NULL)
|
||||
{
|
||||
CComVariant vFlags;
|
||||
if (vFlags.ChangeType(VT_I4, Flags) != S_OK)
|
||||
if ( vFlags.ChangeType(VT_I4, Flags) != S_OK )
|
||||
{
|
||||
NG_ASSERT(0);
|
||||
RETURN_E_INVALIDARG();
|
||||
@ -1260,7 +1393,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR
|
||||
lFlags &= ~(navOpenInNewWindow);
|
||||
if ((bCancel == VARIANT_FALSE) && spDispNew)
|
||||
{
|
||||
CIPtr(IWebBrowser2) spOther = spDispNew;;
|
||||
CIPtr(IWebBrowser2) spOther = spDispNew;
|
||||
if (spOther)
|
||||
{
|
||||
CComVariant vURL(URL);
|
||||
@ -1291,7 +1424,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR
|
||||
// Load the URL
|
||||
char *tmpCommand = sCommand.ToNewCString();
|
||||
nsresult res = m_pIWebShell->LoadURL(sUrl.GetUnicode());
|
||||
|
||||
|
||||
/* , tmpCommand, pIPostData, bModifyHistory);
|
||||
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
||||
nsIInputStream* aPostDataStream=nsnull,
|
||||
@ -1339,7 +1472,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Refresh2(VARIANT __RPC_FAR *Level)
|
||||
if (Level)
|
||||
{
|
||||
CComVariant vLevelAsInt;
|
||||
if (vLevelAsInt.ChangeType(VT_I4, Level) != S_OK)
|
||||
if ( vLevelAsInt.ChangeType(VT_I4, Level) != S_OK )
|
||||
{
|
||||
NG_ASSERT(0);
|
||||
RETURN_E_UNEXPECTED();
|
||||
@ -1594,6 +1727,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Left(long Left)
|
||||
NG_ASSERT(0);
|
||||
RETURN_E_UNEXPECTED();
|
||||
}
|
||||
|
||||
//TODO: Implement put_Left - Should set the left position of this control.
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -1938,7 +2073,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_HWND(long __RPC_FAR *pHWND)
|
||||
RETURN_E_INVALIDARG();
|
||||
}
|
||||
|
||||
//This generates an exception in the IE control.
|
||||
//This is supposed to return a handle to the IE main window. Since that doesn't exist
|
||||
//in the control's case, this shouldn't do anything.
|
||||
*pHWND = NULL;
|
||||
return S_OK;
|
||||
}
|
||||
@ -2079,6 +2215,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_StatusText(BSTR __RPC_FAR *Status
|
||||
}
|
||||
|
||||
//TODO: Implement get_StatusText
|
||||
//NOTE: This function is related to the MS status bar which doesn't exist in this control. Needs more
|
||||
// investigation, but probably doesn't apply.
|
||||
*StatusText = SysAllocString(L"");
|
||||
return S_OK;
|
||||
}
|
||||
@ -2095,6 +2233,8 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_StatusText(BSTR StatusText)
|
||||
}
|
||||
|
||||
//TODO: Implement put_StatusText
|
||||
//NOTE: This function is related to the MS status bar which doesn't exist in this control. Needs more
|
||||
// investigation, but probably doesn't apply.
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -2235,7 +2375,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate2(VARIANT __RPC_FAR *URL, VAR
|
||||
#endif
|
||||
|
||||
CComVariant vURLAsString;
|
||||
if (vURLAsString.ChangeType(VT_BSTR, URL) != S_OK)
|
||||
if ( vURLAsString.ChangeType(VT_BSTR, URL) != S_OK )
|
||||
{
|
||||
RETURN_E_INVALIDARG();
|
||||
}
|
||||
@ -2483,28 +2623,31 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_RegisterAsDropTarget(VARIANT_BOOL
|
||||
pDropTarget->AddRef();
|
||||
pDropTarget->SetOwner(this);
|
||||
|
||||
|
||||
// Ask the site if it wants to replace this drop target for another one
|
||||
CIPtr(IDropTarget) spDropTarget;
|
||||
CIPtr(IDocHostUIHandler) spDocHostUIHandler = m_spClientSite;
|
||||
if (spDocHostUIHandler)
|
||||
{
|
||||
if (spDocHostUIHandler->GetDropTarget(pDropTarget, &spDropTarget) != S_OK)
|
||||
//if (spDocHostUIHandler->GetDropTarget(pDropTarget, &spDropTarget) != S_OK)
|
||||
if (spDocHostUIHandler->GetDropTarget(pDropTarget, &spDropTarget) == S_OK)
|
||||
{
|
||||
spDropTarget = pDropTarget;
|
||||
m_bDropTarget = TRUE;
|
||||
::RegisterDragDrop(m_hWnd, spDropTarget);
|
||||
//spDropTarget = pDropTarget;
|
||||
}
|
||||
}
|
||||
if (spDropTarget)
|
||||
else
|
||||
//if (spDropTarget)
|
||||
{
|
||||
m_bDropTarget = TRUE;
|
||||
::RegisterDragDrop(m_hWnd, spDropTarget);
|
||||
::RegisterDragDrop(m_hWnd, pDropTarget);
|
||||
//::RegisterDragDrop(m_hWnd, spDropTarget);
|
||||
}
|
||||
|
||||
pDropTarget->Release();
|
||||
}
|
||||
|
||||
// Now revoke any child window drop targets and pray they aren't
|
||||
// reset by the layout engine.
|
||||
|
||||
::EnumChildWindows(m_hWnd, EnumChildProc, (LPARAM) this);
|
||||
}
|
||||
}
|
||||
@ -2631,7 +2774,6 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Resizable(VARIANT_BOOL Value)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Ole Command Handlers
|
||||
|
||||
@ -2648,4 +2790,4 @@ HRESULT _stdcall CMozillaBrowser::EditCommandHandler(CMozillaBrowser *pThis, con
|
||||
{
|
||||
pThis->OnEditorCommand(nCmdID);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
@ -90,6 +90,7 @@ typedef long int32;
|
||||
#include "nsViewsCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICookieService.h"
|
||||
|
||||
#include "nsIHTTPChannel.h"
|
||||
|
||||
|
@ -183,6 +183,13 @@ CWebShellContainer::GetChrome(PRUint32& aChromeMaskResult)
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::SetTitle(const PRUnichar* aTitle)
|
||||
{
|
||||
//Fire a title change event
|
||||
USES_CONVERSION;
|
||||
LPOLESTR pszConvertedLocationName = W2OLE(const_cast<PRUnichar *>(aTitle));
|
||||
BSTR __RPC_FAR LocationName = SysAllocString(pszConvertedLocationName);
|
||||
m_pEvents1->Fire_TitleChange(LocationName);
|
||||
m_pEvents2->Fire_TitleChange(LocationName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -199,8 +206,10 @@ CWebShellContainer::GetTitle(const PRUnichar** aResult)
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::SetStatus(const PRUnichar* aStatus)
|
||||
{
|
||||
|
||||
NG_TRACE_METHOD(CWebShellContainer::SetStatus);
|
||||
|
||||
//Gets fired on mouse over link events.
|
||||
BSTR bstrStatus = SysAllocString(W2OLE((PRUnichar *) aStatus));
|
||||
m_pEvents1->Fire_StatusTextChange(bstrStatus);
|
||||
m_pEvents2->Fire_StatusTextChange(bstrStatus);
|
||||
@ -237,6 +246,7 @@ NS_IMETHODIMP
|
||||
CWebShellContainer::SetProgress(PRInt32 aProgress, PRInt32 aProgressMax)
|
||||
{
|
||||
NG_TRACE_METHOD(CWebShellContainer::SetProgress);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -285,10 +295,6 @@ CWebShellContainer::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
|
||||
USES_CONVERSION;
|
||||
NG_TRACE(_T("CWebShellContainer::BeginLoadURL(..., \"%s\")\n"), W2T(aURL));
|
||||
|
||||
// Fire a DownloadBegin
|
||||
m_pEvents1->Fire_DownloadBegin();
|
||||
m_pEvents2->Fire_DownloadBegin();
|
||||
|
||||
// Fire a BeforeNavigate event
|
||||
OLECHAR *pszURL = W2OLE((WCHAR *)aURL);
|
||||
BSTR bstrURL = SysAllocString(pszURL);
|
||||
@ -320,6 +326,20 @@ CWebShellContainer::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
|
||||
{
|
||||
m_pOwner->m_bBusy = TRUE;
|
||||
}
|
||||
|
||||
//NOTE: The IE control fires a DownloadBegin after the first BeforeNavigate. It then fires a
|
||||
// DownloadComplete after then engine has made it's initial connection to the server. It
|
||||
// then fires a second DownloadBegin/DownloadComplete pair around the loading of everything
|
||||
// on the page. These events get fired out of CWebShellContainer::StartDocumentLoad() and
|
||||
// CWebShellContainer::EndDocumentLoad().
|
||||
// We don't appear to distinguish between the initial connection to the server and the
|
||||
// actual transfer of data. Firing these events here simulates, appeasing applications
|
||||
// that are expecting that initial pair.
|
||||
m_pEvents1->Fire_DownloadBegin();
|
||||
m_pEvents2->Fire_DownloadBegin();
|
||||
m_pEvents1->Fire_DownloadComplete();
|
||||
m_pEvents2->Fire_DownloadComplete();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -376,13 +396,12 @@ CWebShellContainer::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsres
|
||||
CComVariant vURL(bstrURL);
|
||||
m_pEvents2->Fire_NavigateComplete2(m_pOwner, &vURL);
|
||||
|
||||
// Fire the new NavigateForward state
|
||||
// Fire the new NavigateForward state
|
||||
VARIANT_BOOL bEnableForward = VARIANT_FALSE;
|
||||
if ( m_pOwner->m_pIWebShell->CanForward() == NS_OK )
|
||||
{
|
||||
bEnableForward = VARIANT_TRUE;
|
||||
}
|
||||
|
||||
m_pEvents2->Fire_CommandStateChange(CSC_NAVIGATEFORWARD, bEnableForward);
|
||||
|
||||
// Fire the new NavigateBack state
|
||||
@ -391,7 +410,6 @@ CWebShellContainer::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsres
|
||||
{
|
||||
bEnableBack = VARIANT_TRUE;
|
||||
}
|
||||
|
||||
m_pEvents2->Fire_CommandStateChange(CSC_NAVIGATEBACK, bEnableBack);
|
||||
|
||||
m_pOwner->m_bBusy = FALSE;
|
||||
@ -469,7 +487,7 @@ CWebShellContainer::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
NG_TRACE(_T("CWebShellContainer::OnStartRequest(...)\n"));
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -493,7 +511,16 @@ CWebShellContainer::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, n
|
||||
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand)
|
||||
{
|
||||
{
|
||||
char* wString = nsnull;
|
||||
aURL->GetPath(&wString);
|
||||
USES_CONVERSION;
|
||||
NG_TRACE(_T("CWebShellContainer::OnStartDocumentLoad(..., %s, \"%s\")\n"),A2CT(wString), A2CT(aCommand));
|
||||
|
||||
//Fire a DownloadBegin
|
||||
m_pEvents1->Fire_DownloadBegin();
|
||||
m_pEvents2->Fire_DownloadBegin();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -501,6 +528,12 @@ CWebShellContainer::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL,
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel *aChannel, nsresult aStatus, nsIDocumentLoaderObserver * aObserver)
|
||||
{
|
||||
NG_TRACE(_T("CWebShellContainer::OnEndDocumentLoad(..., \"\")\n"));
|
||||
|
||||
//Fire a DownloadComplete
|
||||
m_pEvents1->Fire_DownloadComplete();
|
||||
m_pEvents2->Fire_DownloadComplete();
|
||||
|
||||
char* aString = nsnull;
|
||||
nsIURI* uri = nsnull;
|
||||
|
||||
@ -513,7 +546,7 @@ CWebShellContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel *aCh
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
USES_CONVERSION;
|
||||
USES_CONVERSION;
|
||||
BSTR bstrURL = SysAllocString(A2OLE((CHAR *) aString));
|
||||
|
||||
delete [] aString; // clean up.
|
||||
@ -523,12 +556,21 @@ CWebShellContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel *aCh
|
||||
m_pEvents2->Fire_DocumentComplete(m_pOwner, &vURL);
|
||||
SysFreeString(bstrURL);
|
||||
|
||||
//Fire a StatusTextChange event
|
||||
BSTR bstrStatus = SysAllocString(A2OLE((CHAR *) "Done"));
|
||||
m_pEvents1->Fire_StatusTextChange(bstrStatus);
|
||||
m_pEvents2->Fire_StatusTextChange(bstrStatus);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel, nsIContentViewer* aViewer)
|
||||
{
|
||||
NG_TRACE(_T("CWebShellContainer::OnStartURLLoad(..., \"\")\n"));
|
||||
|
||||
//NOTE: This appears to get fired once for each individual item on a page.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -541,10 +583,16 @@ CWebShellContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* aCh
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// we don't care about these.
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel, nsString& aMsg)
|
||||
{
|
||||
NG_TRACE(_T("CWebShellContainer::OnStatusURLLoad(..., \"\")\n"));
|
||||
|
||||
//NOTE: This appears to get fired for each individual item on a page, indicating the status of that item.
|
||||
BSTR bstrStatus = SysAllocString(W2OLE((PRUnichar *) aMsg.GetUnicode()));
|
||||
m_pEvents1->Fire_StatusTextChange(bstrStatus);
|
||||
m_pEvents2->Fire_StatusTextChange(bstrStatus);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -552,6 +600,10 @@ CWebShellContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* aChan
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus)
|
||||
{
|
||||
NG_TRACE(_T("CWebShellContainer::OnEndURLLoad(..., \"\")\n"));
|
||||
|
||||
//NOTE: This appears to get fired once for each individual item on a page.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -560,5 +612,4 @@ NS_IMETHODIMP
|
||||
CWebShellContainer::HandleUnknownContentType(nsIDocumentLoader* loader, nsIChannel *aChannel, const char *aContentType, const char *aCommand )
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
@ -25,6 +25,7 @@
|
||||
// Class IDs
|
||||
NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
NS_DEFINE_IID(kHTMLEditorCID, NS_HTMLEDITOR_CID);
|
||||
NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
||||
|
||||
// Interface IDs
|
||||
NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
|
||||
|
@ -28,6 +28,7 @@
|
||||
// Class IDs
|
||||
NS_EXTERN_IID(kEventQueueServiceCID);
|
||||
NS_EXTERN_IID(kHTMLEditorCID);
|
||||
NS_EXTERN_IID(kCookieServiceCID);
|
||||
|
||||
// Interface IDs
|
||||
NS_EXTERN_IID(kIBrowserWindowIID);
|
||||
|
Loading…
Reference in New Issue
Block a user