Delay Load WinRT Libraries
This commit is contained in:
parent
da0197543a
commit
2c84d70f8f
4 changed files with 26 additions and 37 deletions
|
@ -161,17 +161,6 @@
|
||||||
]
|
]
|
||||||
}], # OS=="mac"
|
}], # OS=="mac"
|
||||||
['OS=="win"', {
|
['OS=="win"', {
|
||||||
'msvs_settings': {
|
|
||||||
'VCLinkerTool': {
|
|
||||||
'AdditionalDependencies': [
|
|
||||||
# Windows Runtime.
|
|
||||||
'crypt32.lib',
|
|
||||||
'runtimeobject.lib',
|
|
||||||
'shlwapi.lib',
|
|
||||||
'windowsapp.lib',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['libchromiumcontent_component', {
|
['libchromiumcontent_component', {
|
||||||
# sandbox, base_static, devtools_discovery, devtools_http_handler,
|
# sandbox, base_static, devtools_discovery, devtools_http_handler,
|
||||||
|
@ -231,6 +220,9 @@
|
||||||
'BluetoothApis.dll',
|
'BluetoothApis.dll',
|
||||||
'Bthprops.cpl',
|
'Bthprops.cpl',
|
||||||
'setupapi.dll',
|
'setupapi.dll',
|
||||||
|
# windows runtime
|
||||||
|
'API-MS-WIN-CORE-WINRT-L1-1-0.DLL',
|
||||||
|
'API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,11 +14,6 @@
|
||||||
|
|
||||||
#pragma comment(lib, "runtimeobject.lib")
|
#pragma comment(lib, "runtimeobject.lib")
|
||||||
|
|
||||||
using namespace Microsoft::WRL;
|
|
||||||
using namespace ABI::Windows::UI::Notifications;
|
|
||||||
using namespace ABI::Windows::Data::Xml::Dom;
|
|
||||||
using namespace ABI::Windows::Foundation;
|
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace brightray {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Initialize Windows Runtime
|
// Initialize Windows Runtime
|
||||||
|
|
||||||
HRESULT init = Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
|
HRESULT init = Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -57,7 +58,7 @@ void WindowsToastNotification::ShowNotification(
|
||||||
if (!toast_str.success())
|
if (!toast_str.success())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ComPtr<IToastNotificationFactory> toast_factory;
|
ComPtr<ABI::Windows::UI::Notifications::IToastNotificationFactory> toast_factory;
|
||||||
if (FAILED(Windows::Foundation::GetActivationFactory(toast_str,
|
if (FAILED(Windows::Foundation::GetActivationFactory(toast_str,
|
||||||
&toast_factory)))
|
&toast_factory)))
|
||||||
return;
|
return;
|
||||||
|
@ -90,24 +91,24 @@ void WindowsToastNotification::NotificationDismissed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowsToastNotification::GetToastXml(
|
bool WindowsToastNotification::GetToastXml(
|
||||||
IToastNotificationManagerStatics* toastManager,
|
ABI::Windows::UI::Notifications::IToastNotificationManagerStatics* toastManager,
|
||||||
const std::wstring& title,
|
const std::wstring& title,
|
||||||
const std::wstring& msg,
|
const std::wstring& msg,
|
||||||
std::string icon_path,
|
std::string icon_path,
|
||||||
IXmlDocument** toast_xml) {
|
IXmlDocument** toast_xml) {
|
||||||
ToastTemplateType template_type;
|
ABI::Windows::UI::Notifications::ToastTemplateType template_type;
|
||||||
if (title.empty() || msg.empty()) {
|
if (title.empty() || msg.empty()) {
|
||||||
// Single line toast.
|
// Single line toast.
|
||||||
template_type = icon_path.empty() ? ToastTemplateType_ToastText01 :
|
template_type = icon_path.empty() ? ABI::Windows::UI::Notifications::ToastTemplateType_ToastText01 :
|
||||||
ToastTemplateType_ToastImageAndText01;
|
ABI::Windows::UI::Notifications::ToastTemplateType_ToastImageAndText01;
|
||||||
if (FAILED(toast_manager_->GetTemplateContent(template_type, toast_xml)))
|
if (FAILED(toast_manager_->GetTemplateContent(template_type, toast_xml)))
|
||||||
return false;
|
return false;
|
||||||
if (!SetXmlText(*toast_xml, title.empty() ? msg : title))
|
if (!SetXmlText(*toast_xml, title.empty() ? msg : title))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// Title and body toast.
|
// Title and body toast.
|
||||||
template_type = icon_path.empty() ? ToastTemplateType_ToastText02 :
|
template_type = icon_path.empty() ? ABI::Windows::UI::Notifications::ToastTemplateType_ToastText02 :
|
||||||
ToastTemplateType_ToastImageAndText02;
|
ABI::Windows::UI::Notifications::ToastTemplateType_ToastImageAndText02;
|
||||||
if (FAILED(toastManager->GetTemplateContent(template_type, toast_xml)))
|
if (FAILED(toastManager->GetTemplateContent(template_type, toast_xml)))
|
||||||
return false;
|
return false;
|
||||||
if (!SetXmlText(*toast_xml, title, msg))
|
if (!SetXmlText(*toast_xml, title, msg))
|
||||||
|
@ -234,7 +235,7 @@ bool WindowsToastNotification::AppendTextToXml(
|
||||||
return SUCCEEDED(node->AppendChild(text_node.Get(), &append_node));
|
return SUCCEEDED(node->AppendChild(text_node.Get(), &append_node));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowsToastNotification::SetupCallbacks(IToastNotification* toast) {
|
bool WindowsToastNotification::SetupCallbacks(ABI::Windows::UI::Notifications::IToastNotification* toast) {
|
||||||
EventRegistrationToken activatedToken, dismissedToken;
|
EventRegistrationToken activatedToken, dismissedToken;
|
||||||
event_handler_ = Make<ToastEventHandler>(this);
|
event_handler_ = Make<ToastEventHandler>(this);
|
||||||
if (FAILED(toast->add_Activated(event_handler_.Get(), &activatedToken)))
|
if (FAILED(toast->add_Activated(event_handler_.Get(), &activatedToken)))
|
||||||
|
@ -254,13 +255,14 @@ ToastEventHandler::~ToastEventHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
IFACEMETHODIMP ToastEventHandler::Invoke(
|
IFACEMETHODIMP ToastEventHandler::Invoke(
|
||||||
IToastNotification* sender, IInspectable* args) {
|
ABI::Windows::UI::Notifications::IToastNotification* sender, IInspectable* args) {
|
||||||
notification_->NotificationClicked();
|
notification_->NotificationClicked();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFACEMETHODIMP ToastEventHandler::Invoke(
|
IFACEMETHODIMP ToastEventHandler::Invoke(
|
||||||
IToastNotification* sender, IToastDismissedEventArgs* e) {
|
ABI::Windows::UI::Notifications::IToastNotification* sender,
|
||||||
|
ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e) {
|
||||||
notification_->NotificationDismissed();
|
notification_->NotificationDismissed();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,17 +16,17 @@
|
||||||
#include "content/public/common/platform_notification_data.h"
|
#include "content/public/common/platform_notification_data.h"
|
||||||
|
|
||||||
using namespace Microsoft::WRL;
|
using namespace Microsoft::WRL;
|
||||||
using namespace ABI::Windows::UI::Notifications;
|
|
||||||
using namespace ABI::Windows::Foundation;
|
|
||||||
|
|
||||||
class ScopedHString;
|
class ScopedHString;
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
using DesktopToastActivatedEventHandler =
|
using DesktopToastActivatedEventHandler =
|
||||||
ITypedEventHandler<ToastNotification*, IInspectable*>;
|
ABI::Windows::Foundation::ITypedEventHandler<ABI::Windows::UI::Notifications::ToastNotification*,
|
||||||
|
IInspectable*>;
|
||||||
using DesktopToastDismissedEventHandler =
|
using DesktopToastDismissedEventHandler =
|
||||||
ITypedEventHandler<ToastNotification*, ToastDismissedEventArgs*>;
|
ABI::Windows::Foundation::ITypedEventHandler<ABI::Windows::UI::Notifications::ToastNotification*,
|
||||||
|
ABI::Windows::UI::Notifications::ToastDismissedEventArgs*>;
|
||||||
|
|
||||||
class WindowsToastNotification {
|
class WindowsToastNotification {
|
||||||
public:
|
public:
|
||||||
|
@ -50,7 +50,7 @@ class WindowsToastNotification {
|
||||||
void NotificationClicked();
|
void NotificationClicked();
|
||||||
void NotificationDismissed();
|
void NotificationDismissed();
|
||||||
|
|
||||||
bool GetToastXml(IToastNotificationManagerStatics* toastManager,
|
bool GetToastXml(ABI::Windows::UI::Notifications::IToastNotificationManagerStatics* toastManager,
|
||||||
const std::wstring& title,
|
const std::wstring& title,
|
||||||
const std::wstring& msg,
|
const std::wstring& msg,
|
||||||
std::string icon_path,
|
std::string icon_path,
|
||||||
|
@ -69,13 +69,13 @@ class WindowsToastNotification {
|
||||||
bool AppendTextToXml(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc,
|
bool AppendTextToXml(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc,
|
||||||
ABI::Windows::Data::Xml::Dom::IXmlNode* node,
|
ABI::Windows::Data::Xml::Dom::IXmlNode* node,
|
||||||
const std::wstring& text);
|
const std::wstring& text);
|
||||||
bool SetupCallbacks(IToastNotification* toast);
|
bool SetupCallbacks(ABI::Windows::UI::Notifications::IToastNotification* toast);
|
||||||
|
|
||||||
scoped_ptr<content::DesktopNotificationDelegate> delegate_;
|
scoped_ptr<content::DesktopNotificationDelegate> delegate_;
|
||||||
ComPtr<ToastEventHandler> event_handler_;
|
ComPtr<ToastEventHandler> event_handler_;
|
||||||
ComPtr<IToastNotificationManagerStatics> toast_manager_;
|
ComPtr<ABI::Windows::UI::Notifications::IToastNotificationManagerStatics> toast_manager_;
|
||||||
ComPtr<IToastNotifier> toast_notifier_;
|
ComPtr<ABI::Windows::UI::Notifications::IToastNotifier> toast_notifier_;
|
||||||
ComPtr<IToastNotification> toast_notification_;
|
ComPtr<ABI::Windows::UI::Notifications::IToastNotification> toast_notification_;
|
||||||
|
|
||||||
base::WeakPtrFactory<WindowsToastNotification> weak_factory_;
|
base::WeakPtrFactory<WindowsToastNotification> weak_factory_;
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ class ToastEventHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>,
|
||||||
ToastEventHandler(WindowsToastNotification* notification);
|
ToastEventHandler(WindowsToastNotification* notification);
|
||||||
~ToastEventHandler();
|
~ToastEventHandler();
|
||||||
|
|
||||||
IFACEMETHODIMP Invoke(IToastNotification* sender, IInspectable* args);
|
IFACEMETHODIMP Invoke(ABI::Windows::UI::Notifications::IToastNotification* sender, IInspectable* args);
|
||||||
IFACEMETHODIMP Invoke(IToastNotification* sender, IToastDismissedEventArgs* e);
|
IFACEMETHODIMP Invoke(ABI::Windows::UI::Notifications::IToastNotification* sender, ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowsToastNotification* notification_; // weak ref.
|
WindowsToastNotification* notification_; // weak ref.
|
||||||
|
|
Loading…
Reference in a new issue