Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 /* vim: se cin sw=2 ts=2 et : */
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef __mozilla_widget_TaskbarPreview_h__
9 #define __mozilla_widget_TaskbarPreview_h__
11 #include <windows.h>
12 #include <shobjidl.h>
13 #undef LogSeverity // SetupAPI.h #defines this as DWORD
15 #include <nsITaskbarPreview.h>
16 #include <nsAutoPtr.h>
17 #include <nsString.h>
18 #include <nsWeakPtr.h>
19 #include <nsIDocShell.h>
20 #include "WindowHook.h"
22 namespace mozilla {
23 namespace widget {
25 class TaskbarPreview : public nsITaskbarPreview
26 {
27 public:
28 TaskbarPreview(ITaskbarList4 *aTaskbar, nsITaskbarPreviewController *aController, HWND aHWND, nsIDocShell *aShell);
29 virtual ~TaskbarPreview();
31 NS_DECL_NSITASKBARPREVIEW
33 protected:
34 // Called to update ITaskbarList4 dependent properties
35 virtual nsresult UpdateTaskbarProperties();
37 // Invoked when the preview is made visible
38 virtual nsresult Enable();
39 // Invoked when the preview is made invisible
40 virtual nsresult Disable();
42 // Detaches this preview from the nsWindow instance it's tied to
43 virtual void DetachFromNSWindow();
45 // Determines if the window is available and a destroy has not yet started
46 bool IsWindowAvailable() const;
48 // Marks this preview as being active
49 virtual nsresult ShowActive(bool active) = 0;
50 // Gets a reference to the window used to handle the preview messages
51 virtual HWND& PreviewWindow() = 0;
53 // Window procedure for the PreviewWindow (hooked for window previews)
54 virtual LRESULT WndProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
56 // Returns whether or not the taskbar icon has been created for mWnd The
57 // ITaskbarList4 API requires that we wait until the icon has been created
58 // before we can call its methods.
59 bool CanMakeTaskbarCalls();
61 // Gets the WindowHook for the nsWindow
62 WindowHook &GetWindowHook();
64 // Enables/disables custom drawing for the given window
65 static void EnableCustomDrawing(HWND aHWND, bool aEnable);
67 // MSCOM Taskbar interface
68 nsRefPtr<ITaskbarList4> mTaskbar;
69 // Controller for this preview
70 nsCOMPtr<nsITaskbarPreviewController> mController;
71 // The HWND to the nsWindow that this object previews
72 HWND mWnd;
73 // Whether or not this preview is visible
74 bool mVisible;
76 private:
77 // Called when the tooltip should be updated
78 nsresult UpdateTooltip();
80 // Requests the controller to draw into a canvas of the given width and
81 // height. The resulting bitmap is sent to the DWM to display.
82 void DrawBitmap(uint32_t width, uint32_t height, bool isPreview);
84 // WindowHook procedure for hooking mWnd
85 static bool MainWindowHook(void *aContext,
86 HWND hWnd, UINT nMsg,
87 WPARAM wParam, LPARAM lParam,
88 LRESULT *aResult);
90 // Docshell corresponding to the <window> the nsWindow contains
91 nsWeakPtr mDocShell;
92 nsString mTooltip;
94 // The preview currently marked as active in the taskbar. nullptr if no
95 // preview is active (some other window is).
96 static TaskbarPreview *sActivePreview;
97 };
99 } // namespace widget
100 } // namespace mozilla
102 #endif /* __mozilla_widget_TaskbarPreview_h__ */