widget/windows/winrt/UIAAccessibilityBridge.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

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: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #pragma once
michael@0 7
michael@0 8 #if defined(ACCESSIBILITY)
michael@0 9
michael@0 10 #include "nsCOMPtr.h"
michael@0 11 #include "nsIObserver.h"
michael@0 12 #include "nsIObserverService.h"
michael@0 13 #include "nsServiceManagerUtils.h"
michael@0 14 #include "mozilla/a11y/Accessible.h"
michael@0 15
michael@0 16 #include "mozwrlbase.h"
michael@0 17
michael@0 18 namespace mozilla {
michael@0 19 namespace widget {
michael@0 20 namespace winrt {
michael@0 21
michael@0 22 // Connects to our accessibility framework to receive
michael@0 23 // events and query the dom.
michael@0 24 class AccessibilityBridge : public nsIObserver
michael@0 25 {
michael@0 26 public:
michael@0 27 NS_DECL_ISUPPORTS
michael@0 28 NS_DECL_NSIOBSERVER
michael@0 29
michael@0 30 AccessibilityBridge() {}
michael@0 31
michael@0 32 ~AccessibilityBridge() {
michael@0 33 Disconnect();
michael@0 34 }
michael@0 35
michael@0 36 bool Init(IUnknown* aBridge, mozilla::a11y::Accessible* aPtr) {
michael@0 37 mAccess = aPtr;
michael@0 38 mBridge = aBridge;
michael@0 39 return Connect();
michael@0 40 }
michael@0 41
michael@0 42 bool Connect() {
michael@0 43 nsresult rv;
michael@0 44
michael@0 45 nsCOMPtr<nsIObserverService> observerService =
michael@0 46 do_GetService("@mozilla.org/observer-service;1", &rv);
michael@0 47 if (NS_FAILED(rv)) {
michael@0 48 return false;
michael@0 49 }
michael@0 50 rv = observerService->AddObserver(this, "accessible-event", false);
michael@0 51 if (NS_FAILED(rv)) {
michael@0 52 return false;
michael@0 53 }
michael@0 54 return true;
michael@0 55 }
michael@0 56
michael@0 57 bool Connected() {
michael@0 58 return mAccess ? true : false;
michael@0 59 }
michael@0 60
michael@0 61 void Disconnect() {
michael@0 62 nsresult rv;
michael@0 63 nsCOMPtr<nsIObserverService> observerService =
michael@0 64 do_GetService("@mozilla.org/observer-service;1", &rv);
michael@0 65 if (NS_FAILED(rv)) {
michael@0 66 NS_WARNING("failed to get observersvc on shutdown.");
michael@0 67 return;
michael@0 68 }
michael@0 69 observerService->RemoveObserver(this, "accessible-event");
michael@0 70 mAccess = nullptr;
michael@0 71 }
michael@0 72
michael@0 73 private:
michael@0 74 nsRefPtr<mozilla::a11y::Accessible> mAccess;
michael@0 75 Microsoft::WRL::ComPtr<IUnknown> mBridge;
michael@0 76 };
michael@0 77
michael@0 78 } } }
michael@0 79
michael@0 80 #endif // ACCESSIBILITY

mercurial