widget/windows/winrt/ToastNotificationHandler.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.

     1 /* -*- Mode: C++; tab-width: 4; 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 #pragma once
     8 #include <windows.ui.notifications.h>
     9 #include <windows.data.xml.dom.h>
    10 #include "mozwrlbase.h"
    11 #include "nsString.h"
    14 class ToastNotificationHandler {
    15     typedef ABI::Windows::UI::Notifications::IToastNotification IToastNotification;
    16     typedef ABI::Windows::UI::Notifications::IToastDismissedEventArgs IToastDismissedEventArgs;
    17     typedef ABI::Windows::UI::Notifications::IToastNotificationManagerStatics IToastNotificationManagerStatics;
    18     typedef ABI::Windows::UI::Notifications::ToastTemplateType ToastTemplateType;
    19     typedef ABI::Windows::Data::Xml::Dom::IXmlNode IXmlNode;
    20     typedef ABI::Windows::Data::Xml::Dom::IXmlDocument IXmlDocument;
    22     void SetNodeValueString(HSTRING inputString,Microsoft::WRL::ComPtr<IXmlNode> node,
    23                                             Microsoft::WRL::ComPtr<IXmlDocument> xml);
    24   public:
    25     ToastNotificationHandler() {};
    26     ~ToastNotificationHandler() {};
    28     bool DisplayNotification(HSTRING title, HSTRING msg, HSTRING imagePath,
    29                              const nsAString& aCookie, const nsAString& aAppId);
    30     bool DisplayTextNotification(HSTRING title, HSTRING msg,
    31                                  const nsAString& aCookie,
    32                                  const nsAString& aAppId);
    33     HRESULT OnActivate(IToastNotification *notification, IInspectable *inspectable);
    34     HRESULT OnDismiss(IToastNotification *notification,
    35                       IToastDismissedEventArgs* aArgs);
    37   private:
    38     nsString mCookie;
    39     Microsoft::WRL::ComPtr<IToastNotificationManagerStatics> mToastNotificationManagerStatics;
    41     bool CreateWindowsNotificationFromXml(IXmlDocument *toastXml,
    42                                           const nsAString& aAppId);
    43     Microsoft::WRL::ComPtr<IXmlDocument> InitializeXmlForTemplate(ToastTemplateType templateType);
    44 };

mercurial