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 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* vim:expandtab:shiftwidth=4:tabstop=4: |
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 | |
michael@0 | 8 | #include "prlink.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "nsBidiKeyboard.h" |
michael@0 | 11 | #include <gtk/gtk.h> |
michael@0 | 12 | |
michael@0 | 13 | #if (MOZ_WIDGET_GTK == 2) |
michael@0 | 14 | typedef gboolean (*GdkKeymapHaveBidiLayoutsType)(GdkKeymap *keymap); |
michael@0 | 15 | static GdkKeymapHaveBidiLayoutsType GdkKeymapHaveBidiLayouts = nullptr; |
michael@0 | 16 | #endif |
michael@0 | 17 | |
michael@0 | 18 | NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard) |
michael@0 | 19 | |
michael@0 | 20 | nsBidiKeyboard::nsBidiKeyboard() |
michael@0 | 21 | { |
michael@0 | 22 | Reset(); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | NS_IMETHODIMP |
michael@0 | 26 | nsBidiKeyboard::Reset() |
michael@0 | 27 | { |
michael@0 | 28 | #if (MOZ_WIDGET_GTK == 2) |
michael@0 | 29 | PRLibrary *gtklib = nullptr; |
michael@0 | 30 | #if defined(MOZ_X11) |
michael@0 | 31 | if (!GdkKeymapHaveBidiLayouts) { |
michael@0 | 32 | GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType) |
michael@0 | 33 | PR_FindFunctionSymbolAndLibrary("gdk_keymap_have_bidi_layouts", |
michael@0 | 34 | >klib); |
michael@0 | 35 | if (gtklib) |
michael@0 | 36 | PR_UnloadLibrary(gtklib); |
michael@0 | 37 | } |
michael@0 | 38 | #endif |
michael@0 | 39 | |
michael@0 | 40 | mHaveBidiKeyboards = false; |
michael@0 | 41 | if (GdkKeymapHaveBidiLayouts) |
michael@0 | 42 | mHaveBidiKeyboards = (*GdkKeymapHaveBidiLayouts)(nullptr); |
michael@0 | 43 | #else |
michael@0 | 44 | mHaveBidiKeyboards = gdk_keymap_have_bidi_layouts(gdk_keymap_get_default()); |
michael@0 | 45 | #endif |
michael@0 | 46 | return NS_OK; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | nsBidiKeyboard::~nsBidiKeyboard() |
michael@0 | 50 | { |
michael@0 | 51 | #if (MOZ_WIDGET_GTK == 2) |
michael@0 | 52 | GdkKeymapHaveBidiLayouts = nullptr; |
michael@0 | 53 | #endif |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | NS_IMETHODIMP |
michael@0 | 57 | nsBidiKeyboard::IsLangRTL(bool *aIsRTL) |
michael@0 | 58 | { |
michael@0 | 59 | if (!mHaveBidiKeyboards) |
michael@0 | 60 | return NS_ERROR_FAILURE; |
michael@0 | 61 | |
michael@0 | 62 | *aIsRTL = (gdk_keymap_get_direction(gdk_keymap_get_default()) == PANGO_DIRECTION_RTL); |
michael@0 | 63 | |
michael@0 | 64 | return NS_OK; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult) |
michael@0 | 68 | { |
michael@0 | 69 | // not implemented yet |
michael@0 | 70 | return NS_ERROR_NOT_IMPLEMENTED; |
michael@0 | 71 | } |