Add a devtools button

This commit is contained in:
Paul Rouget 2020-03-25 13:19:50 +01:00
parent 6ca767d7f9
commit a707432b00
9 changed files with 62 additions and 15 deletions

View file

@ -11,8 +11,6 @@ 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;
@ -560,18 +558,10 @@ std::optional<hstring> ServoControl::OnServoPromptInput(winrt::hstring message,
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);
RunOnUIThread([=] {
auto status = success ? DevtoolsStatus::Running : DevtoolsStatus::Failed;
mOnDevtoolsStatusChangedEvent(status, port);
});
}
template <typename Callable> void ServoControl::RunOnUIThread(Callable cb) {