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.
michael@0 | 1 | /* vim: se cin sw=2 ts=2 et : */ |
michael@0 | 2 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 3 | * |
michael@0 | 4 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | #ifndef __UXThemeData_h__ |
michael@0 | 8 | #define __UXThemeData_h__ |
michael@0 | 9 | #include <windows.h> |
michael@0 | 10 | #include <uxtheme.h> |
michael@0 | 11 | |
michael@0 | 12 | #include "nscore.h" |
michael@0 | 13 | #include "mozilla/LookAndFeel.h" |
michael@0 | 14 | #include "WinUtils.h" |
michael@0 | 15 | |
michael@0 | 16 | #include <dwmapi.h> |
michael@0 | 17 | |
michael@0 | 18 | #include "nsWindowDefs.h" |
michael@0 | 19 | |
michael@0 | 20 | // These window messages are not defined in dwmapi.h |
michael@0 | 21 | #ifndef WM_DWMCOMPOSITIONCHANGED |
michael@0 | 22 | #define WM_DWMCOMPOSITIONCHANGED 0x031E |
michael@0 | 23 | #endif |
michael@0 | 24 | |
michael@0 | 25 | // Windows 7 additions |
michael@0 | 26 | #ifndef WM_DWMSENDICONICTHUMBNAIL |
michael@0 | 27 | #define WM_DWMSENDICONICTHUMBNAIL 0x0323 |
michael@0 | 28 | #define WM_DWMSENDICONICLIVEPREVIEWBITMAP 0x0326 |
michael@0 | 29 | #endif |
michael@0 | 30 | |
michael@0 | 31 | #define DWMWA_FORCE_ICONIC_REPRESENTATION 7 |
michael@0 | 32 | #define DWMWA_HAS_ICONIC_BITMAP 10 |
michael@0 | 33 | |
michael@0 | 34 | enum nsUXThemeClass { |
michael@0 | 35 | eUXButton = 0, |
michael@0 | 36 | eUXEdit, |
michael@0 | 37 | eUXTooltip, |
michael@0 | 38 | eUXRebar, |
michael@0 | 39 | eUXMediaRebar, |
michael@0 | 40 | eUXCommunicationsRebar, |
michael@0 | 41 | eUXBrowserTabBarRebar, |
michael@0 | 42 | eUXToolbar, |
michael@0 | 43 | eUXMediaToolbar, |
michael@0 | 44 | eUXCommunicationsToolbar, |
michael@0 | 45 | eUXProgress, |
michael@0 | 46 | eUXTab, |
michael@0 | 47 | eUXScrollbar, |
michael@0 | 48 | eUXTrackbar, |
michael@0 | 49 | eUXSpin, |
michael@0 | 50 | eUXStatus, |
michael@0 | 51 | eUXCombobox, |
michael@0 | 52 | eUXHeader, |
michael@0 | 53 | eUXListview, |
michael@0 | 54 | eUXMenu, |
michael@0 | 55 | eUXWindowFrame, |
michael@0 | 56 | eUXNumClasses |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | // Native windows style constants |
michael@0 | 60 | enum WindowsTheme { |
michael@0 | 61 | WINTHEME_UNRECOGNIZED = 0, |
michael@0 | 62 | WINTHEME_CLASSIC = 1, // no theme |
michael@0 | 63 | WINTHEME_AERO = 2, |
michael@0 | 64 | WINTHEME_LUNA = 3, |
michael@0 | 65 | WINTHEME_ROYALE = 4, |
michael@0 | 66 | WINTHEME_ZUNE = 5, |
michael@0 | 67 | WINTHEME_AERO_LITE = 6 |
michael@0 | 68 | }; |
michael@0 | 69 | enum WindowsThemeColor { |
michael@0 | 70 | WINTHEMECOLOR_UNRECOGNIZED = 0, |
michael@0 | 71 | WINTHEMECOLOR_NORMAL = 1, |
michael@0 | 72 | WINTHEMECOLOR_HOMESTEAD = 2, |
michael@0 | 73 | WINTHEMECOLOR_METALLIC = 3 |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | #define CMDBUTTONIDX_MINIMIZE 0 |
michael@0 | 77 | #define CMDBUTTONIDX_RESTORE 1 |
michael@0 | 78 | #define CMDBUTTONIDX_CLOSE 2 |
michael@0 | 79 | #define CMDBUTTONIDX_BUTTONBOX 3 |
michael@0 | 80 | |
michael@0 | 81 | class nsUXThemeData { |
michael@0 | 82 | static HMODULE sThemeDLL; |
michael@0 | 83 | static HANDLE sThemes[eUXNumClasses]; |
michael@0 | 84 | |
michael@0 | 85 | static const wchar_t *GetClassName(nsUXThemeClass); |
michael@0 | 86 | |
michael@0 | 87 | public: |
michael@0 | 88 | static const wchar_t kThemeLibraryName[]; |
michael@0 | 89 | static bool sFlatMenus; |
michael@0 | 90 | static bool sTitlebarInfoPopulatedAero; |
michael@0 | 91 | static bool sTitlebarInfoPopulatedThemed; |
michael@0 | 92 | static SIZE sCommandButtons[4]; |
michael@0 | 93 | static mozilla::LookAndFeel::WindowsTheme sThemeId; |
michael@0 | 94 | static bool sIsDefaultWindowsTheme; |
michael@0 | 95 | static bool sIsHighContrastOn; |
michael@0 | 96 | |
michael@0 | 97 | static void Initialize(); |
michael@0 | 98 | static void Teardown(); |
michael@0 | 99 | static void Invalidate(); |
michael@0 | 100 | static HANDLE GetTheme(nsUXThemeClass cls); |
michael@0 | 101 | static HMODULE GetThemeDLL(); |
michael@0 | 102 | |
michael@0 | 103 | // nsWindow calls this to update desktop settings info |
michael@0 | 104 | static void InitTitlebarInfo(); |
michael@0 | 105 | static void UpdateTitlebarInfo(HWND aWnd); |
michael@0 | 106 | |
michael@0 | 107 | static void UpdateNativeThemeInfo(); |
michael@0 | 108 | static mozilla::LookAndFeel::WindowsTheme GetNativeThemeId(); |
michael@0 | 109 | static bool IsDefaultWindowTheme(); |
michael@0 | 110 | static bool IsHighContrastOn(); |
michael@0 | 111 | |
michael@0 | 112 | // This method returns the cached compositor state. Most |
michael@0 | 113 | // callers should call without the argument. The cache |
michael@0 | 114 | // should be modified only when the application receives |
michael@0 | 115 | // WM_DWMCOMPOSITIONCHANGED. This rule prevents inconsistent |
michael@0 | 116 | // results for two or more calls which check the state during |
michael@0 | 117 | // composition transition. |
michael@0 | 118 | static bool CheckForCompositor(bool aUpdateCache = false); |
michael@0 | 119 | }; |
michael@0 | 120 | #endif // __UXThemeData_h__ |