toolkit/components/satchel/nsFormFillController.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 __nsFormFillController__
     7 #define __nsFormFillController__
     9 #include "nsIFormFillController.h"
    10 #include "nsIAutoCompleteInput.h"
    11 #include "nsIAutoCompleteSearch.h"
    12 #include "nsIAutoCompleteController.h"
    13 #include "nsIAutoCompletePopup.h"
    14 #include "nsIFormAutoComplete.h"
    15 #include "nsIDOMEventListener.h"
    16 #include "nsCOMPtr.h"
    17 #include "nsDataHashtable.h"
    18 #include "nsIDocShell.h"
    19 #include "nsIDOMWindow.h"
    20 #include "nsIDOMHTMLInputElement.h"
    21 #include "nsILoginManager.h"
    22 #include "nsIMutationObserver.h"
    23 #include "nsTArray.h"
    25 // X.h defines KeyPress
    26 #ifdef KeyPress
    27 #undef KeyPress
    28 #endif
    30 class nsFormHistory;
    31 class nsINode;
    33 class nsFormFillController : public nsIFormFillController,
    34                              public nsIAutoCompleteInput,
    35                              public nsIAutoCompleteSearch,
    36                              public nsIDOMEventListener,
    37                              public nsIFormAutoCompleteObserver,
    38                              public nsIMutationObserver
    39 {
    40 public:
    41   NS_DECL_ISUPPORTS
    42   NS_DECL_NSIFORMFILLCONTROLLER
    43   NS_DECL_NSIAUTOCOMPLETESEARCH
    44   NS_DECL_NSIAUTOCOMPLETEINPUT
    45   NS_DECL_NSIFORMAUTOCOMPLETEOBSERVER
    46   NS_DECL_NSIDOMEVENTLISTENER
    47   NS_DECL_NSIMUTATIONOBSERVER
    49   nsresult Focus(nsIDOMEvent* aEvent);
    50   nsresult KeyPress(nsIDOMEvent* aKeyEvent);
    51   nsresult MouseDown(nsIDOMEvent* aMouseEvent);
    53   nsFormFillController();
    54   virtual ~nsFormFillController();
    56 protected:
    57   void AddWindowListeners(nsIDOMWindow *aWindow);
    58   void RemoveWindowListeners(nsIDOMWindow *aWindow);
    60   void AddKeyListener(nsINode* aInput);
    61   void RemoveKeyListener();
    63   void StartControllingInput(nsIDOMHTMLInputElement *aInput);
    64   void StopControllingInput();
    66   nsresult PerformInputListAutoComplete(nsIAutoCompleteResult* aPreviousResult);
    68   void RevalidateDataList();
    69   bool RowMatch(nsFormHistory *aHistory, uint32_t aIndex, const nsAString &aInputName, const nsAString &aInputValue);
    71   inline nsIDocShell *GetDocShellForInput(nsIDOMHTMLInputElement *aInput);
    72   inline nsIDOMWindow *GetWindowForDocShell(nsIDocShell *aDocShell);
    73   inline int32_t GetIndexOfDocShell(nsIDocShell *aDocShell);
    75   void MaybeRemoveMutationObserver(nsINode* aNode);
    77   static PLDHashOperator RemoveForDocumentEnumerator(const nsINode* aKey,
    78                                                      bool& aEntry,
    79                                                      void* aUserData);
    80   bool IsEventTrusted(nsIDOMEvent *aEvent);
    81   // members //////////////////////////////////////////
    83   nsCOMPtr<nsIAutoCompleteController> mController;
    84   nsCOMPtr<nsILoginManager> mLoginManager;
    85   nsIDOMHTMLInputElement* mFocusedInput;
    86   nsINode* mFocusedInputNode;
    88   // mListNode is a <datalist> element which, is set, has the form fill controller
    89   // as a mutation observer for it.
    90   nsINode* mListNode;
    91   nsCOMPtr<nsIAutoCompletePopup> mFocusedPopup;
    93   nsTArray<nsCOMPtr<nsIDocShell> > mDocShells;
    94   nsTArray<nsCOMPtr<nsIAutoCompletePopup> > mPopups;
    96   //these are used to dynamically update the autocomplete
    97   nsCOMPtr<nsIAutoCompleteResult> mLastSearchResult;
    99   // The observer passed to StartSearch. It will be notified when the search is
   100   // complete or the data from a datalist changes.
   101   nsCOMPtr<nsIAutoCompleteObserver> mLastListener;
   103   // This is cleared by StopSearch().
   104   nsCOMPtr<nsIFormAutoComplete> mLastFormAutoComplete;
   105   nsString mLastSearchString;
   107   nsDataHashtable<nsPtrHashKey<const nsINode>, bool> mPwmgrInputs;
   109   uint32_t mTimeout;
   110   uint32_t mMinResultsForPopup;
   111   uint32_t mMaxRows;
   112   bool mDisableAutoComplete;
   113   bool mCompleteDefaultIndex;
   114   bool mCompleteSelectedIndex;
   115   bool mForceComplete;
   116   bool mSuppressOnInput;
   117 };
   119 #endif // __nsFormFillController__

mercurial