applets/web: Implement the online web browser applet

This commit is contained in:
Morph 2020-12-08 06:20:45 -05:00
parent 51cddcb8b8
commit 82fa9f8d56
8 changed files with 167 additions and 64 deletions

View file

@ -20,4 +20,13 @@ void DefaultWebBrowserApplet::OpenLocalWebPage(
callback(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost/");
}
void DefaultWebBrowserApplet::OpenExternalWebPage(
std::string_view external_url,
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const {
LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open external web page at {}",
external_url);
callback(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost/");
}
} // namespace Core::Frontend

View file

@ -18,6 +18,10 @@ public:
virtual void OpenLocalWebPage(
std::string_view local_url, std::function<void()> extract_romfs_callback,
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0;
virtual void OpenExternalWebPage(
std::string_view external_url,
std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0;
};
class DefaultWebBrowserApplet final : public WebBrowserApplet {
@ -27,6 +31,10 @@ public:
void OpenLocalWebPage(std::string_view local_url, std::function<void()> extract_romfs_callback,
std::function<void(Service::AM::Applets::WebExitReason, std::string)>
callback) const override;
void OpenExternalWebPage(std::string_view external_url,
std::function<void(Service::AM::Applets::WebExitReason, std::string)>
callback) const override;
};
} // namespace Core::Frontend

View file

@ -409,7 +409,9 @@ void WebBrowser::InitializeOffline() {
void WebBrowser::InitializeShare() {}
void WebBrowser::InitializeWeb() {}
void WebBrowser::InitializeWeb() {
external_url = ParseStringValue(GetInputTLVData(WebArgInputTLVType::InitialURL).value());
}
void WebBrowser::InitializeWifi() {}
@ -456,8 +458,12 @@ void WebBrowser::ExecuteShare() {
}
void WebBrowser::ExecuteWeb() {
LOG_WARNING(Service_AM, "(STUBBED) called, Web Applet is not implemented");
WebBrowserExit(WebExitReason::EndButtonPressed);
LOG_INFO(Service_AM, "Opening external URL at {}", external_url);
frontend.OpenExternalWebPage(external_url,
[this](WebExitReason exit_reason, std::string last_url) {
WebBrowserExit(exit_reason, last_url);
});
}
void WebBrowser::ExecuteWifi() {

View file

@ -79,6 +79,8 @@ private:
std::string offline_document;
FileSys::VirtualFile offline_romfs;
std::string external_url;
Core::System& system;
};