summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/am')
-rw-r--r--src/core/hle/service/am/applets/web_browser.cpp66
-rw-r--r--src/core/hle/service/am/applets/web_browser.h10
2 files changed, 44 insertions, 32 deletions
diff --git a/src/core/hle/service/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp
index 02ce9f387..9c8be156f 100644
--- a/src/core/hle/service/am/applets/web_browser.cpp
+++ b/src/core/hle/service/am/applets/web_browser.cpp
@@ -15,7 +15,6 @@
#include "core/file_sys/registered_cache.h"
#include "core/file_sys/romfs.h"
#include "core/file_sys/system_archive/system_archive.h"
-#include "core/file_sys/vfs_types.h"
#include "core/file_sys/vfs_vector.h"
#include "core/frontend/applets/web_browser.h"
#include "core/hle/kernel/process.h"
@@ -311,6 +310,18 @@ void WebBrowser::Execute() {
}
}
+void WebBrowser::ExtractOfflineRomFS() {
+ LOG_DEBUG(Service_AM, "Extracting RomFS to {}", offline_cache_dir);
+
+ const auto extracted_romfs_dir =
+ FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard);
+
+ const auto temp_dir =
+ system.GetFilesystem()->CreateDirectory(offline_cache_dir, FileSys::Mode::ReadWrite);
+
+ FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir);
+}
+
void WebBrowser::WebBrowserExit(WebExitReason exit_reason, std::string last_url) {
if ((web_arg_header.shim_kind == ShimKind::Share &&
web_applet_version >= WebAppletVersion::Version196608) ||
@@ -360,12 +371,11 @@ void WebBrowser::InitializeOffline() {
const auto document_kind =
ParseRawValue<DocumentKind>(GetInputTLVData(WebArgInputTLVType::DocumentKind).value());
- u64 title_id{};
- FileSys::ContentRecordType nca_type{FileSys::ContentRecordType::HtmlDocument};
std::string additional_paths;
switch (document_kind) {
case DocumentKind::OfflineHtmlPage:
+ default:
title_id = system.CurrentProcess()->GetTitleID();
nca_type = FileSys::ContentRecordType::HtmlDocument;
additional_paths = "html-document";
@@ -395,31 +405,6 @@ void WebBrowser::InitializeOffline() {
offline_document = Common::FS::SanitizePath(
fmt::format("{}/{}/{}", offline_cache_dir, additional_paths, document_path),
Common::FS::DirectorySeparator::PlatformDefault);
-
- const auto main_url = Common::FS::SanitizePath(GetMainURL(offline_document),
- Common::FS::DirectorySeparator::PlatformDefault);
-
- if (Common::FS::Exists(main_url)) {
- return;
- }
-
- auto offline_romfs = GetOfflineRomFS(system, title_id, nca_type);
-
- if (offline_romfs == nullptr) {
- LOG_ERROR(Service_AM, "RomFS with title_id={:016X} and nca_type={} cannot be extracted!",
- title_id, nca_type);
- return;
- }
-
- LOG_DEBUG(Service_AM, "Extracting RomFS to {}", offline_cache_dir);
-
- const auto extracted_romfs_dir =
- FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard);
-
- const auto temp_dir =
- system.GetFilesystem()->CreateDirectory(offline_cache_dir, FileSys::Mode::ReadWrite);
-
- FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir);
}
void WebBrowser::InitializeShare() {}
@@ -441,11 +426,28 @@ void WebBrowser::ExecuteLogin() {
}
void WebBrowser::ExecuteOffline() {
+ const auto main_url = Common::FS::SanitizePath(GetMainURL(offline_document),
+ Common::FS::DirectorySeparator::PlatformDefault);
+
+ if (!Common::FS::Exists(main_url)) {
+ offline_romfs = GetOfflineRomFS(system, title_id, nca_type);
+
+ if (offline_romfs == nullptr) {
+ LOG_ERROR(Service_AM,
+ "RomFS with title_id={:016X} and nca_type={} cannot be extracted!", title_id,
+ nca_type);
+ WebBrowserExit(WebExitReason::WindowClosed);
+ return;
+ }
+ }
+
LOG_INFO(Service_AM, "Opening offline document at {}", offline_document);
- frontend.OpenLocalWebPage(offline_document,
- [this](WebExitReason exit_reason, std::string last_url) {
- WebBrowserExit(exit_reason, last_url);
- });
+
+ frontend.OpenLocalWebPage(
+ offline_document, [this] { ExtractOfflineRomFS(); },
+ [this](WebExitReason exit_reason, std::string last_url) {
+ WebBrowserExit(exit_reason, last_url);
+ });
}
void WebBrowser::ExecuteShare() {
diff --git a/src/core/hle/service/am/applets/web_browser.h b/src/core/hle/service/am/applets/web_browser.h
index c36c717f1..936a49a86 100644
--- a/src/core/hle/service/am/applets/web_browser.h
+++ b/src/core/hle/service/am/applets/web_browser.h
@@ -8,6 +8,7 @@
#include "common/common_funcs.h"
#include "common/common_types.h"
+#include "core/file_sys/vfs_types.h"
#include "core/hle/result.h"
#include "core/hle/service/am/applets/applets.h"
#include "core/hle/service/am/applets/web_types.h"
@@ -16,6 +17,10 @@ namespace Core {
class System;
}
+namespace FileSys {
+enum class ContentRecordType : u8;
+}
+
namespace Service::AM::Applets {
class WebBrowser final : public Applet {
@@ -31,6 +36,8 @@ public:
void ExecuteInteractive() override;
void Execute() override;
+ void ExtractOfflineRomFS();
+
void WebBrowserExit(WebExitReason exit_reason, std::string last_url = "");
private:
@@ -66,8 +73,11 @@ private:
WebArgHeader web_arg_header;
WebArgInputTLVMap web_arg_input_tlv_map;
+ u64 title_id;
+ FileSys::ContentRecordType nca_type;
std::string offline_cache_dir;
std::string offline_document;
+ FileSys::VirtualFile offline_romfs;
Core::System& system;
};