Use smart pointer for everything

This commit is contained in:
Cheng Zhao 2015-11-10 19:50:38 +08:00
parent 1b9c9e40e3
commit 6b9371c4cd
6 changed files with 240 additions and 268 deletions

View file

@ -35,7 +35,7 @@ NotificationPresenterWin::~NotificationPresenterWin() {
void NotificationPresenterWin::ShowNotification( void NotificationPresenterWin::ShowNotification(
const content::PlatformNotificationData& data, const content::PlatformNotificationData& data,
const SkBitmap& icon, const SkBitmap& icon,
scoped_ptr<content::DesktopNotificationDelegate> delegate_ptr, scoped_ptr<content::DesktopNotificationDelegate> delegate,
base::Closure* cancel_callback) { base::Closure* cancel_callback) {
std::wstring title = data.title; std::wstring title = data.title;
std::wstring body = data.body; std::wstring body = data.body;
@ -45,7 +45,7 @@ void NotificationPresenterWin::ShowNotification(
// toast notification supported in version >= Windows 8 // toast notification supported in version >= Windows 8
// for prior versions, use Tray.displayBalloon // for prior versions, use Tray.displayBalloon
if (base::win::GetVersion() >= base::win::VERSION_WIN8) { if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
wtn = new WindowsToastNotification(appName.c_str(), delegate_ptr.release()); wtn = new WindowsToastNotification(appName.c_str(), delegate.Pass());
wtn->ShowNotification(title.c_str(), body.c_str(), iconPath, m_lastNotification); wtn->ShowNotification(title.c_str(), body.c_str(), iconPath, m_lastNotification);
} }

View file

@ -0,0 +1,28 @@
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file.
#include "browser/win/scoped_hstring.h"
#include <winstring.h>
ScopedHString::ScopedHString(const wchar_t* source)
: str_(nullptr) {
Set(source);
}
ScopedHString::ScopedHString() : str_(nullptr) {
}
ScopedHString::~ScopedHString() {
if (str_)
WindowsDeleteString(str_);
}
void ScopedHString::Set(const wchar_t* source) {
if (str_) {
WindowsDeleteString(str_);
str_ = nullptr;
}
WindowsCreateString(source, wcslen(source), &str_);
}

View file

@ -0,0 +1,36 @@
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file.
#ifndef BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_
#define BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_
#include <hstring.h>
#include <windows.h>
#include "base/basictypes.h"
class ScopedHString {
public:
// Copy from |source|.
ScopedHString(const wchar_t* source);
// Create empty string.
ScopedHString();
~ScopedHString();
// Sets to |source|.
void Set(const wchar_t* source);
// Returns string.
operator HSTRING() const { return str_; }
// Whether there is a string created.
bool success() const { return str_; }
private:
HSTRING str_;
DISALLOW_COPY_AND_ASSIGN(ScopedHString);
};
#endif // BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_

View file

@ -5,6 +5,8 @@
#include "browser/win/windows_toast_notification.h" #include "browser/win/windows_toast_notification.h"
#include "base/strings/utf_string_conversions.h"
#include "browser/win/scoped_hstring.h"
#include "content/public/browser/desktop_notification_delegate.h" #include "content/public/browser/desktop_notification_delegate.h"
using namespace WinToasts; using namespace WinToasts;
@ -22,317 +24,232 @@ HRESULT init = Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
} // namespace } // namespace
WindowsToastNotification::WindowsToastNotification( WindowsToastNotification::WindowsToastNotification(
const char* appName, content::DesktopNotificationDelegate* delegate) { const char* app_name,
HSTRING toastNotifMgrStr = nullptr; scoped_ptr<content::DesktopNotificationDelegate> delegate)
HSTRING appId = nullptr; : delegate_(delegate.Pass()) {
ScopedHString toast_manager_str(
RuntimeClass_Windows_UI_Notifications_ToastNotificationManager);
if (!toast_manager_str.success())
return;
HRESULT hr = Windows::Foundation::GetActivationFactory(
toast_manager_str, &toast_manager_);
if (FAILED(hr))
return;
HRESULT hr = CreateHString(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager, &toastNotifMgrStr); ScopedHString app_id(base::UTF8ToUTF16(app_name).c_str());
if (!app_id.success())
return;
hr = Windows::Foundation::GetActivationFactory(toastNotifMgrStr, &m_toastManager); toast_manager_->CreateToastNotifierWithId(app_id, &toast_notifier_);
WCHAR wAppName[MAX_PATH];
swprintf(wAppName, ARRAYSIZE(wAppName), L"%S", appName);
hr = CreateHString(wAppName, &appId);
m_toastManager->CreateToastNotifierWithId(appId, &m_toastNotifier);
if (toastNotifMgrStr) {
WindowsDeleteString(toastNotifMgrStr);
}
if (appId) {
WindowsDeleteString(appId);
}
n_delegate = delegate;
} }
WindowsToastNotification::~WindowsToastNotification() { WindowsToastNotification::~WindowsToastNotification() {
if (n_delegate) {
delete n_delegate;
}
} }
void WindowsToastNotification::ShowNotification( void WindowsToastNotification::ShowNotification(
const WCHAR* title, const WCHAR* msg, std::string iconPath, ComPtr<IToastNotification>& toast) { const WCHAR* title,
HRESULT hr; const WCHAR* msg,
HSTRING toastNotifStr = nullptr; std::string icon_path,
ComPtr<IToastNotification>& toast) {
ComPtr<IXmlDocument> toast_xml;
if(FAILED(GetToastXml(toast_manager_.Get(), title, msg, icon_path, &toast_xml)))
return;
do { ScopedHString toast_str(
ComPtr<IXmlDocument> toastXml; RuntimeClass_Windows_UI_Notifications_ToastNotification);
hr = GetToastXml(m_toastManager.Get(), title, msg, iconPath, &toastXml); if (!toast_str.success())
BREAK_IF_BAD(hr); return;
hr = CreateHString(RuntimeClass_Windows_UI_Notifications_ToastNotification, &toastNotifStr);
BREAK_IF_BAD(hr);
ComPtr<IToastNotificationFactory> toastFactory; ComPtr<IToastNotificationFactory> toastFactory;
hr = Windows::Foundation::GetActivationFactory(toastNotifStr, &toastFactory); if (FAILED(Windows::Foundation::GetActivationFactory(toast_str, &toastFactory)))
BREAK_IF_BAD(hr); return;
hr = toastFactory->CreateToastNotification(toastXml.Get(), &toast); if (FAILED(toastFactory->CreateToastNotification(toast_xml.Get(), &toast)))
BREAK_IF_BAD(hr); return;
hr = SetupCallbacks(toast.Get()); if (FAILED(SetupCallbacks(toast.Get())))
BREAK_IF_BAD(hr); return;
hr = m_toastNotifier->Show(toast.Get()); if (FAILED(toast_notifier_->Show(toast.Get())))
BREAK_IF_BAD(hr); return;
n_delegate->NotificationDisplayed(); delegate_->NotificationDisplayed();
} while (FALSE);
if (toastNotifStr) {
WindowsDeleteString(toastNotifStr);
}
} }
void WindowsToastNotification::DismissNotification( void WindowsToastNotification::DismissNotification(
ComPtr<IToastNotification> toast) { ComPtr<IToastNotification> toast) {
m_toastNotifier->Hide(toast.Get()); toast_notifier_->Hide(toast.Get());
} }
void WindowsToastNotification::NotificationClicked() { void WindowsToastNotification::NotificationClicked() {
delegate_->NotificationClick();
delete this; delete this;
} }
void WindowsToastNotification::NotificationDismissed() { void WindowsToastNotification::NotificationDismissed() {
delegate_->NotificationClosed();
delete this; delete this;
} }
HRESULT WindowsToastNotification::GetToastXml( bool WindowsToastNotification::GetToastXml(
IToastNotificationManagerStatics* toastManager, IToastNotificationManagerStatics* toastManager,
const WCHAR* title, const WCHAR* title,
const WCHAR* msg, const WCHAR* msg,
std::string iconPath, std::string icon_path,
IXmlDocument** toastXml) { IXmlDocument** toast_xml) {
HRESULT hr; ToastTemplateType template_type;
ToastTemplateType templateType; if (!title || !msg) {
if (title == NULL || msg == NULL) { // Single line toast.
// Single line toast template_type = icon_path.empty() ? ToastTemplateType_ToastText01 :
templateType = iconPath.length() == 0 ? ToastTemplateType_ToastText01 : ToastTemplateType_ToastImageAndText01; ToastTemplateType_ToastImageAndText01;
hr = m_toastManager->GetTemplateContent(templateType, toastXml); if (FAILED(toast_manager_->GetTemplateContent(template_type, toast_xml)))
if (SUCCEEDED(hr)) { return false;
const WCHAR* text = title != NULL ? title : msg; if (!SetXmlText(*toast_xml, title ? title : msg))
hr = SetXmlText(*toastXml, text); return false;
}
} else { } else {
// Title and body toast // Title and body toast.
templateType = iconPath.length() == 0 ? ToastTemplateType_ToastText02 : ToastTemplateType_ToastImageAndText02; template_type = icon_path.empty() ? ToastTemplateType_ToastText02 :
hr = toastManager->GetTemplateContent(templateType, toastXml); ToastTemplateType_ToastImageAndText02;
if (SUCCEEDED(hr)) { if (FAILED(toastManager->GetTemplateContent(template_type, toast_xml)))
hr = SetXmlText(*toastXml, title, msg); return false;
} if (!SetXmlText(*toast_xml, title, msg))
return false;
} }
if (iconPath.length() != 0 && SUCCEEDED(hr)) {
// Toast has image // Toast has image
if (SUCCEEDED(hr)) { if (!icon_path.empty())
hr = SetXmlImage(*toastXml, iconPath); return SetXmlImage(*toast_xml, icon_path);
return true;
} }
// Don't stop a notification from showing just because an image couldn't be displayed. By default the app icon will be shown. bool WindowsToastNotification::SetXmlText(
hr = S_OK;
}
return hr;
}
HRESULT WindowsToastNotification::SetXmlText(
IXmlDocument* doc, const WCHAR* text) { IXmlDocument* doc, const WCHAR* text) {
HSTRING tag = NULL; ScopedHString tag;
ComPtr<IXmlNodeList> node_list;
ComPtr<IXmlNodeList> nodeList; if (!GetTextNodeList(&tag, doc, &node_list, 1))
HRESULT hr = GetTextNodeList(&tag, doc, &nodeList, 1); return false;
do {
BREAK_IF_BAD(hr);
ComPtr<IXmlNode> node; ComPtr<IXmlNode> node;
hr = nodeList->Item(0, &node); if (FAILED(node_list->Item(0, &node)))
BREAK_IF_BAD(hr); return false;
hr = AppendTextToXml(doc, node.Get(), text); return AppendTextToXml(doc, node.Get(), text);
} while (FALSE);
if (tag != NULL) {
WindowsDeleteString(tag);
} }
return hr; bool WindowsToastNotification::SetXmlText(
}
HRESULT WindowsToastNotification::SetXmlText(
IXmlDocument* doc, const WCHAR* title, const WCHAR* body) { IXmlDocument* doc, const WCHAR* title, const WCHAR* body) {
HSTRING tag = NULL; ScopedHString tag;
ComPtr<IXmlNodeList> nodeList; ComPtr<IXmlNodeList> node_list;
HRESULT hr = GetTextNodeList(&tag, doc, &nodeList, 2); if (!GetTextNodeList(&tag, doc, &node_list, 2))
do { return false;
BREAK_IF_BAD(hr);
ComPtr<IXmlNode> node; ComPtr<IXmlNode> node;
hr = nodeList->Item(0, &node); if (FAILED(node_list->Item(0, &node)))
BREAK_IF_BAD(hr); return false;
hr = AppendTextToXml(doc, node.Get(), title); if (!AppendTextToXml(doc, node.Get(), title))
BREAK_IF_BAD(hr); return false;
hr = nodeList->Item(1, &node); if (FAILED(node_list->Item(1, &node)))
BREAK_IF_BAD(hr); return false;
hr = AppendTextToXml(doc, node.Get(), body); return AppendTextToXml(doc, node.Get(), body);
} while (FALSE);
if (tag != NULL) {
WindowsDeleteString(tag);
} }
return hr; bool WindowsToastNotification::SetXmlImage(
} IXmlDocument* doc, std::string icon_path) {
ScopedHString tag(L"imag");
if (!tag.success())
return false;
HRESULT WindowsToastNotification::SetXmlImage( ComPtr<IXmlNodeList> node_list;
IXmlDocument* doc, std::string iconPath) { if (FAILED(doc->GetElementsByTagName(tag, &node_list)))
HSTRING tag = NULL; return false;
HSTRING src = NULL;
HSTRING imgPath = NULL;
HRESULT hr = CreateHString(L"image", &tag);
do { ComPtr<IXmlNode> image_node;
BREAK_IF_BAD(hr); if (FAILED(node_list->Item(0, &image_node)))
return false;
ComPtr<IXmlNodeList> nodeList;
hr = doc->GetElementsByTagName(tag, &nodeList);
BREAK_IF_BAD(hr);
ComPtr<IXmlNode> imageNode;
hr = nodeList->Item(0, &imageNode);
BREAK_IF_BAD(hr);
ComPtr<IXmlNamedNodeMap> attrs; ComPtr<IXmlNamedNodeMap> attrs;
hr = imageNode->get_Attributes(&attrs); if (FAILED(image_node->get_Attributes(&attrs)))
BREAK_IF_BAD(hr); return false;
hr = CreateHString(L"src", &src); ScopedHString src(L"src");
BREAK_IF_BAD(hr); if (!src.success())
return false;
ComPtr<IXmlNode> srcAttr; ComPtr<IXmlNode> src_attr;
hr = attrs->GetNamedItem(src, &srcAttr); if (FAILED(attrs->GetNamedItem(src, &src_attr)))
BREAK_IF_BAD(hr); return false;
WCHAR xmlPath[MAX_PATH]; ScopedHString img_path(base::UTF8ToUTF16(icon_path).c_str());
swprintf(xmlPath, ARRAYSIZE(xmlPath), L"%S", iconPath); if (!img_path.success())
hr = CreateHString(xmlPath, &imgPath); return false;
BREAK_IF_BAD(hr);
ComPtr<IXmlText> srcText; ComPtr<IXmlText> src_text;
hr = doc->CreateTextNode(imgPath, &srcText); if (FAILED(doc->CreateTextNode(img_path, &src_text)))
BREAK_IF_BAD(hr); return false;
ComPtr<IXmlNode> srcNode; ComPtr<IXmlNode> src_node;
hr = srcText.As(&srcNode); if (FAILED(src_text.As(&src_node)))
BREAK_IF_BAD(hr); return false;
ComPtr<IXmlNode> childNode; ComPtr<IXmlNode> child_node;
hr = srcAttr->AppendChild(srcNode.Get(), &childNode); return SUCCEEDED(src_attr->AppendChild(src_node.Get(), &child_node));
} while (FALSE);
if (tag != NULL) {
WindowsDeleteString(tag);
}
if (src != NULL) {
WindowsDeleteString(src);
}
if (imgPath != NULL) {
WindowsDeleteString(imgPath);
} }
return hr; bool WindowsToastNotification::GetTextNodeList(
} ScopedHString* tag,
HRESULT WindowsToastNotification::GetTextNodeList(
HSTRING* tag,
IXmlDocument* doc, IXmlDocument* doc,
IXmlNodeList** nodeList, IXmlNodeList** node_list,
UINT32 reqLength) { UINT32 req_length) {
HRESULT hr = CreateHString(L"text", tag); tag->Set(L"text");
do { if (!tag->success())
BREAK_IF_BAD(hr); return false;
hr = doc->GetElementsByTagName(*tag, nodeList); if (FAILED(doc->GetElementsByTagName(*tag, node_list)))
BREAK_IF_BAD(hr); return false;
UINT32 nodeLength; UINT32 node_length;
hr = (*nodeList)->get_Length(&nodeLength); if (FAILED((*node_list)->get_Length(&node_length)))
BREAK_IF_BAD(hr); return false;
if (nodeLength < reqLength) { return node_length >= req_length;
hr = E_INVALIDARG;
}
} while (FALSE);
if (!SUCCEEDED(hr)) {
// Allow the caller to delete this string on success
WindowsDeleteString(*tag);
} }
return hr; bool WindowsToastNotification::AppendTextToXml(
}
HRESULT WindowsToastNotification::AppendTextToXml(
IXmlDocument* doc, IXmlNode* node, const WCHAR* text) { IXmlDocument* doc, IXmlNode* node, const WCHAR* text) {
HSTRING str = NULL; ScopedHString str(text);
HRESULT hr = CreateHString(text, &str); if (!str.success())
do { return false;
BREAK_IF_BAD(hr);
ComPtr<IXmlText> xmlText; ComPtr<IXmlText> xml_text;
hr = doc->CreateTextNode(str, &xmlText); if (FAILED(doc->CreateTextNode(str, &xml_text)))
BREAK_IF_BAD(hr); return false;
ComPtr<IXmlNode> textNode; ComPtr<IXmlNode> text_node;
hr = xmlText.As(&textNode); if (FAILED(xml_text.As(&text_node)))
BREAK_IF_BAD(hr); return false;
ComPtr<IXmlNode> appendNode; ComPtr<IXmlNode> append_node;
hr = node->AppendChild(textNode.Get(), &appendNode); return SUCCEEDED(node->AppendChild(text_node.Get(), &append_node));
} while (FALSE);
if (str != NULL) {
WindowsDeleteString(str);
} }
return hr; bool WindowsToastNotification::SetupCallbacks(IToastNotification* toast) {
}
HRESULT WindowsToastNotification::SetupCallbacks(IToastNotification* toast) {
EventRegistrationToken activatedToken, dismissedToken; EventRegistrationToken activatedToken, dismissedToken;
m_eventHandler = Make<ToastEventHandler>(this, n_delegate); event_handler_ = Make<ToastEventHandler>(this);
HRESULT hr = toast->add_Activated(m_eventHandler.Get(), &activatedToken); if (FAILED(toast->add_Activated(event_handler_.Get(), &activatedToken)))
return false;
if (SUCCEEDED(hr)) { return SUCCEEDED(toast->add_Dismissed(event_handler_.Get(), &dismissedToken));
hr = toast->add_Dismissed(m_eventHandler.Get(), &dismissedToken);
}
return hr;
}
HRESULT WindowsToastNotification::CreateHString(
const WCHAR* source, HSTRING* dest) {
if (source == NULL || dest == NULL) {
return E_INVALIDARG;
}
HRESULT hr = WindowsCreateString(source, wcslen(source), dest);
return hr;
} }
/* /*
/ Toast Event Handler / Toast Event Handler
*/ */
ToastEventHandler::ToastEventHandler( ToastEventHandler::ToastEventHandler(WindowsToastNotification* notification)
WindowsToastNotification* notification, : notification_(notification) {
content::DesktopNotificationDelegate* delegate) {
m_notification = notification;
n_delegate = delegate;
} }
ToastEventHandler::~ToastEventHandler() { ToastEventHandler::~ToastEventHandler() {
@ -340,26 +257,14 @@ ToastEventHandler::~ToastEventHandler() {
IFACEMETHODIMP ToastEventHandler::Invoke( IFACEMETHODIMP ToastEventHandler::Invoke(
IToastNotification* sender, IInspectable* args) { IToastNotification* sender, IInspectable* args) {
// Notification "activated" (clicked) notification_->NotificationClicked();
n_delegate->NotificationClick();
if (m_notification != NULL) {
m_notification->NotificationClicked();
}
return S_OK; return S_OK;
} }
IFACEMETHODIMP ToastEventHandler::Invoke( IFACEMETHODIMP ToastEventHandler::Invoke(
IToastNotification* sender, IToastDismissedEventArgs* e) { IToastNotification* sender, IToastDismissedEventArgs* e) {
// Notification dismissed notification_->NotificationDismissed();
n_delegate->NotificationClosed();
if (m_notification != NULL) {
m_notification->NotificationDismissed();
}
return S_OK; return S_OK;
} }
} //namespace } // namespace WinToasts

View file

@ -18,6 +18,8 @@ using namespace Microsoft::WRL;
using namespace ABI::Windows::UI::Notifications; using namespace ABI::Windows::UI::Notifications;
using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Foundation;
class ScopedHString;
namespace WinToasts { namespace WinToasts {
using DesktopToastActivatedEventHandler = using DesktopToastActivatedEventHandler =
@ -29,7 +31,9 @@ class ToastEventHandler;
class WindowsToastNotification { class WindowsToastNotification {
public: public:
WindowsToastNotification(const char* appName, content::DesktopNotificationDelegate* delegate); WindowsToastNotification(
const char* app_name,
scoped_ptr<content::DesktopNotificationDelegate> delegate);
~WindowsToastNotification(); ~WindowsToastNotification();
void ShowNotification(const WCHAR* title, const WCHAR* msg, std::string iconPath, ComPtr<IToastNotification>& toast); void ShowNotification(const WCHAR* title, const WCHAR* msg, std::string iconPath, ComPtr<IToastNotification>& toast);
@ -38,20 +42,18 @@ class WindowsToastNotification {
void NotificationDismissed(); void NotificationDismissed();
private: private:
ComPtr<ToastEventHandler> m_eventHandler; scoped_ptr<content::DesktopNotificationDelegate> delegate_;
ComPtr<ToastEventHandler> event_handler_;
ComPtr<IToastNotificationManagerStatics> toast_manager_;
ComPtr<IToastNotifier> toast_notifier_;
content::DesktopNotificationDelegate* n_delegate; bool GetToastXml(IToastNotificationManagerStatics* toastManager, const WCHAR* title, const WCHAR* msg, std::string iconPath, ABI::Windows::Data::Xml::Dom::IXmlDocument** toastXml);
ComPtr<IToastNotificationManagerStatics> m_toastManager; bool SetXmlText(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, const WCHAR* text);
ComPtr<IToastNotifier> m_toastNotifier; bool SetXmlText(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, const WCHAR* title, const WCHAR* body);
bool SetXmlImage(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, std::string iconPath);
HRESULT GetToastXml(IToastNotificationManagerStatics* toastManager, const WCHAR* title, const WCHAR* msg, std::string iconPath, ABI::Windows::Data::Xml::Dom::IXmlDocument** toastXml); bool GetTextNodeList(ScopedHString* tag, ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, ABI::Windows::Data::Xml::Dom::IXmlNodeList** nodeList, UINT32 reqLength);
HRESULT SetXmlText(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, const WCHAR* text); bool AppendTextToXml(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, ABI::Windows::Data::Xml::Dom::IXmlNode* node, const WCHAR* text);
HRESULT SetXmlText(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, const WCHAR* title, const WCHAR* body); bool SetupCallbacks(IToastNotification* toast);
HRESULT SetXmlImage(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, std::string iconPath);
HRESULT GetTextNodeList(HSTRING* tag, ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, ABI::Windows::Data::Xml::Dom::IXmlNodeList** nodeList, UINT32 reqLength);
HRESULT AppendTextToXml(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, ABI::Windows::Data::Xml::Dom::IXmlNode* node, const WCHAR* text);
HRESULT SetupCallbacks(IToastNotification* toast);
HRESULT CreateHString(const WCHAR* source, HSTRING* dest);
}; };
@ -59,15 +61,14 @@ class ToastEventHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>,
DesktopToastActivatedEventHandler, DesktopToastActivatedEventHandler,
DesktopToastDismissedEventHandler> { DesktopToastDismissedEventHandler> {
public: public:
ToastEventHandler(WindowsToastNotification* notification, content::DesktopNotificationDelegate* delegate); ToastEventHandler(WindowsToastNotification* notification);
~ToastEventHandler(); ~ToastEventHandler();
IFACEMETHODIMP Invoke(IToastNotification* sender, IInspectable* args); IFACEMETHODIMP Invoke(IToastNotification* sender, IInspectable* args);
IFACEMETHODIMP Invoke(IToastNotification* sender, IToastDismissedEventArgs* e); IFACEMETHODIMP Invoke(IToastNotification* sender, IToastDismissedEventArgs* e);
private: private:
WindowsToastNotification* m_notification; WindowsToastNotification* notification_; // weak ref.
content::DesktopNotificationDelegate* n_delegate;
}; };
} // namespace } // namespace

View file

@ -67,6 +67,8 @@
'browser/win/notification_presenter_win.cc', 'browser/win/notification_presenter_win.cc',
'browser/win/windows_toast_notification.h', 'browser/win/windows_toast_notification.h',
'browser/win/windows_toast_notification.cc', 'browser/win/windows_toast_notification.cc',
'browser/win/scoped_hstring.h',
'browser/win/scoped_hstring.cc',
'browser/special_storage_policy.cc', 'browser/special_storage_policy.cc',
'browser/special_storage_policy.h', 'browser/special_storage_policy.h',
'browser/url_request_context_getter.cc', 'browser/url_request_context_getter.cc',