parent
3b183854ff
commit
2d3c65beca
31 changed files with 200 additions and 152 deletions
|
@ -72,7 +72,7 @@ bool NotificationPresenterWin::Init() {
|
|||
return temp_dir_.CreateUniqueTempDir();
|
||||
}
|
||||
|
||||
std::u16string NotificationPresenterWin::SaveIconToFilesystem(
|
||||
std::wstring NotificationPresenterWin::SaveIconToFilesystem(
|
||||
const SkBitmap& icon,
|
||||
const GURL& origin) {
|
||||
std::string filename;
|
||||
|
@ -85,12 +85,12 @@ std::u16string NotificationPresenterWin::SaveIconToFilesystem(
|
|||
}
|
||||
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
base::FilePath path = temp_dir_.GetPath().Append(base::UTF8ToUTF16(filename));
|
||||
base::FilePath path = temp_dir_.GetPath().Append(base::UTF8ToWide(filename));
|
||||
if (base::PathExists(path))
|
||||
return path.value();
|
||||
if (SaveIconToPath(icon, path))
|
||||
return path.value();
|
||||
return base::UTF8ToUTF16(origin.spec());
|
||||
return base::UTF8ToWide(origin.spec());
|
||||
}
|
||||
|
||||
Notification* NotificationPresenterWin::CreateNotificationObject(
|
||||
|
|
|
@ -38,7 +38,7 @@ class NotificationPresenterWin : public NotificationPresenter {
|
|||
|
||||
bool Init();
|
||||
|
||||
std::u16string SaveIconToFilesystem(const SkBitmap& icon, const GURL& origin);
|
||||
std::wstring SaveIconToFilesystem(const SkBitmap& icon, const GURL& origin);
|
||||
|
||||
private:
|
||||
Notification* CreateNotificationObject(
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
namespace electron {
|
||||
|
@ -49,13 +50,15 @@ void Win32Notification::Show(const NotificationOptions& options) {
|
|||
existing->tag_.clear();
|
||||
|
||||
this->notification_ref_ = std::move(existing->notification_ref_);
|
||||
this->notification_ref_.Set(options.title, options.msg, image);
|
||||
this->notification_ref_.Set(base::UTF16ToWide(options.title),
|
||||
base::UTF16ToWide(options.msg), image);
|
||||
// Need to remove the entry in the notifications set that
|
||||
// NotificationPresenter is holding
|
||||
existing->Destroy();
|
||||
} else {
|
||||
this->notification_ref_ =
|
||||
presenter->AddNotification(options.title, options.msg, image);
|
||||
presenter->AddNotification(base::UTF16ToWide(options.title),
|
||||
base::UTF16ToWide(options.msg), image);
|
||||
}
|
||||
|
||||
this->tag_ = options.tag;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "shell/browser/notifications/win/notification_presenter_win.h"
|
||||
#include "shell/browser/win/scoped_hstring.h"
|
||||
#include "shell/common/application_info.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/l10n/l10n_util_win.h"
|
||||
#include "ui/strings/grit/ui_strings.h"
|
||||
|
||||
using ABI::Windows::Data::Xml::Dom::IXmlAttribute;
|
||||
|
@ -132,15 +132,18 @@ HRESULT WindowsToastNotification::ShowInternal(
|
|||
// The custom xml takes priority over the preset template.
|
||||
if (!options.toast_xml.empty()) {
|
||||
REPORT_AND_RETURN_IF_FAILED(
|
||||
XmlDocumentFromString(options.toast_xml.c_str(), &toast_xml),
|
||||
XmlDocumentFromString(base::UTF16ToWide(options.toast_xml).c_str(),
|
||||
&toast_xml),
|
||||
"XML: Invalid XML");
|
||||
} else {
|
||||
auto* presenter_win = static_cast<NotificationPresenterWin*>(presenter());
|
||||
std::wstring icon_path =
|
||||
presenter_win->SaveIconToFilesystem(options.icon, options.icon_url);
|
||||
REPORT_AND_RETURN_IF_FAILED(
|
||||
GetToastXml(toast_manager_.Get(), options.title, options.msg, icon_path,
|
||||
options.timeout_type, options.silent, &toast_xml),
|
||||
GetToastXml(toast_manager_.Get(), base::UTF16ToWide(options.title),
|
||||
base::UTF16ToWide(options.msg), icon_path,
|
||||
base::UTF16ToWide(options.timeout_type), options.silent,
|
||||
&toast_xml),
|
||||
"XML: Failed to create XML document");
|
||||
}
|
||||
|
||||
|
@ -211,7 +214,7 @@ HRESULT WindowsToastNotification::GetToastXml(
|
|||
}
|
||||
|
||||
// Configure the toast's timeout settings
|
||||
if (timeout_type == base::ASCIIToUTF16("never")) {
|
||||
if (timeout_type == base::ASCIIToWide("never")) {
|
||||
REPORT_AND_RETURN_IF_FAILED(
|
||||
(SetXmlScenarioReminder(*toast_xml)),
|
||||
"XML: Setting \"scenario\" option on notification failed");
|
||||
|
@ -379,7 +382,7 @@ HRESULT WindowsToastNotification::SetXmlScenarioReminder(IXmlDocument* doc) {
|
|||
RETURN_IF_FAILED(content_attribute.As(&content_attribute_node));
|
||||
|
||||
// Set content attribute to Dismiss
|
||||
ScopedHString content_value(l10n_util::GetStringUTF16(IDS_APP_CLOSE));
|
||||
ScopedHString content_value(l10n_util::GetWideString(IDS_APP_CLOSE));
|
||||
if (!content_value.success())
|
||||
return E_FAIL;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue