Auto merge of #27287 - paulrouget:fxrmin, r=jdm

Make it possible to run fxr:// url in non-kiosk mode

Fix #27274
This commit is contained in:
bors-servo 2020-07-16 09:26:15 -04:00 committed by GitHub
commit 9daadd03cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 16 deletions

View file

@ -95,10 +95,7 @@ void App::OnActivated(IActivatedEventArgs const &args) {
rootFrame = content.try_as<Frame>(); rootFrame = content.try_as<Frame>();
} }
auto page = rootFrame.Content().try_as<BrowserPage>(); auto page = rootFrame.Content().try_as<BrowserPage>();
page->LoadServoURI(protocolActivatedEventArgs.Uri()); page->LoadFXRURI(protocolActivatedEventArgs.Uri());
// If Servo was opened as a result of clicking on a fxr:// URL,
// we activate transient mode.
page->SetTransientMode(!isRunning);
} }
} }

View file

@ -99,16 +99,20 @@ void BrowserPage::OnURLKeyboardAccelerator(
urlTextbox().Focus(FocusState::Programmatic); urlTextbox().Focus(FocusState::Programmatic);
} }
void BrowserPage::LoadServoURI(Uri uri) { void BrowserPage::LoadFXRURI(Uri uri) {
auto scheme = uri.SchemeName(); auto scheme = uri.SchemeName();
if (scheme != SERVO_SCHEME) {
log(L"Unexpected URL: ", uri.RawUri().c_str());
return;
}
std::wstring raw{uri.RawUri()}; std::wstring raw{uri.RawUri()};
auto raw2 = raw.substr(SERVO_SCHEME_SLASH_SLASH.size()); if (scheme == FXR_SCHEME) {
servoControl().LoadURIOrSearch(raw2); auto raw2 = raw.substr(FXR_SCHEME_SLASH_SLASH.size());
servoControl().LoadURIOrSearch(raw2);
SetTransientMode(false);
} else if (scheme == FXRMIN_SCHEME) {
auto raw2 = raw.substr(FXRMIN_SCHEME_SLASH_SLASH.size());
servoControl().LoadURIOrSearch(raw2);
SetTransientMode(true);
} else {
log(L"Unexpected URL: ", uri.RawUri().c_str());
}
} }
void BrowserPage::SetTransientMode(bool transient) { void BrowserPage::SetTransientMode(bool transient) {

View file

@ -17,8 +17,10 @@ using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::UI::Xaml; using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Xaml::Media; using namespace winrt::Windows::UI::Xaml::Media;
static const hstring SERVO_SCHEME = L"fxr"; static const hstring FXR_SCHEME = L"fxr";
static const hstring SERVO_SCHEME_SLASH_SLASH = L"fxr://"; static const hstring FXR_SCHEME_SLASH_SLASH = L"fxr://";
static const hstring FXRMIN_SCHEME = L"fxrmin";
static const hstring FXRMIN_SCHEME_SLASH_SLASH = L"fxrmin://";
struct BrowserPage : BrowserPageT<BrowserPage>, public servo::DevtoolsDelegate { struct BrowserPage : BrowserPageT<BrowserPage>, public servo::DevtoolsDelegate {
public: public:
@ -37,8 +39,7 @@ public:
OnURLKeyboardAccelerator(IInspectable const &, OnURLKeyboardAccelerator(IInspectable const &,
Input::KeyboardAcceleratorInvokedEventArgs const &); Input::KeyboardAcceleratorInvokedEventArgs const &);
void Shutdown(); void Shutdown();
void LoadServoURI(Uri uri); void LoadFXRURI(Uri uri);
void SetTransientMode(bool);
void SetArgs(hstring); void SetArgs(hstring);
void OnMediaControlsPlayClicked(IInspectable const &, void OnMediaControlsPlayClicked(IInspectable const &,
RoutedEventArgs const &); RoutedEventArgs const &);
@ -52,6 +53,7 @@ public:
Collections::IObservableVector<IInspectable> ConsoleLogs() { return mLogs; }; Collections::IObservableVector<IInspectable> ConsoleLogs() { return mLogs; };
private: private:
void SetTransientMode(bool);
void UpdatePref(ServoApp::Pref, Controls::Control); void UpdatePref(ServoApp::Pref, Controls::Control);
void BindServoEvents(); void BindServoEvents();
void BuildPrefList(); void BuildPrefList();

View file

@ -38,6 +38,12 @@
<uap:DisplayName>Firefox Reality URL</uap:DisplayName> <uap:DisplayName>Firefox Reality URL</uap:DisplayName>
</uap:Protocol> </uap:Protocol>
</uap:Extension> </uap:Extension>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="fxrmin">
<uap:Logo>Assets\StoreLogo.png</uap:Logo>
<uap:DisplayName>Firefox Reality URL (Kiosk mode)</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
</Extensions> </Extensions>
</Application> </Application>
</Applications> </Applications>