diff --git a/brightray/browser/win/notification_presenter_win.cc b/brightray/browser/win/notification_presenter_win.cc index 6fc4001a3396..8d4fe8bace04 100644 --- a/brightray/browser/win/notification_presenter_win.cc +++ b/brightray/browser/win/notification_presenter_win.cc @@ -42,8 +42,7 @@ void NotificationPresenterWin::ShowNotification( scoped_ptr delegate, base::Closure* cancel_callback) { // This class manages itself. - auto notification = new WindowsToastNotification( - GetApplicationName(), delegate.Pass()); + auto notification = new WindowsToastNotification(delegate.Pass()); notification->ShowNotification(data.title, data.body, data.icon.spec()); if (cancel_callback) { diff --git a/brightray/browser/win/windows_toast_notification.cc b/brightray/browser/win/windows_toast_notification.cc index ec2d85f31c07..60a20dc329f5 100644 --- a/brightray/browser/win/windows_toast_notification.cc +++ b/brightray/browser/win/windows_toast_notification.cc @@ -5,6 +5,8 @@ #include "browser/win/windows_toast_notification.h" +#include + #include "base/strings/utf_string_conversions.h" #include "browser/win/scoped_hstring.h" #include "content/public/browser/desktop_notification_delegate.h" @@ -13,8 +15,21 @@ using namespace ABI::Windows::Data::Xml::Dom; namespace brightray { +namespace { + +bool GetAppUserModelId(ScopedHString* app_id) { + PWSTR current_app_id; + if (FAILED(GetCurrentProcessExplicitAppUserModelID(¤t_app_id))) + return false; + + app_id->Set(current_app_id); + CoTaskMemFree(current_app_id); + return app_id->success(); +} + +} // namespace + WindowsToastNotification::WindowsToastNotification( - const std::string& app_name, scoped_ptr delegate) : delegate_(delegate.Pass()), weak_factory_(this) { @@ -30,8 +45,8 @@ WindowsToastNotification::WindowsToastNotification( if (FAILED(hr)) return; - ScopedHString app_id(base::UTF8ToUTF16(app_name).c_str()); - if (!app_id.success()) + ScopedHString app_id; + if (!GetAppUserModelId(&app_id)) return; toast_manager_->CreateToastNotifierWithId(app_id, &toast_notifier_); diff --git a/brightray/browser/win/windows_toast_notification.h b/brightray/browser/win/windows_toast_notification.h index 91f0537a7a9a..87dffae438b2 100644 --- a/brightray/browser/win/windows_toast_notification.h +++ b/brightray/browser/win/windows_toast_notification.h @@ -34,7 +34,6 @@ using DesktopToastFailedEventHandler = class WindowsToastNotification { public: WindowsToastNotification( - const std::string& app_name, scoped_ptr delegate); ~WindowsToastNotification();