Use application name when app user model ID is not available
This commit is contained in:
parent
c060539562
commit
087eeedab8
4 changed files with 24 additions and 13 deletions
|
@ -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"
|
||||
|
|
|
@ -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_);
|
||||
}
|
||||
|
|
|
@ -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_; }
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue