|
@@ -11,6 +11,7 @@
|
|
|
#include <shlobj.h>
|
|
|
#include <vector>
|
|
|
|
|
|
+#include "base/environment.h"
|
|
|
#include "base/strings/utf_string_conversions.h"
|
|
|
#include "brightray/browser/notification_delegate.h"
|
|
|
#include "brightray/browser/win/notification_presenter_win.h"
|
|
@@ -41,6 +42,10 @@ bool GetAppUserModelId(ScopedHString* app_id) {
|
|
|
return app_id->success();
|
|
|
}
|
|
|
|
|
|
+bool IsDebuggingNotifications() {
|
|
|
+ return base::Environment::Create()->HasVar("ELECTRON_DEBUG_NOTIFICATIONS");
|
|
|
+}
|
|
|
+
|
|
|
} // namespace
|
|
|
|
|
|
// static
|
|
@@ -129,11 +134,14 @@ void WindowsToastNotification::Show(const NotificationOptions& options) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ if (IsDebuggingNotifications()) LOG(INFO) << "Notification created";
|
|
|
+
|
|
|
if (delegate())
|
|
|
delegate()->NotificationDisplayed();
|
|
|
}
|
|
|
|
|
|
void WindowsToastNotification::Dismiss() {
|
|
|
+ if (IsDebuggingNotifications()) LOG(INFO) << "Hiding notification";
|
|
|
toast_notifier_->Hide(toast_notification_.Get());
|
|
|
}
|
|
|
|
|
@@ -164,16 +172,28 @@ bool WindowsToastNotification::GetToastXml(
|
|
|
? ABI::Windows::UI::Notifications::ToastTemplateType_ToastText02
|
|
|
: ABI::Windows::UI::Notifications::
|
|
|
ToastTemplateType_ToastImageAndText02;
|
|
|
- if (FAILED(toastManager->GetTemplateContent(template_type, toast_xml)))
|
|
|
+ if (FAILED(toastManager->GetTemplateContent(template_type, toast_xml))) {
|
|
|
+ if (IsDebuggingNotifications())
|
|
|
+ LOG(INFO) << "Fetching XML template failed";
|
|
|
return false;
|
|
|
- if (!SetXmlText(*toast_xml, title, msg))
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!SetXmlText(*toast_xml, title, msg)) {
|
|
|
+ if (IsDebuggingNotifications())
|
|
|
+ LOG(INFO) << "Setting text fields on template failed";
|
|
|
return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Configure the toast's notification sound
|
|
|
if (silent) {
|
|
|
- if (FAILED(SetXmlAudioSilent(*toast_xml)))
|
|
|
+ if (FAILED(SetXmlAudioSilent(*toast_xml))) {
|
|
|
+ if (IsDebuggingNotifications()) {
|
|
|
+ LOG(INFO) << "Setting \"silent\" option on notification failed";
|
|
|
+ }
|
|
|
+
|
|
|
return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Configure the toast's image
|
|
@@ -398,6 +418,8 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
|
|
|
content::BrowserThread::PostTask(
|
|
|
content::BrowserThread::UI, FROM_HERE,
|
|
|
base::Bind(&Notification::NotificationClicked, notification_));
|
|
|
+ if (IsDebuggingNotifications()) LOG(INFO) << "Notification clicked";
|
|
|
+
|
|
|
return S_OK;
|
|
|
}
|
|
|
|
|
@@ -407,6 +429,8 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
|
|
|
content::BrowserThread::PostTask(
|
|
|
content::BrowserThread::UI, FROM_HERE,
|
|
|
base::Bind(&Notification::NotificationDismissed, notification_));
|
|
|
+ if (IsDebuggingNotifications()) LOG(INFO) << "Notification dismissed";
|
|
|
+
|
|
|
return S_OK;
|
|
|
}
|
|
|
|
|
@@ -416,6 +440,8 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
|
|
|
content::BrowserThread::PostTask(
|
|
|
content::BrowserThread::UI, FROM_HERE,
|
|
|
base::Bind(&Notification::NotificationFailed, notification_));
|
|
|
+ if (IsDebuggingNotifications()) LOG(INFO) << "Notification failed";
|
|
|
+
|
|
|
return S_OK;
|
|
|
}
|
|
|
|