Handle servo:// url

This commit is contained in:
Paul Rouget 2019-08-20 07:28:00 +02:00
parent 5f89dc87bd
commit 5c1d130217
10 changed files with 91 additions and 40 deletions

View file

@ -7,6 +7,7 @@
#include "BrowserPage.h"
#include "BrowserPage.g.cpp"
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::UI::ViewManagement;
@ -36,10 +37,20 @@ void BrowserPage::BindServoEvents() {
});
}
void BrowserPage::Shutdown() {
servoControl().Shutdown();
void BrowserPage::LoadServoURI(Uri uri) {
auto scheme = uri.SchemeName();
if (scheme != SERVO_SCHEME) {
log("Unexpected URL: ", uri.RawUri().c_str());
return;
}
std::wstring raw{uri.RawUri()};
auto raw2 = raw.substr(SERVO_SCHEME_SLASH_SLASH.size());
servoControl().LoadURIOrSearch(raw2);
}
void BrowserPage::Shutdown() { servoControl().Shutdown(); }
/**** USER INTERACTIONS WITH UI ****/
void BrowserPage::OnBackButtonClicked(IInspectable const &,
@ -62,7 +73,7 @@ void BrowserPage::OnStopButtonClicked(IInspectable const &,
servoControl().Stop();
}
void BrowserPage::OnURLEdited(IInspectable const &sender,
void BrowserPage::OnURLEdited(IInspectable const &,
Input::KeyRoutedEventArgs const &e) {
if (e.Key() == Windows::System::VirtualKey::Enter) {
servoControl().Focus(FocusState::Programmatic);