diff --git a/brightray/browser/win/notification_presenter_win.cc b/brightray/browser/win/notification_presenter_win.cc index 63feb44224ef..447125f39117 100644 --- a/brightray/browser/win/notification_presenter_win.cc +++ b/brightray/browser/win/notification_presenter_win.cc @@ -7,7 +7,6 @@ #include "base/win/windows_version.h" #include "browser/win/windows_toast_notification.h" -#include "common/application_info.h" #include "content/public/browser/desktop_notification_delegate.h" #include "content/public/common/platform_notification_data.h" #include "third_party/skia/include/core/SkBitmap.h" diff --git a/brightray/browser/win/scoped_hstring.cc b/brightray/browser/win/scoped_hstring.cc index e3f5cbd29bbb..082ebe762270 100644 --- a/brightray/browser/win/scoped_hstring.cc +++ b/brightray/browser/win/scoped_hstring.cc @@ -8,26 +8,34 @@ ScopedHString::ScopedHString(const wchar_t* source) : str_(nullptr) { - Set(source); + Reset(source); } ScopedHString::ScopedHString(const std::wstring& source) : str_(nullptr) { - WindowsCreateString(source.c_str(), source.length(), &str_); + Reset(source); } ScopedHString::ScopedHString() : str_(nullptr) { } ScopedHString::~ScopedHString() { - if (str_) - WindowsDeleteString(str_); + Reset(); } -void ScopedHString::Set(const wchar_t* source) { +void ScopedHString::Reset() { if (str_) { WindowsDeleteString(str_); str_ = nullptr; } +} + +void ScopedHString::Reset(const wchar_t* source) { + Reset(); WindowsCreateString(source, wcslen(source), &str_); } + +void ScopedHString::Reset(const std::wstring& source) { + Reset(); + WindowsCreateString(source.c_str(), source.length(), &str_); +} diff --git a/brightray/browser/win/scoped_hstring.h b/brightray/browser/win/scoped_hstring.h index de03c0469b3a..5494df2fc5ce 100644 --- a/brightray/browser/win/scoped_hstring.h +++ b/brightray/browser/win/scoped_hstring.h @@ -22,7 +22,9 @@ class ScopedHString { ~ScopedHString(); // Sets to |source|. - void Set(const wchar_t* source); + void Reset(); + void Reset(const wchar_t* source); + void Reset(const std::wstring& source); // Returns string. operator HSTRING() const { return str_; } diff --git a/brightray/browser/win/windows_toast_notification.cc b/brightray/browser/win/windows_toast_notification.cc index 64806430a7eb..58b4756fed91 100644 --- a/brightray/browser/win/windows_toast_notification.cc +++ b/brightray/browser/win/windows_toast_notification.cc @@ -9,6 +9,7 @@ #include "base/strings/utf_string_conversions.h" #include "browser/win/scoped_hstring.h" +#include "common/application_info.h" #include "content/public/browser/desktop_notification_delegate.h" using namespace ABI::Windows::Data::Xml::Dom; @@ -19,11 +20,12 @@ 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); + if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(¤t_app_id))) { + app_id->Reset(current_app_id); + CoTaskMemFree(current_app_id); + } else { + app_id->Reset(base::UTF8ToUTF16(GetApplicationName())); + } return app_id->success(); } @@ -229,7 +231,7 @@ bool WindowsToastNotification::GetTextNodeList( IXmlDocument* doc, IXmlNodeList** node_list, UINT32 req_length) { - tag->Set(L"text"); + tag->Reset(L"text"); if (!tag->success()) return false;