зеркало из https://github.com/mozilla/pjs.git
Bug 511849 nsBrowserInstance is no longer required. r=Neil,sr=bsmedberg
This commit is contained in:
Родитель
f9e4db61e9
Коммит
2c0df4289e
|
@ -200,7 +200,6 @@
|
|||
@BINPATH@/components/migration.xpt
|
||||
#endif
|
||||
@BINPATH@/components/mimetype.xpt
|
||||
@BINPATH@/components/mozbrwsr.xpt
|
||||
@BINPATH@/components/mozfind.xpt
|
||||
@BINPATH@/components/necko_about.xpt
|
||||
@BINPATH@/components/necko_cache.xpt
|
||||
|
|
|
@ -44,6 +44,6 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
MODULE = browser
|
||||
|
||||
DIRS = public src
|
||||
DIRS = src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = browser
|
||||
XPIDL_MODULE = mozbrwsr
|
||||
|
||||
XPIDLSRCS = nsIBrowserInstance.idl
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* William A. Law <law@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindowInternal;
|
||||
|
||||
[scriptable, uuid(8AF0FA40-598D-11d3-806A-00600811A9C3)]
|
||||
interface nsIBrowserInstance : nsISupports {
|
||||
|
||||
boolean startPageCycler();
|
||||
attribute boolean cmdLineURLUsed;
|
||||
|
||||
// Infrastructure.
|
||||
void setWebShellWindow( in nsIDOMWindowInternal aWindow );
|
||||
|
||||
// File.
|
||||
void close();
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
#define NS_BROWSERINSTANCE_CONTRACTID "@mozilla.org/appshell/component/browser/instance;1"
|
||||
#define NS_BROWSERSTARTUPHANDLER_CONTRACTID "@mozilla.org/commandlinehandler/general-startup;1?type=browser"
|
||||
#define NS_CHROMESTARTUPHANDLER_CONTRACTID "@mozilla.org/commandlinehandler/general-startup;1?type=chrome"
|
||||
|
||||
// {c7bee75a-1dd1-11b2-9333-a38e085287cf}
|
||||
#define NS_BROWSERCONTROLLER_CID { 0xc7bee75a, 0x1dd1, 0x11b2, { 0x93, 0x33, 0xa3, 0x8e, 0x08, 0x52, 0x87, 0xcf } }
|
||||
|
||||
// {5551A1E0-5A66-11d3-806A-00600811A9C3}
|
||||
#define NS_BROWSERINSTANCE_CID { 0x5551a1e0, 0x5a66, 0x11d3, { 0x80, 0x6a, 0x0, 0x60, 0x08, 0x11, 0xa9, 0xc3 } }
|
||||
|
||||
// {C2343730-DC2C-11d3-98B3-001083010E9B}
|
||||
#define NS_BROWSERCONTENTHANDLER_CID { 0xc2343730, 0xdc2c, 0x11d3, { 0x98, 0xb3, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } }
|
||||
|
||||
// {406B41R2-98B1-40B2-99R3-8A326CDC1F30}
|
||||
#define NS_CHROMESTARTUPHANDLER_CID { 0x406b41e2, 0x98b1, 0x40b2, { 0x99, 0xe3, 0x8a, 0x32, 0x6c, 0xdc, 0x1f, 0x30 } }
|
||||
|
||||
%}
|
|
@ -50,7 +50,6 @@ MODULE_NAME = nsBrowserModule
|
|||
|
||||
|
||||
CPPSRCS = \
|
||||
nsBrowserInstance.cpp \
|
||||
nsBrowserStatusFilter.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -1,539 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Travis Bogard <travis@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Local Includes
|
||||
#include "nsBrowserInstance.h"
|
||||
|
||||
// Helper Includes
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsISHistory.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
|
||||
/// Unsorted Includes
|
||||
|
||||
#include "nsIObserver.h"
|
||||
#include "pratom.h"
|
||||
#include "prprf.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIContentViewerEdit.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIAppStartup.h"
|
||||
|
||||
#include "nsIObserverService.h"
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
// Stuff to implement file download dialog.
|
||||
#include "nsIProxyObjectManager.h"
|
||||
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
|
||||
// If DEBUG, NS_BUILD_REFCNT_LOGGING, or MOZ_JPROF is
|
||||
// defined, enable the PageCycler.
|
||||
#if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) || defined(MOZ_JPROF)
|
||||
#define ENABLE_PAGE_CYCLER
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
static int APP_DEBUG = 0; // Set to 1 in debugger to turn on debugging.
|
||||
#else
|
||||
#define APP_DEBUG 0
|
||||
#endif
|
||||
|
||||
|
||||
#define PREF_HOMEPAGE_OVERRIDE_URL "startup.homepage_override_url"
|
||||
#define PREF_HOMEPAGE_OVERRIDE_MSTONE "browser.startup.homepage_override.mstone"
|
||||
#define PREF_BROWSER_STARTUP_PAGE "browser.startup.page"
|
||||
#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
|
||||
|
||||
const char *kIgnoreOverrideMilestone = "ignore";
|
||||
|
||||
//*****************************************************************************
|
||||
//*** PageCycler: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
#ifdef ENABLE_PAGE_CYCLER
|
||||
#include "nsITimer.h"
|
||||
|
||||
static void TimesUp(nsITimer *aTimer, void *aClosure);
|
||||
// Timer callback: called when the timer fires
|
||||
|
||||
class PageCycler : public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
struct PageCyclerEvent : public nsRunnable {
|
||||
PageCyclerEvent(PageCycler *pc) : mPageCycler(pc) {}
|
||||
NS_IMETHOD Run() {
|
||||
mPageCycler->DoCycle();
|
||||
return NS_OK;
|
||||
}
|
||||
nsRefPtr<PageCycler> mPageCycler;
|
||||
};
|
||||
|
||||
PageCycler(nsBrowserInstance* appCore, const char *aTimeoutValue = nsnull, const char *aWaitValue = nsnull)
|
||||
: mAppCore(appCore), mBuffer(nsnull), mCursor(nsnull), mTimeoutValue(0), mWaitValue(1 /*sec*/) {
|
||||
NS_ADDREF(mAppCore);
|
||||
if (aTimeoutValue){
|
||||
mTimeoutValue = atol(aTimeoutValue);
|
||||
}
|
||||
if (aWaitValue) {
|
||||
mWaitValue = atol(aWaitValue);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~PageCycler() {
|
||||
if (mBuffer) delete[] mBuffer;
|
||||
NS_RELEASE(mAppCore);
|
||||
}
|
||||
|
||||
nsresult Init(const char* nativePath) {
|
||||
nsresult rv;
|
||||
if (!mFile) {
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(aFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mFile = do_QueryInterface(aFile);
|
||||
NS_ASSERTION(mFile, "QI to nsILocalFile should not fail");
|
||||
rv = mFile->AppendRelativeNativePath(nsDependentCString(nativePath));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> inStr;
|
||||
rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), mFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUint32 avail;
|
||||
rv = inStr->Available(&avail);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mBuffer = new char[avail + 1];
|
||||
if (mBuffer == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
PRUint32 amt;
|
||||
rv = inStr->Read(mBuffer, avail, &amt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ASSERTION(amt == avail, "Didn't get the whole file.");
|
||||
mBuffer[avail] = '\0';
|
||||
mCursor = mBuffer;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsServ =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = obsServ->AddObserver(this, "EndDocumentLoad", PR_FALSE );
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add self to observer service");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult GetNextURL(nsString& result) {
|
||||
result.AssignWithConversion(mCursor);
|
||||
PRInt32 pos = result.Find(NS_LINEBREAK);
|
||||
if (pos > 0) {
|
||||
result.Truncate(pos);
|
||||
mLastRequest.Assign(result);
|
||||
mCursor += pos + NS_LINEBREAK_LEN;
|
||||
return NS_OK;
|
||||
}
|
||||
else if ( !result.IsEmpty() ) {
|
||||
// no more URLs after this one
|
||||
mCursor += result.Length(); // Advance cursor to terminating '\0'
|
||||
mLastRequest.Assign(result);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
// no more URLs, so quit the browser
|
||||
nsresult rv;
|
||||
// make sure our timer is stopped first
|
||||
StopTimer();
|
||||
|
||||
// XXX This needs to do a whole bunch of other stuff that
|
||||
// globalOverlay.js's goQuitApplication does.
|
||||
nsCOMPtr<nsIAppStartup> appStartup =
|
||||
do_GetService(NS_APPSTARTUP_CONTRACTID, &rv);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIAppStartup> appStartupProxy;
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
|
||||
NS_GET_IID(nsIAppStartup), appStartup,
|
||||
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(appStartupProxy));
|
||||
|
||||
(void)appStartupProxy->Quit(nsIAppStartup::eAttemptQuit);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHOD Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
const PRUnichar* someData) {
|
||||
nsresult rv = NS_OK;
|
||||
nsString data(someData);
|
||||
if (data.Find(mLastRequest) == 0) {
|
||||
char* dataStr = ToNewCString(data);
|
||||
printf("########## PageCycler loaded (%d ms): %s\n",
|
||||
PR_IntervalToMilliseconds(PR_IntervalNow() - mIntervalTime),
|
||||
dataStr);
|
||||
NS_Free(dataStr);
|
||||
|
||||
nsAutoString url;
|
||||
rv = GetNextURL(url);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// stop previous timer
|
||||
StopTimer();
|
||||
if (aSubject == this){
|
||||
// if the aSubject arg is 'this' then we were called by the Timer
|
||||
// Stop the current load and move on to the next
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
mAppCore->GetContentAreaDocShell(getter_AddRefs(docShell));
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
|
||||
if(webNav)
|
||||
webNav->Stop(nsIWebNavigation::STOP_ALL);
|
||||
}
|
||||
|
||||
// We need to enqueue an event to load the next page,
|
||||
// otherwise we'll run the risk of confusing the docshell
|
||||
// (which notifies observers before propagating the
|
||||
// DocumentEndLoad up to parent docshells).
|
||||
nsCOMPtr<nsIRunnable> ev = new PageCyclerEvent(this);
|
||||
if (ev)
|
||||
rv = NS_DispatchToCurrentThread(ev);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("######### PageCycler couldn't asynchronously load: %s\n", NS_ConvertUTF16toUTF8(mLastRequest).get());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
char* dataStr = ToNewCString(data);
|
||||
printf("########## PageCycler possible failure for: %s\n", dataStr);
|
||||
NS_Free(dataStr);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void DoCycle()
|
||||
{
|
||||
// load the URL
|
||||
const PRUnichar* url = mLastRequest.get();
|
||||
printf("########## PageCycler starting: %s\n", NS_ConvertUTF16toUTF8(url).get());
|
||||
|
||||
mIntervalTime = PR_IntervalNow();
|
||||
mAppCore->LoadUrl(url);
|
||||
|
||||
// start new timer
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
const nsAutoString &GetLastRequest( void )
|
||||
{
|
||||
return mLastRequest;
|
||||
}
|
||||
|
||||
// StartTimer: if mTimeoutValue is positive, then create a new timer
|
||||
// that will call the callback fcn 'TimesUp' to keep us cycling
|
||||
// through the URLs
|
||||
nsresult StartTimer(void)
|
||||
{
|
||||
nsresult rv=NS_OK;
|
||||
if (mTimeoutValue > 0){
|
||||
mShutdownTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create timer for PageCycler...");
|
||||
if (NS_SUCCEEDED(rv) && mShutdownTimer){
|
||||
mShutdownTimer->InitWithFuncCallback(TimesUp, (void *)this, mTimeoutValue*1000,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// StopTimer: if there is a timer, cancel it
|
||||
nsresult StopTimer(void)
|
||||
{
|
||||
if (mShutdownTimer){
|
||||
mShutdownTimer->Cancel();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsBrowserInstance* mAppCore;
|
||||
nsCOMPtr<nsILocalFile> mFile;
|
||||
char* mBuffer;
|
||||
char* mCursor;
|
||||
nsAutoString mLastRequest;
|
||||
nsCOMPtr<nsITimer> mShutdownTimer;
|
||||
PRUint32 mTimeoutValue;
|
||||
PRUint32 mWaitValue;
|
||||
PRIntervalTime mIntervalTime;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(PageCycler, nsIObserver)
|
||||
|
||||
// TimesUp: callback for the PageCycler timer: called when we have
|
||||
// waited too long for the page to finish loading.
|
||||
//
|
||||
// The aClosure argument is actually the PageCycler, so use it to stop
|
||||
// the timer and call the Observe fcn to move on to the next URL. Note
|
||||
// that we pass the PageCycler instance as the aSubject argument to the
|
||||
// Observe function. This is our indication that the Observe method is
|
||||
// being called after a timeout, allowing the PageCycler to do any
|
||||
// necessary processing before moving on.
|
||||
|
||||
void TimesUp(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
if(aClosure){
|
||||
PageCycler *pCycler = (PageCycler *)aClosure;
|
||||
pCycler->StopTimer();
|
||||
const nsAutoString &url = pCycler->GetLastRequest();
|
||||
fprintf(stderr,"########## PageCycler Timeout on URL: %s\n",
|
||||
NS_LossyConvertUTF16toASCII(url).get());
|
||||
pCycler->Observe( pCycler, nsnull, url.get() );
|
||||
}
|
||||
}
|
||||
|
||||
#endif //ENABLE_PAGE_CYCLER
|
||||
|
||||
PRBool nsBrowserInstance::sCmdLineURLUsed = PR_FALSE;
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsBrowserInstance: Object Management
|
||||
//*****************************************************************************
|
||||
|
||||
nsBrowserInstance::nsBrowserInstance() : mIsClosed(PR_FALSE)
|
||||
{
|
||||
mDOMWindow = nsnull;
|
||||
mContentAreaDocShellWeak = nsnull;
|
||||
}
|
||||
|
||||
nsBrowserInstance::~nsBrowserInstance()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserInstance::ReinitializeContentVariables()
|
||||
{
|
||||
NS_ASSERTION(mDOMWindow,"Reinitializing Content Variables without a window will cause a crash. see Bugzilla Bug 46454");
|
||||
if (!mDOMWindow)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> contentWindow;
|
||||
mDOMWindow->GetContent(getter_AddRefs(contentWindow));
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> pcontentWindow(do_QueryInterface(contentWindow));
|
||||
|
||||
if (pcontentWindow) {
|
||||
nsIDocShell *docShell = pcontentWindow->GetDocShell();
|
||||
|
||||
mContentAreaDocShellWeak = do_GetWeakReference(docShell); // Weak reference
|
||||
|
||||
if (APP_DEBUG) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
|
||||
if (docShellAsItem) {
|
||||
nsXPIDLString name;
|
||||
docShellAsItem->GetName(getter_Copies(name));
|
||||
printf("Attaching to Content DocShell [%s]\n", NS_LossyConvertUTF16toASCII(name).get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsBrowserInstance::GetContentAreaDocShell(nsIDocShell** outDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContentAreaDocShellWeak));
|
||||
if (!mIsClosed && docShell) {
|
||||
// we're still alive and the docshell still exists. but has it been destroyed?
|
||||
nsCOMPtr<nsIBaseWindow> hack = do_QueryInterface(docShell);
|
||||
if (hack) {
|
||||
nsCOMPtr<nsIWidget> parent;
|
||||
hack->GetParentWidget(getter_AddRefs(parent));
|
||||
if (!parent)
|
||||
// it's a zombie. a new one is in place. set up to use it.
|
||||
docShell = 0;
|
||||
}
|
||||
}
|
||||
if (!mIsClosed && !docShell)
|
||||
ReinitializeContentVariables();
|
||||
|
||||
docShell = do_QueryReferent(mContentAreaDocShellWeak);
|
||||
*outDocShell = docShell;
|
||||
NS_IF_ADDREF(*outDocShell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsBrowserInstance: nsISupports
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ADDREF(nsBrowserInstance)
|
||||
NS_IMPL_RELEASE(nsBrowserInstance)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsBrowserInstance)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBrowserInstance)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIBrowserInstance)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
// nsBrowserInstance: nsIBrowserInstance
|
||||
//*****************************************************************************
|
||||
|
||||
nsresult
|
||||
nsBrowserInstance::LoadUrl(const PRUnichar * urlToLoad)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
GetContentAreaDocShell(getter_AddRefs(docShell));
|
||||
|
||||
/* Ask nsDocShell to load the URl */
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
|
||||
|
||||
// Normal browser.
|
||||
rv = webNav->LoadURI( urlToLoad, // URI string
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE, // Load flags
|
||||
nsnull, // Referring URI
|
||||
nsnull, // Post data
|
||||
nsnull ); // Extra headers
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::SetCmdLineURLUsed(PRBool aCmdLineURLUsed)
|
||||
{
|
||||
sCmdLineURLUsed = aCmdLineURLUsed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::GetCmdLineURLUsed(PRBool* aCmdLineURLUsed)
|
||||
{
|
||||
NS_ASSERTION(aCmdLineURLUsed, "aCmdLineURLUsed can't be null");
|
||||
if (!aCmdLineURLUsed)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aCmdLineURLUsed = sCmdLineURLUsed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::StartPageCycler(PRBool* aIsPageCycling)
|
||||
{
|
||||
*aIsPageCycling = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::SetWebShellWindow(nsIDOMWindowInternal* aWin)
|
||||
{
|
||||
NS_ENSURE_ARG(aWin);
|
||||
mDOMWindow = aWin;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> win( do_QueryInterface(aWin) );
|
||||
if (!win) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (APP_DEBUG) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem =
|
||||
do_QueryInterface(win->GetDocShell());
|
||||
|
||||
if (docShellAsItem) {
|
||||
// inform our top level docshell that we are its parent URI
|
||||
// content listener...
|
||||
nsXPIDLString name;
|
||||
docShellAsItem->GetName(getter_Copies(name));
|
||||
printf("Attaching to WebShellWindow[%s]\n", NS_LossyConvertUTF16toASCII(name).get());
|
||||
}
|
||||
}
|
||||
|
||||
ReinitializeContentVariables();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::Close()
|
||||
{
|
||||
// if we have already been closed....then just return
|
||||
if (mIsClosed)
|
||||
return NS_OK;
|
||||
else
|
||||
mIsClosed = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsBrowserInstance_h___
|
||||
#define nsBrowserInstance_h___
|
||||
|
||||
// Helper Classes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIBrowserInstance.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDocShell;
|
||||
class nsIDOMWindowInternal;
|
||||
class nsIPrefBranch;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsBrowserInstance:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsBrowserInstance : public nsIBrowserInstance,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
friend class PageCycler;
|
||||
|
||||
nsBrowserInstance();
|
||||
virtual ~nsBrowserInstance();
|
||||
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR( NS_BROWSERINSTANCE_CID )
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIBROWSERINSTANCE
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
nsresult LoadUrl(const PRUnichar * urlToLoad);
|
||||
nsresult GetContentAreaDocShell(nsIDocShell** outDocShell);
|
||||
|
||||
void ReinitializeContentVariables();
|
||||
|
||||
PRBool mIsClosed;
|
||||
static PRBool sCmdLineURLUsed;
|
||||
|
||||
nsWeakPtr mContentAreaDocShellWeak;
|
||||
|
||||
nsIDOMWindowInternal* mDOMWindow; // weak reference
|
||||
|
||||
#ifdef DEBUG_warren
|
||||
PRIntervalTime mLoadStartTime;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // nsBrowserInstance_h___
|
|
@ -47,7 +47,6 @@
|
|||
#endif
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
#include "nsBrowserInstance.h"
|
||||
#endif
|
||||
|
||||
#include "nsBrowserStatusFilter.h"
|
||||
|
@ -58,7 +57,6 @@
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHTTPIndex, Init)
|
||||
#endif
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDirectoryViewerFactory)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserInstance)
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserStatusFilter)
|
||||
|
@ -109,11 +107,6 @@ static const nsModuleComponentInfo components[] = {
|
|||
{ "Directory Viewer", NS_HTTPINDEX_SERVICE_CID, NS_HTTPINDEX_DATASOURCE_CONTRACTID,
|
||||
nsHTTPIndexConstructor },
|
||||
#endif
|
||||
{ "nsBrowserInstance",
|
||||
NS_BROWSERINSTANCE_CID,
|
||||
NS_BROWSERINSTANCE_CONTRACTID,
|
||||
nsBrowserInstanceConstructor
|
||||
},
|
||||
#endif
|
||||
{ NS_BROWSERSTATUSFILTER_CLASSNAME,
|
||||
NS_BROWSERSTATUSFILTER_CID,
|
||||
|
|
Загрузка…
Ссылка в новой задаче