UWP port: re-enable devtools

This commit is contained in:
Paul Rouget 2020-03-16 12:06:09 +01:00
parent 58ff35f5bf
commit 00395125f6
6 changed files with 34 additions and 7 deletions

View file

@ -11,6 +11,8 @@ using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::System;
using namespace winrt::Windows::Devices::Input;
using namespace winrt::Windows::UI::Notifications;
using namespace winrt::Windows::Data::Xml::Dom;
using namespace concurrency;
using namespace winrt::servo;
@ -556,6 +558,22 @@ std::optional<hstring> ServoControl::OnServoPromptInput(winrt::hstring message,
return string;
}
void ServoControl::OnServoDevtoolsStarted(bool success,
const unsigned int port) {
auto toastTemplate = ToastTemplateType::ToastText01;
auto toastXml = ToastNotificationManager::GetTemplateContent(toastTemplate);
auto toastTextElements = toastXml.GetElementsByTagName(L"text");
std::wstring message;
if (success) {
message = L"DevTools server has started on port " + std::to_wstring(port);
} else {
message = L"Error: could not start DevTools";
}
toastTextElements.Item(0).InnerText(message);
auto toast = ToastNotification(toastXml);
ToastNotificationManager::CreateToastNotifier().Show(toast);
}
template <typename Callable> void ServoControl::RunOnUIThread(Callable cb) {
Dispatcher().RunAsync(CoreDispatcherPriority::High, cb);
}