michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsEditingSession_h__ michael@0: #define nsEditingSession_h__ michael@0: michael@0: michael@0: #ifndef nsWeakReference_h__ michael@0: #include "nsWeakReference.h" // for nsSupportsWeakReference, etc michael@0: #endif michael@0: michael@0: #include "nsAutoPtr.h" // for nsRefPtr michael@0: #include "nsCOMPtr.h" // for nsCOMPtr michael@0: #include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS michael@0: #include "nsIWeakReferenceUtils.h" // for nsWeakPtr michael@0: #include "nsWeakReference.h" // for nsSupportsWeakReference, etc michael@0: #include "nscore.h" // for nsresult michael@0: michael@0: #ifndef __gen_nsIWebProgressListener_h__ michael@0: #include "nsIWebProgressListener.h" michael@0: #endif michael@0: michael@0: #ifndef __gen_nsIEditingSession_h__ michael@0: #include "nsIEditingSession.h" // for NS_DECL_NSIEDITINGSESSION, etc michael@0: #endif michael@0: michael@0: #include "nsString.h" // for nsCString michael@0: michael@0: class nsIDOMWindow; michael@0: class nsISupports; michael@0: class nsITimer; michael@0: michael@0: #define NS_EDITINGSESSION_CID \ michael@0: { 0xbc26ff01, 0xf2bd, 0x11d4, { 0xa7, 0x3c, 0xe5, 0xa4, 0xb5, 0xa8, 0xbd, 0xfc } } michael@0: michael@0: michael@0: class nsComposerCommandsUpdater; michael@0: class nsIChannel; michael@0: class nsIControllers; michael@0: class nsIDocShell; michael@0: class nsIEditor; michael@0: class nsIWebProgress; michael@0: michael@0: class nsEditingSession : public nsIEditingSession, michael@0: public nsIWebProgressListener, michael@0: public nsSupportsWeakReference michael@0: { michael@0: public: michael@0: michael@0: nsEditingSession(); michael@0: virtual ~nsEditingSession(); michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: // nsIWebProgressListener michael@0: NS_DECL_NSIWEBPROGRESSLISTENER michael@0: michael@0: // nsIEditingSession michael@0: NS_DECL_NSIEDITINGSESSION michael@0: michael@0: protected: michael@0: michael@0: nsIDocShell * GetDocShellFromWindow(nsIDOMWindow *aWindow); michael@0: michael@0: nsresult SetupEditorCommandController(const char *aControllerClassName, michael@0: nsIDOMWindow *aWindow, michael@0: nsISupports *aContext, michael@0: uint32_t *aControllerId); michael@0: michael@0: nsresult SetContextOnControllerById(nsIControllers* aControllers, michael@0: nsISupports* aContext, michael@0: uint32_t aID); michael@0: michael@0: nsresult PrepareForEditing(nsIDOMWindow *aWindow); michael@0: michael@0: static void TimerCallback(nsITimer *aTimer, void *aClosure); michael@0: nsCOMPtr mLoadBlankDocTimer; michael@0: michael@0: // progress load stuff michael@0: nsresult StartDocumentLoad(nsIWebProgress *aWebProgress, michael@0: bool isToBeMadeEditable); michael@0: nsresult EndDocumentLoad(nsIWebProgress *aWebProgress, michael@0: nsIChannel* aChannel, nsresult aStatus, michael@0: bool isToBeMadeEditable); michael@0: nsresult StartPageLoad(nsIChannel *aChannel); michael@0: nsresult EndPageLoad(nsIWebProgress *aWebProgress, michael@0: nsIChannel* aChannel, nsresult aStatus); michael@0: michael@0: bool IsProgressForTargetDocument(nsIWebProgress *aWebProgress); michael@0: michael@0: void RemoveEditorControllers(nsIDOMWindow *aWindow); michael@0: void RemoveWebProgressListener(nsIDOMWindow *aWindow); michael@0: void RestoreAnimationMode(nsIDOMWindow *aWindow); michael@0: void RemoveListenersAndControllers(nsIDOMWindow *aWindow, michael@0: nsIEditor *aEditor); michael@0: michael@0: protected: michael@0: michael@0: bool mDoneSetup; // have we prepared for editing yet? michael@0: michael@0: // Used to prevent double creation of editor because nsIWebProgressListener michael@0: // receives a STATE_STOP notification before the STATE_START michael@0: // for our document, so we wait for the STATE_START, then STATE_STOP michael@0: // before creating an editor michael@0: bool mCanCreateEditor; michael@0: michael@0: bool mInteractive; michael@0: bool mMakeWholeDocumentEditable; michael@0: michael@0: bool mDisabledJSAndPlugins; michael@0: michael@0: // True if scripts were enabled before the editor turned scripts michael@0: // off, otherwise false. michael@0: bool mScriptsEnabled; michael@0: michael@0: // True if plugins were enabled before the editor turned plugins michael@0: // off, otherwise false. michael@0: bool mPluginsEnabled; michael@0: michael@0: bool mProgressListenerRegistered; michael@0: michael@0: // The image animation mode before it was turned off. michael@0: uint16_t mImageAnimationMode; michael@0: michael@0: // THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT michael@0: // MORE THAN ONE EDITOR PER EDITING SESSION michael@0: nsRefPtr mStateMaintainer; michael@0: michael@0: // Save the editor type so we can create the editor after loading uri michael@0: nsCString mEditorType; michael@0: uint32_t mEditorFlags; michael@0: uint32_t mEditorStatus; michael@0: uint32_t mBaseCommandControllerId; michael@0: uint32_t mDocStateControllerId; michael@0: uint32_t mHTMLCommandControllerId; michael@0: michael@0: // Make sure the docshell we use is safe michael@0: nsWeakPtr mDocShell; michael@0: michael@0: // See if we can reuse an existing editor michael@0: nsWeakPtr mExistingEditor; michael@0: }; michael@0: michael@0: michael@0: michael@0: #endif // nsEditingSession_h__