editor/composer/src/nsEditingSession.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsEditingSession_h__
     7 #define nsEditingSession_h__
    10 #ifndef nsWeakReference_h__
    11 #include "nsWeakReference.h"            // for nsSupportsWeakReference, etc
    12 #endif
    14 #include "nsAutoPtr.h"                  // for nsRefPtr
    15 #include "nsCOMPtr.h"                   // for nsCOMPtr
    16 #include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS
    17 #include "nsIWeakReferenceUtils.h"      // for nsWeakPtr
    18 #include "nsWeakReference.h"            // for nsSupportsWeakReference, etc
    19 #include "nscore.h"                     // for nsresult
    21 #ifndef __gen_nsIWebProgressListener_h__
    22 #include "nsIWebProgressListener.h"
    23 #endif
    25 #ifndef __gen_nsIEditingSession_h__
    26 #include "nsIEditingSession.h"          // for NS_DECL_NSIEDITINGSESSION, etc
    27 #endif
    29 #include "nsString.h"                   // for nsCString
    31 class nsIDOMWindow;
    32 class nsISupports;
    33 class nsITimer;
    35 #define NS_EDITINGSESSION_CID                            \
    36 { 0xbc26ff01, 0xf2bd, 0x11d4, { 0xa7, 0x3c, 0xe5, 0xa4, 0xb5, 0xa8, 0xbd, 0xfc } }
    39 class nsComposerCommandsUpdater;
    40 class nsIChannel;
    41 class nsIControllers;
    42 class nsIDocShell;
    43 class nsIEditor;
    44 class nsIWebProgress;
    46 class nsEditingSession : public nsIEditingSession,
    47                          public nsIWebProgressListener,
    48                          public nsSupportsWeakReference
    49 {
    50 public:
    52                   nsEditingSession();
    53   virtual         ~nsEditingSession();
    55   // nsISupports
    56   NS_DECL_ISUPPORTS
    58   // nsIWebProgressListener
    59   NS_DECL_NSIWEBPROGRESSLISTENER
    61   // nsIEditingSession
    62   NS_DECL_NSIEDITINGSESSION
    64 protected:
    66   nsIDocShell *   GetDocShellFromWindow(nsIDOMWindow *aWindow);
    68   nsresult        SetupEditorCommandController(const char *aControllerClassName,
    69                                                nsIDOMWindow *aWindow,
    70                                                nsISupports *aContext,
    71                                                uint32_t *aControllerId);
    73   nsresult        SetContextOnControllerById(nsIControllers* aControllers, 
    74                                             nsISupports* aContext,
    75                                             uint32_t aID);
    77   nsresult        PrepareForEditing(nsIDOMWindow *aWindow);
    79   static void     TimerCallback(nsITimer *aTimer, void *aClosure);
    80   nsCOMPtr<nsITimer>  mLoadBlankDocTimer;
    82   // progress load stuff
    83   nsresult        StartDocumentLoad(nsIWebProgress *aWebProgress,
    84                                     bool isToBeMadeEditable);
    85   nsresult        EndDocumentLoad(nsIWebProgress *aWebProgress, 
    86                                   nsIChannel* aChannel, nsresult aStatus,
    87                                   bool isToBeMadeEditable);
    88   nsresult        StartPageLoad(nsIChannel *aChannel);
    89   nsresult        EndPageLoad(nsIWebProgress *aWebProgress, 
    90                               nsIChannel* aChannel, nsresult aStatus);
    92   bool            IsProgressForTargetDocument(nsIWebProgress *aWebProgress);
    94   void            RemoveEditorControllers(nsIDOMWindow *aWindow);
    95   void            RemoveWebProgressListener(nsIDOMWindow *aWindow);
    96   void            RestoreAnimationMode(nsIDOMWindow *aWindow);
    97   void            RemoveListenersAndControllers(nsIDOMWindow *aWindow,
    98                                                 nsIEditor *aEditor);
   100 protected:
   102   bool            mDoneSetup;    // have we prepared for editing yet?
   104   // Used to prevent double creation of editor because nsIWebProgressListener
   105   //  receives a STATE_STOP notification before the STATE_START 
   106   //  for our document, so we wait for the STATE_START, then STATE_STOP 
   107   //  before creating an editor
   108   bool            mCanCreateEditor; 
   110   bool            mInteractive;
   111   bool            mMakeWholeDocumentEditable;
   113   bool            mDisabledJSAndPlugins;
   115   // True if scripts were enabled before the editor turned scripts
   116   // off, otherwise false.
   117   bool            mScriptsEnabled;
   119   // True if plugins were enabled before the editor turned plugins
   120   // off, otherwise false.
   121   bool            mPluginsEnabled;
   123   bool            mProgressListenerRegistered;
   125   // The image animation mode before it was turned off.
   126   uint16_t        mImageAnimationMode;
   128   // THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT
   129   // MORE THAN ONE EDITOR PER EDITING SESSION
   130   nsRefPtr<nsComposerCommandsUpdater> mStateMaintainer;
   132   // Save the editor type so we can create the editor after loading uri
   133   nsCString       mEditorType; 
   134   uint32_t        mEditorFlags;
   135   uint32_t        mEditorStatus;
   136   uint32_t        mBaseCommandControllerId;
   137   uint32_t        mDocStateControllerId;
   138   uint32_t        mHTMLCommandControllerId;
   140   // Make sure the docshell we use is safe
   141   nsWeakPtr       mDocShell;
   143   // See if we can reuse an existing editor
   144   nsWeakPtr       mExistingEditor;
   145 };
   149 #endif // nsEditingSession_h__

mercurial