2002-06-19 18:25:27 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-09-12 19:59:33 +04:00
|
|
|
* Version: Mozilla-sample-code 1.0
|
2002-06-19 18:25:27 +04:00
|
|
|
*
|
2004-09-12 19:59:33 +04:00
|
|
|
* Copyright (c) 2002 Netscape Communications Corporation and
|
|
|
|
* other contributors
|
2002-06-19 18:25:27 +04:00
|
|
|
*
|
2004-09-12 19:59:33 +04:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this Mozilla sample software and associated documentation files
|
|
|
|
* (the "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
* persons to whom the Software is furnished to do so, subject to the
|
|
|
|
* following conditions:
|
2002-06-19 18:25:27 +04:00
|
|
|
*
|
2004-09-12 19:59:33 +04:00
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
2002-06-19 18:25:27 +04:00
|
|
|
*
|
2004-09-12 19:59:33 +04:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2000-07-05 02:42:09 +04:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
2002-06-19 18:25:27 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-07-05 02:42:09 +04:00
|
|
|
|
2005-09-15 16:04:57 +04:00
|
|
|
// Local includes
|
|
|
|
#include "resource.h"
|
|
|
|
#include "winEmbed.h"
|
|
|
|
#include "WebBrowserChrome.h"
|
|
|
|
|
|
|
|
// OS headers
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
// Frozen APIs
|
|
|
|
|
|
|
|
#include "nsStringAPI.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsIComponentManager.h"
|
2001-02-26 03:34:57 +03:00
|
|
|
#include "nsIDOMWindow.h"
|
2005-09-15 16:04:57 +04:00
|
|
|
#include "nsIGenericFactory.h"
|
2001-02-07 08:10:46 +03:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2000-07-05 02:42:09 +04:00
|
|
|
#include "nsIRequest.h"
|
2005-09-15 16:04:57 +04:00
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsIWebProgress.h"
|
2000-08-01 05:37:07 +04:00
|
|
|
#include "nsCWebBrowser.h"
|
2001-03-22 17:49:39 +03:00
|
|
|
#include "nsIProfileChangeStatus.h"
|
|
|
|
|
2005-09-15 16:04:57 +04:00
|
|
|
// Glue APIs (not frozen, but safe to use because they are statically linked)
|
|
|
|
#include "nsComponentManagerUtils.h"
|
2000-07-05 02:42:09 +04:00
|
|
|
|
2005-09-15 16:04:57 +04:00
|
|
|
// NON-FROZEN APIS!
|
|
|
|
#include "nsIWebNavigation.h"
|
2000-07-05 02:42:09 +04:00
|
|
|
|
|
|
|
WebBrowserChrome::WebBrowserChrome()
|
|
|
|
{
|
2000-08-01 05:37:07 +04:00
|
|
|
mNativeWindow = nsnull;
|
2001-04-25 03:05:34 +04:00
|
|
|
mSizeSet = PR_FALSE;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WebBrowserChrome::~WebBrowserChrome()
|
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
WebBrowserChromeUI::Destroyed(this);
|
2000-12-13 16:47:16 +03:00
|
|
|
}
|
|
|
|
|
2001-03-22 17:49:39 +03:00
|
|
|
nsresult WebBrowserChrome::CreateBrowser(PRInt32 aX, PRInt32 aY,
|
|
|
|
PRInt32 aCX, PRInt32 aCY,
|
|
|
|
nsIWebBrowser **aBrowser)
|
2000-12-13 16:47:16 +03:00
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aBrowser);
|
|
|
|
*aBrowser = nsnull;
|
|
|
|
|
|
|
|
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
|
|
|
|
|
|
|
|
if (!mWebBrowser)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2007-07-08 11:08:56 +04:00
|
|
|
(void)mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome*>(this));
|
2001-03-22 17:49:39 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> browserBaseWindow = do_QueryInterface(mWebBrowser);
|
|
|
|
|
2007-07-08 11:08:56 +04:00
|
|
|
mNativeWindow = WebBrowserChromeUI::CreateNativeWindow(static_cast<nsIWebBrowserChrome*>(this));
|
2001-03-22 17:49:39 +03:00
|
|
|
|
|
|
|
if (!mNativeWindow)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
browserBaseWindow->InitWindow( mNativeWindow,
|
|
|
|
nsnull,
|
|
|
|
aX, aY, aCX, aCY);
|
|
|
|
browserBaseWindow->Create();
|
|
|
|
|
2007-07-08 11:08:56 +04:00
|
|
|
nsCOMPtr<nsIWebProgressListener> listener(static_cast<nsIWebProgressListener*>(this));
|
2003-07-25 23:06:59 +04:00
|
|
|
nsCOMPtr<nsIWeakReference> thisListener(do_GetWeakReference(listener));
|
2001-03-22 17:49:39 +03:00
|
|
|
(void)mWebBrowser->AddWebBrowserListener(thisListener,
|
|
|
|
NS_GET_IID(nsIWebProgressListener));
|
|
|
|
|
|
|
|
// The window has been created. Now register for history notifications
|
|
|
|
mWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsISHistoryListener));
|
|
|
|
|
2001-03-28 15:20:18 +04:00
|
|
|
if (mWebBrowser)
|
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
*aBrowser = mWebBrowser;
|
|
|
|
NS_ADDREF(*aBrowser);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsISupports
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(WebBrowserChrome)
|
|
|
|
NS_IMPL_RELEASE(WebBrowserChrome)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(WebBrowserChrome)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
2001-03-13 15:48:33 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
2000-12-13 16:47:16 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) // optional
|
2001-02-07 03:33:11 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISHistoryListener)
|
2001-02-01 00:03:40 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2001-03-22 17:49:39 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
2001-03-28 15:20:18 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
|
2000-07-05 02:42:09 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsIInterfaceRequestor
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstancePtr)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
2001-02-26 03:34:57 +03:00
|
|
|
|
2001-03-28 15:20:18 +04:00
|
|
|
*aInstancePtr = 0;
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
|
|
|
|
{
|
|
|
|
if (mWebBrowser)
|
|
|
|
{
|
|
|
|
return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
|
|
|
|
}
|
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
|
|
|
return QueryInterface(aIID, aInstancePtr);
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsIWebBrowserChrome
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2000-08-25 22:39:46 +04:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
WebBrowserChromeUI::UpdateStatusBarText(this, aStatus);
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::GetWebBrowser(nsIWebBrowser** aWebBrowser)
|
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aWebBrowser);
|
|
|
|
*aWebBrowser = mWebBrowser;
|
|
|
|
NS_IF_ADDREF(*aWebBrowser);
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::SetWebBrowser(nsIWebBrowser* aWebBrowser)
|
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
mWebBrowser = aWebBrowser;
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2000-08-25 22:39:46 +04:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::GetChromeFlags(PRUint32* aChromeMask)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
*aChromeMask = mChromeFlags;
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2000-08-25 22:39:46 +04:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::SetChromeFlags(PRUint32 aChromeMask)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
mChromeFlags = aChromeMask;
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 15:48:33 +03:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::DestroyBrowserWindow(void)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
WebBrowserChromeUI::Destroy(this);
|
|
|
|
return NS_OK;
|
2001-03-13 15:48:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-04 00:52:05 +04:00
|
|
|
// IN: The desired browser client area dimensions.
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(PRInt32 aWidth, PRInt32 aHeight)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-04-25 03:05:34 +04:00
|
|
|
/* This isn't exactly correct: we're setting the whole window to
|
|
|
|
the size requested for the browser. At time of writing, though,
|
|
|
|
it's fine and useful for winEmbed's purposes. */
|
2002-07-04 00:52:05 +04:00
|
|
|
WebBrowserChromeUI::SizeTo(this, aWidth, aHeight);
|
2001-04-25 03:05:34 +04:00
|
|
|
mSizeSet = PR_TRUE;
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::ShowAsModal(void)
|
|
|
|
{
|
2001-04-21 06:45:37 +04:00
|
|
|
if (mDependentParent)
|
|
|
|
AppCallbacks::EnableChromeWindow(mDependentParent, PR_FALSE);
|
|
|
|
|
|
|
|
mContinueModalLoop = PR_TRUE;
|
|
|
|
AppCallbacks::RunEventLoop(mContinueModalLoop);
|
|
|
|
|
|
|
|
if (mDependentParent)
|
|
|
|
AppCallbacks::EnableChromeWindow(mDependentParent, PR_TRUE);
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2000-11-09 03:17:09 +03:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::IsWindowModal(PRBool *_retval)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
*_retval = PR_FALSE;
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-11-09 03:17:09 +03:00
|
|
|
}
|
|
|
|
|
2000-08-01 05:37:07 +04:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::ExitModalEventLoop(nsresult aStatus)
|
|
|
|
{
|
2001-04-21 06:45:37 +04:00
|
|
|
mContinueModalLoop = PR_FALSE;
|
|
|
|
return NS_OK;
|
2000-08-01 05:37:07 +04:00
|
|
|
}
|
|
|
|
|
2001-04-25 06:04:56 +04:00
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsIWebBrowserChromeFocus
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::FocusNextElement()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::FocusPrevElement()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2000-07-05 02:42:09 +04:00
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsIWebProgressListener
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::OnProgressChange(nsIWebProgress *progress, nsIRequest *request,
|
|
|
|
PRInt32 curSelfProgress, PRInt32 maxSelfProgress,
|
|
|
|
PRInt32 curTotalProgress, PRInt32 maxTotalProgress)
|
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
WebBrowserChromeUI::UpdateProgress(this, curTotalProgress, maxTotalProgress);
|
2000-12-13 16:47:16 +03:00
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIRequest *request,
|
2002-05-17 00:57:37 +04:00
|
|
|
PRUint32 progressStateFlags, nsresult status)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2000-12-13 16:47:16 +03:00
|
|
|
if ((progressStateFlags & STATE_START) && (progressStateFlags & STATE_IS_DOCUMENT))
|
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
WebBrowserChromeUI::UpdateBusyState(this, PR_TRUE);
|
2000-12-13 16:47:16 +03:00
|
|
|
}
|
2000-08-01 05:37:07 +04:00
|
|
|
|
2000-12-13 16:47:16 +03:00
|
|
|
if ((progressStateFlags & STATE_STOP) && (progressStateFlags & STATE_IS_DOCUMENT))
|
2000-08-01 05:37:07 +04:00
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
WebBrowserChromeUI::UpdateBusyState(this, PR_FALSE);
|
|
|
|
WebBrowserChromeUI::UpdateProgress(this, 0, 100);
|
|
|
|
WebBrowserChromeUI::UpdateStatusBarText(this, nsnull);
|
2001-04-25 03:05:34 +04:00
|
|
|
ContentFinishedLoading();
|
2000-08-01 05:37:07 +04:00
|
|
|
}
|
2000-12-13 16:47:16 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-25 09:45:56 +04:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsIURI *location)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-05-30 02:48:39 +04:00
|
|
|
PRBool isSubFrameLoad = PR_FALSE; // Is this a subframe load
|
|
|
|
if (aWebProgress) {
|
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow;
|
|
|
|
nsCOMPtr<nsIDOMWindow> topDomWindow;
|
|
|
|
aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
|
|
|
if (domWindow) { // Get root domWindow
|
|
|
|
domWindow->GetTop(getter_AddRefs(topDomWindow));
|
|
|
|
}
|
|
|
|
if (domWindow != topDomWindow)
|
|
|
|
isSubFrameLoad = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (!isSubFrameLoad)
|
2001-03-22 17:49:39 +03:00
|
|
|
WebBrowserChromeUI::UpdateCurrentURI(this);
|
2001-05-30 02:48:39 +04:00
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2000-07-25 09:45:56 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserChrome::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsresult aStatus,
|
|
|
|
const PRUnichar* aMessage)
|
|
|
|
{
|
2001-03-22 17:49:39 +03:00
|
|
|
WebBrowserChromeUI::UpdateStatusBarText(this, aMessage);
|
2000-07-25 09:45:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-07-05 02:42:09 +04:00
|
|
|
|
2000-09-15 02:56:56 +04:00
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserChrome::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|
|
|
nsIRequest *aRequest,
|
2002-05-17 00:57:37 +04:00
|
|
|
PRUint32 state)
|
2000-09-15 02:56:56 +04:00
|
|
|
{
|
2002-05-17 00:57:37 +04:00
|
|
|
return NS_OK;
|
2000-09-15 02:56:56 +04:00
|
|
|
}
|
|
|
|
|
2001-02-07 03:33:11 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsISHistoryListener
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserChrome::OnHistoryNewEntry(nsIURI * aNewURI)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
return SendHistoryStatusMessage(aNewURI, "add");
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserChrome::OnHistoryGoBack(nsIURI * aBackURI, PRBool * aContinue)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
// For now, let the operation continue
|
|
|
|
*aContinue = PR_TRUE;
|
|
|
|
return SendHistoryStatusMessage(aBackURI, "back");
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserChrome::OnHistoryGoForward(nsIURI * aForwardURI, PRBool * aContinue)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
// For now, let the operation continue
|
|
|
|
*aContinue = PR_TRUE;
|
|
|
|
return SendHistoryStatusMessage(aForwardURI, "forward");
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserChrome::OnHistoryGotoIndex(PRInt32 aIndex, nsIURI * aGotoURI, PRBool * aContinue)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
// For now, let the operation continue
|
|
|
|
*aContinue = PR_TRUE;
|
|
|
|
return SendHistoryStatusMessage(aGotoURI, "goto", aIndex);
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserChrome::OnHistoryReload(nsIURI * aURI, PRUint32 aReloadFlags, PRBool * aContinue)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
// For now, let the operation continue
|
|
|
|
*aContinue = PR_TRUE;
|
|
|
|
return SendHistoryStatusMessage(aURI, "reload", 0 /* no info to pass here */, aReloadFlags);
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserChrome::OnHistoryPurge(PRInt32 aNumEntries, PRBool *aContinue)
|
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
// For now let the operation continue
|
|
|
|
*aContinue = PR_FALSE;
|
|
|
|
return SendHistoryStatusMessage(nsnull, "purge", aNumEntries);
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
|
|
|
|
2005-09-15 16:04:57 +04:00
|
|
|
static void
|
|
|
|
AppendIntToCString(PRInt32 info1, nsCString& aResult)
|
|
|
|
{
|
|
|
|
char intstr[10];
|
|
|
|
_snprintf(intstr, sizeof(intstr) - 1, "%i", info1);
|
|
|
|
intstr[sizeof(intstr) - 1] = '\0';
|
|
|
|
aResult.Append(intstr);
|
|
|
|
}
|
|
|
|
|
2001-02-07 03:33:11 +03:00
|
|
|
nsresult
|
|
|
|
WebBrowserChrome::SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1, PRUint32 aReloadFlags)
|
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
nsCString uriSpec;
|
2001-03-28 15:20:18 +04:00
|
|
|
if (aURI)
|
2001-02-07 03:33:11 +03:00
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
aURI->GetSpec(uriSpec);
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
2001-03-28 15:20:18 +04:00
|
|
|
|
2005-09-15 16:04:57 +04:00
|
|
|
nsCString status;
|
2001-03-28 15:20:18 +04:00
|
|
|
|
2004-09-14 00:53:42 +04:00
|
|
|
if(!(strcmp(operation, "back")))
|
2001-03-28 15:20:18 +04:00
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Assign("Going back to url: ");
|
|
|
|
status.Append(uriSpec);
|
2001-03-28 15:20:18 +04:00
|
|
|
}
|
2004-09-14 00:53:42 +04:00
|
|
|
else if (!(strcmp(operation, "forward")))
|
2001-03-28 15:20:18 +04:00
|
|
|
{
|
|
|
|
// Going forward. XXX Get string from a resource file
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Assign("Going forward to url: ");
|
|
|
|
status.Append(uriSpec);
|
2001-03-28 15:20:18 +04:00
|
|
|
}
|
2004-09-14 00:53:42 +04:00
|
|
|
else if (!(strcmp(operation, "reload")))
|
2001-02-07 03:33:11 +03:00
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
// Reloading. XXX Get string from a resource file
|
|
|
|
if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
|
|
|
|
aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)
|
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Assign("Reloading url, (bypassing proxy and cache): ");
|
2001-03-28 15:20:18 +04:00
|
|
|
}
|
|
|
|
else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY)
|
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Assign("Reloading url, (bypassing proxy): ");
|
2001-03-28 15:20:18 +04:00
|
|
|
}
|
|
|
|
else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)
|
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Assign("Reloading url, (bypassing cache): ");
|
2001-03-28 15:20:18 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Assign("Reloading url, (normal): ");
|
2001-03-28 15:20:18 +04:00
|
|
|
}
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Append(uriSpec);
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
2004-09-14 00:53:42 +04:00
|
|
|
else if (!(strcmp(operation, "add")))
|
2001-02-07 03:33:11 +03:00
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Assign(uriSpec);
|
|
|
|
status.Append(" added to session History");
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
2004-09-14 00:53:42 +04:00
|
|
|
else if (!(strcmp(operation, "goto")))
|
2001-02-07 03:33:11 +03:00
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
status.Assign("Going to HistoryIndex: ");
|
|
|
|
|
|
|
|
AppendIntToCString(info1, status);
|
|
|
|
|
|
|
|
status.Append(" Url: ");
|
|
|
|
status.Append(uriSpec);
|
2001-03-28 15:20:18 +04:00
|
|
|
}
|
2004-09-14 00:53:42 +04:00
|
|
|
else if (!(strcmp(operation, "purge")))
|
2001-03-28 15:20:18 +04:00
|
|
|
{
|
2005-09-15 16:04:57 +04:00
|
|
|
AppendIntToCString(info1, status);
|
|
|
|
status.Append(" purged from Session History");
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
|
|
|
|
2005-09-15 16:04:57 +04:00
|
|
|
nsString wstatus;
|
|
|
|
NS_CStringToUTF16(status, NS_CSTRING_ENCODING_UTF8, wstatus);
|
|
|
|
WebBrowserChromeUI::UpdateStatusBarText(this, wstatus.get());
|
2001-02-07 03:33:11 +03:00
|
|
|
|
2001-03-28 15:20:18 +04:00
|
|
|
return NS_OK;
|
2001-02-07 03:33:11 +03:00
|
|
|
}
|
2000-09-15 02:56:56 +04:00
|
|
|
|
2001-04-25 03:05:34 +04:00
|
|
|
void WebBrowserChrome::ContentFinishedLoading()
|
|
|
|
{
|
|
|
|
// if it was a chrome window and no one has already specified a size,
|
|
|
|
// size to content
|
|
|
|
if (mWebBrowser && !mSizeSet &&
|
|
|
|
(mChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {
|
|
|
|
nsCOMPtr<nsIDOMWindow> contentWin;
|
|
|
|
mWebBrowser->GetContentDOMWindow(getter_AddRefs(contentWin));
|
2001-04-28 06:42:23 +04:00
|
|
|
if (contentWin)
|
|
|
|
contentWin->SizeToContent();
|
2001-04-25 03:05:34 +04:00
|
|
|
WebBrowserChromeUI::ShowWindow(this, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 02:42:09 +04:00
|
|
|
//*****************************************************************************
|
2001-03-13 15:48:33 +03:00
|
|
|
// WebBrowserChrome::nsIEmbeddingSiteWindow
|
2000-07-05 02:42:09 +04:00
|
|
|
//*****************************************************************************
|
|
|
|
|
2001-03-13 15:48:33 +03:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-03-13 15:48:33 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 15:48:33 +03:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-03-13 15:48:33 +03:00
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
|
|
|
|
{
|
|
|
|
*x = 0;
|
|
|
|
*y = 0;
|
|
|
|
}
|
|
|
|
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
|
|
|
|
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
|
|
|
|
{
|
|
|
|
*cx = 0;
|
|
|
|
*cy = 0;
|
|
|
|
}
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2001-02-02 16:24:50 +03:00
|
|
|
/* void setFocus (); */
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::SetFocus()
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-09-24 01:03:03 +04:00
|
|
|
WebBrowserChromeUI::SetFocus(this);
|
|
|
|
return NS_OK;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2001-02-02 16:24:50 +03:00
|
|
|
/* attribute wstring title; */
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::GetTitle(PRUnichar * *aTitle)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-02-02 16:24:50 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aTitle);
|
2000-07-05 02:42:09 +04:00
|
|
|
|
2001-02-02 16:24:50 +03:00
|
|
|
*aTitle = nsnull;
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
2001-02-02 16:24:50 +03:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::SetTitle(const PRUnichar * aTitle)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-02-02 16:24:50 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-07-05 02:42:09 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 15:48:33 +03:00
|
|
|
/* attribute boolean visibility; */
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::GetVisibility(PRBool * aVisibility)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aVisibility);
|
|
|
|
*aVisibility = PR_TRUE;
|
2001-03-22 17:49:39 +03:00
|
|
|
return NS_OK;
|
2001-03-13 15:48:33 +03:00
|
|
|
}
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::SetVisibility(PRBool aVisibility)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-02 16:24:50 +03:00
|
|
|
/* attribute nativeSiteWindow siteWindow */
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::GetSiteWindow(void * *aSiteWindow)
|
2000-07-05 02:42:09 +04:00
|
|
|
{
|
2001-02-02 16:24:50 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aSiteWindow);
|
2000-07-05 02:42:09 +04:00
|
|
|
|
2001-02-02 16:24:50 +03:00
|
|
|
*aSiteWindow = mNativeWindow;
|
2000-07-05 02:42:09 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-03-22 17:49:39 +03:00
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsIObserver
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2001-10-20 00:52:59 +04:00
|
|
|
NS_IMETHODIMP WebBrowserChrome::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
|
2001-03-22 17:49:39 +03:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2004-09-14 00:53:42 +04:00
|
|
|
if (strcmp(aTopic, "profile-change-teardown") == 0)
|
2001-03-22 17:49:39 +03:00
|
|
|
{
|
2001-03-28 15:20:18 +04:00
|
|
|
// A profile change means death for this window
|
|
|
|
WebBrowserChromeUI::Destroy(this);
|
2001-03-22 17:49:39 +03:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-03-28 15:20:18 +04:00
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsIContextMenuListener
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
/* void OnShowContextMenu (in unsigned long aContextFlags, in nsIDOMEvent aEvent, in nsIDOMNode aNode); */
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
|
|
|
|
{
|
|
|
|
WebBrowserChromeUI::ShowContextMenu(this, aContextFlags, aEvent, aNode);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// WebBrowserChrome::nsITooltipListener
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
/* void OnShowTooltip (in long aXCoords, in long aYCoords, in wstring aTipText); */
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText)
|
|
|
|
{
|
|
|
|
WebBrowserChromeUI::ShowTooltip(this, aXCoords, aYCoords, aTipText);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* void OnHideTooltip (); */
|
|
|
|
NS_IMETHODIMP WebBrowserChrome::OnHideTooltip()
|
|
|
|
{
|
|
|
|
WebBrowserChromeUI::HideTooltip(this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|