diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/frontend/applets/web_browser.cpp | 5 | ||||
| -rw-r--r-- | src/core/frontend/applets/web_browser.h | 11 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/web_browser.cpp | 66 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/web_browser.h | 10 | ||||
| -rw-r--r-- | src/yuzu/applets/web_browser.cpp | 21 | ||||
| -rw-r--r-- | src/yuzu/applets/web_browser.h | 21 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 58 | ||||
| -rw-r--r-- | src/yuzu/main.h | 1 |
8 files changed, 125 insertions, 68 deletions
diff --git a/src/core/frontend/applets/web_browser.cpp b/src/core/frontend/applets/web_browser.cpp index 0e1612e27..a5d8f82ac 100644 --- a/src/core/frontend/applets/web_browser.cpp +++ b/src/core/frontend/applets/web_browser.cpp | |||
| @@ -12,11 +12,12 @@ WebBrowserApplet::~WebBrowserApplet() = default; | |||
| 12 | DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; | 12 | DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; |
| 13 | 13 | ||
| 14 | void DefaultWebBrowserApplet::OpenLocalWebPage( | 14 | void DefaultWebBrowserApplet::OpenLocalWebPage( |
| 15 | std::string_view local_url, std::function<void(WebExitReason, std::string)> callback) const { | 15 | std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 16 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { | ||
| 16 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}", | 17 | LOG_WARNING(Service_AM, "(STUBBED) called, backend requested to open local web page at {}", |
| 17 | local_url); | 18 | local_url); |
| 18 | 19 | ||
| 19 | callback(WebExitReason::WindowClosed, "http://localhost/"); | 20 | callback(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost/"); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | } // namespace Core::Frontend | 23 | } // namespace Core::Frontend |
diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h index 2ccefc68f..5b0629cfb 100644 --- a/src/core/frontend/applets/web_browser.h +++ b/src/core/frontend/applets/web_browser.h | |||
| @@ -9,8 +9,6 @@ | |||
| 9 | 9 | ||
| 10 | #include "core/hle/service/am/applets/web_types.h" | 10 | #include "core/hle/service/am/applets/web_types.h" |
| 11 | 11 | ||
| 12 | using namespace Service::AM::Applets; | ||
| 13 | |||
| 14 | namespace Core::Frontend { | 12 | namespace Core::Frontend { |
| 15 | 13 | ||
| 16 | class WebBrowserApplet { | 14 | class WebBrowserApplet { |
| @@ -18,16 +16,17 @@ public: | |||
| 18 | virtual ~WebBrowserApplet(); | 16 | virtual ~WebBrowserApplet(); |
| 19 | 17 | ||
| 20 | virtual void OpenLocalWebPage( | 18 | virtual void OpenLocalWebPage( |
| 21 | std::string_view local_url, | 19 | std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 22 | std::function<void(WebExitReason, std::string)> callback) const = 0; | 20 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const = 0; |
| 23 | }; | 21 | }; |
| 24 | 22 | ||
| 25 | class DefaultWebBrowserApplet final : public WebBrowserApplet { | 23 | class DefaultWebBrowserApplet final : public WebBrowserApplet { |
| 26 | public: | 24 | public: |
| 27 | ~DefaultWebBrowserApplet() override; | 25 | ~DefaultWebBrowserApplet() override; |
| 28 | 26 | ||
| 29 | void OpenLocalWebPage(std::string_view local_url, | 27 | void OpenLocalWebPage(std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 30 | std::function<void(WebExitReason, std::string)> callback) const override; | 28 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> |
| 29 | callback) const override; | ||
| 31 | }; | 30 | }; |
| 32 | 31 | ||
| 33 | } // namespace Core::Frontend | 32 | } // namespace Core::Frontend |
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 @@ | |||
| 15 | #include "core/file_sys/registered_cache.h" | 15 | #include "core/file_sys/registered_cache.h" |
| 16 | #include "core/file_sys/romfs.h" | 16 | #include "core/file_sys/romfs.h" |
| 17 | #include "core/file_sys/system_archive/system_archive.h" | 17 | #include "core/file_sys/system_archive/system_archive.h" |
| 18 | #include "core/file_sys/vfs_types.h" | ||
| 19 | #include "core/file_sys/vfs_vector.h" | 18 | #include "core/file_sys/vfs_vector.h" |
| 20 | #include "core/frontend/applets/web_browser.h" | 19 | #include "core/frontend/applets/web_browser.h" |
| 21 | #include "core/hle/kernel/process.h" | 20 | #include "core/hle/kernel/process.h" |
| @@ -311,6 +310,18 @@ void WebBrowser::Execute() { | |||
| 311 | } | 310 | } |
| 312 | } | 311 | } |
| 313 | 312 | ||
| 313 | void WebBrowser::ExtractOfflineRomFS() { | ||
| 314 | LOG_DEBUG(Service_AM, "Extracting RomFS to {}", offline_cache_dir); | ||
| 315 | |||
| 316 | const auto extracted_romfs_dir = | ||
| 317 | FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard); | ||
| 318 | |||
| 319 | const auto temp_dir = | ||
| 320 | system.GetFilesystem()->CreateDirectory(offline_cache_dir, FileSys::Mode::ReadWrite); | ||
| 321 | |||
| 322 | FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir); | ||
| 323 | } | ||
| 324 | |||
| 314 | void WebBrowser::WebBrowserExit(WebExitReason exit_reason, std::string last_url) { | 325 | void WebBrowser::WebBrowserExit(WebExitReason exit_reason, std::string last_url) { |
| 315 | if ((web_arg_header.shim_kind == ShimKind::Share && | 326 | if ((web_arg_header.shim_kind == ShimKind::Share && |
| 316 | web_applet_version >= WebAppletVersion::Version196608) || | 327 | web_applet_version >= WebAppletVersion::Version196608) || |
| @@ -360,12 +371,11 @@ void WebBrowser::InitializeOffline() { | |||
| 360 | const auto document_kind = | 371 | const auto document_kind = |
| 361 | ParseRawValue<DocumentKind>(GetInputTLVData(WebArgInputTLVType::DocumentKind).value()); | 372 | ParseRawValue<DocumentKind>(GetInputTLVData(WebArgInputTLVType::DocumentKind).value()); |
| 362 | 373 | ||
| 363 | u64 title_id{}; | ||
| 364 | FileSys::ContentRecordType nca_type{FileSys::ContentRecordType::HtmlDocument}; | ||
| 365 | std::string additional_paths; | 374 | std::string additional_paths; |
| 366 | 375 | ||
| 367 | switch (document_kind) { | 376 | switch (document_kind) { |
| 368 | case DocumentKind::OfflineHtmlPage: | 377 | case DocumentKind::OfflineHtmlPage: |
| 378 | default: | ||
| 369 | title_id = system.CurrentProcess()->GetTitleID(); | 379 | title_id = system.CurrentProcess()->GetTitleID(); |
| 370 | nca_type = FileSys::ContentRecordType::HtmlDocument; | 380 | nca_type = FileSys::ContentRecordType::HtmlDocument; |
| 371 | additional_paths = "html-document"; | 381 | additional_paths = "html-document"; |
| @@ -395,31 +405,6 @@ void WebBrowser::InitializeOffline() { | |||
| 395 | offline_document = Common::FS::SanitizePath( | 405 | offline_document = Common::FS::SanitizePath( |
| 396 | fmt::format("{}/{}/{}", offline_cache_dir, additional_paths, document_path), | 406 | fmt::format("{}/{}/{}", offline_cache_dir, additional_paths, document_path), |
| 397 | Common::FS::DirectorySeparator::PlatformDefault); | 407 | Common::FS::DirectorySeparator::PlatformDefault); |
| 398 | |||
| 399 | const auto main_url = Common::FS::SanitizePath(GetMainURL(offline_document), | ||
| 400 | Common::FS::DirectorySeparator::PlatformDefault); | ||
| 401 | |||
| 402 | if (Common::FS::Exists(main_url)) { | ||
| 403 | return; | ||
| 404 | } | ||
| 405 | |||
| 406 | auto offline_romfs = GetOfflineRomFS(system, title_id, nca_type); | ||
| 407 | |||
| 408 | if (offline_romfs == nullptr) { | ||
| 409 | LOG_ERROR(Service_AM, "RomFS with title_id={:016X} and nca_type={} cannot be extracted!", | ||
| 410 | title_id, nca_type); | ||
| 411 | return; | ||
| 412 | } | ||
| 413 | |||
| 414 | LOG_DEBUG(Service_AM, "Extracting RomFS to {}", offline_cache_dir); | ||
| 415 | |||
| 416 | const auto extracted_romfs_dir = | ||
| 417 | FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard); | ||
| 418 | |||
| 419 | const auto temp_dir = | ||
| 420 | system.GetFilesystem()->CreateDirectory(offline_cache_dir, FileSys::Mode::ReadWrite); | ||
| 421 | |||
| 422 | FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir); | ||
| 423 | } | 408 | } |
| 424 | 409 | ||
| 425 | void WebBrowser::InitializeShare() {} | 410 | void WebBrowser::InitializeShare() {} |
| @@ -441,11 +426,28 @@ void WebBrowser::ExecuteLogin() { | |||
| 441 | } | 426 | } |
| 442 | 427 | ||
| 443 | void WebBrowser::ExecuteOffline() { | 428 | void WebBrowser::ExecuteOffline() { |
| 429 | const auto main_url = Common::FS::SanitizePath(GetMainURL(offline_document), | ||
| 430 | Common::FS::DirectorySeparator::PlatformDefault); | ||
| 431 | |||
| 432 | if (!Common::FS::Exists(main_url)) { | ||
| 433 | offline_romfs = GetOfflineRomFS(system, title_id, nca_type); | ||
| 434 | |||
| 435 | if (offline_romfs == nullptr) { | ||
| 436 | LOG_ERROR(Service_AM, | ||
| 437 | "RomFS with title_id={:016X} and nca_type={} cannot be extracted!", title_id, | ||
| 438 | nca_type); | ||
| 439 | WebBrowserExit(WebExitReason::WindowClosed); | ||
| 440 | return; | ||
| 441 | } | ||
| 442 | } | ||
| 443 | |||
| 444 | LOG_INFO(Service_AM, "Opening offline document at {}", offline_document); | 444 | LOG_INFO(Service_AM, "Opening offline document at {}", offline_document); |
| 445 | frontend.OpenLocalWebPage(offline_document, | 445 | |
| 446 | [this](WebExitReason exit_reason, std::string last_url) { | 446 | frontend.OpenLocalWebPage( |
| 447 | WebBrowserExit(exit_reason, last_url); | 447 | offline_document, [this] { ExtractOfflineRomFS(); }, |
| 448 | }); | 448 | [this](WebExitReason exit_reason, std::string last_url) { |
| 449 | WebBrowserExit(exit_reason, last_url); | ||
| 450 | }); | ||
| 449 | } | 451 | } |
| 450 | 452 | ||
| 451 | void WebBrowser::ExecuteShare() { | 453 | 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 @@ | |||
| 8 | 8 | ||
| 9 | #include "common/common_funcs.h" | 9 | #include "common/common_funcs.h" |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "core/file_sys/vfs_types.h" | ||
| 11 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
| 12 | #include "core/hle/service/am/applets/applets.h" | 13 | #include "core/hle/service/am/applets/applets.h" |
| 13 | #include "core/hle/service/am/applets/web_types.h" | 14 | #include "core/hle/service/am/applets/web_types.h" |
| @@ -16,6 +17,10 @@ namespace Core { | |||
| 16 | class System; | 17 | class System; |
| 17 | } | 18 | } |
| 18 | 19 | ||
| 20 | namespace FileSys { | ||
| 21 | enum class ContentRecordType : u8; | ||
| 22 | } | ||
| 23 | |||
| 19 | namespace Service::AM::Applets { | 24 | namespace Service::AM::Applets { |
| 20 | 25 | ||
| 21 | class WebBrowser final : public Applet { | 26 | class WebBrowser final : public Applet { |
| @@ -31,6 +36,8 @@ public: | |||
| 31 | void ExecuteInteractive() override; | 36 | void ExecuteInteractive() override; |
| 32 | void Execute() override; | 37 | void Execute() override; |
| 33 | 38 | ||
| 39 | void ExtractOfflineRomFS(); | ||
| 40 | |||
| 34 | void WebBrowserExit(WebExitReason exit_reason, std::string last_url = ""); | 41 | void WebBrowserExit(WebExitReason exit_reason, std::string last_url = ""); |
| 35 | 42 | ||
| 36 | private: | 43 | private: |
| @@ -66,8 +73,11 @@ private: | |||
| 66 | WebArgHeader web_arg_header; | 73 | WebArgHeader web_arg_header; |
| 67 | WebArgInputTLVMap web_arg_input_tlv_map; | 74 | WebArgInputTLVMap web_arg_input_tlv_map; |
| 68 | 75 | ||
| 76 | u64 title_id; | ||
| 77 | FileSys::ContentRecordType nca_type; | ||
| 69 | std::string offline_cache_dir; | 78 | std::string offline_cache_dir; |
| 70 | std::string offline_document; | 79 | std::string offline_document; |
| 80 | FileSys::VirtualFile offline_romfs; | ||
| 71 | 81 | ||
| 72 | Core::System& system; | 82 | Core::System& system; |
| 73 | }; | 83 | }; |
diff --git a/src/yuzu/applets/web_browser.cpp b/src/yuzu/applets/web_browser.cpp index 26b9df51a..52c99d1ba 100644 --- a/src/yuzu/applets/web_browser.cpp +++ b/src/yuzu/applets/web_browser.cpp | |||
| @@ -120,7 +120,7 @@ QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system) | |||
| 120 | [this] { | 120 | [this] { |
| 121 | if (page()->url() == url_interceptor->GetRequestedURL()) { | 121 | if (page()->url() == url_interceptor->GetRequestedURL()) { |
| 122 | SetFinished(true); | 122 | SetFinished(true); |
| 123 | SetExitReason(WebExitReason::WindowClosed); | 123 | SetExitReason(Service::AM::Applets::WebExitReason::WindowClosed); |
| 124 | } | 124 | } |
| 125 | }, | 125 | }, |
| 126 | Qt::QueuedConnection); | 126 | Qt::QueuedConnection); |
| @@ -135,7 +135,7 @@ void QtNXWebEngineView::LoadLocalWebPage(std::string_view main_url, | |||
| 135 | std::string_view additional_args) { | 135 | std::string_view additional_args) { |
| 136 | SetUserAgent(UserAgent::WebApplet); | 136 | SetUserAgent(UserAgent::WebApplet); |
| 137 | SetFinished(false); | 137 | SetFinished(false); |
| 138 | SetExitReason(WebExitReason::EndButtonPressed); | 138 | SetExitReason(Service::AM::Applets::WebExitReason::EndButtonPressed); |
| 139 | SetLastURL("http://localhost/"); | 139 | SetLastURL("http://localhost/"); |
| 140 | StartInputThread(); | 140 | StartInputThread(); |
| 141 | 141 | ||
| @@ -176,11 +176,11 @@ void QtNXWebEngineView::SetFinished(bool finished_) { | |||
| 176 | finished = finished_; | 176 | finished = finished_; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | WebExitReason QtNXWebEngineView::GetExitReason() const { | 179 | Service::AM::Applets::WebExitReason QtNXWebEngineView::GetExitReason() const { |
| 180 | return exit_reason; | 180 | return exit_reason; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | void QtNXWebEngineView::SetExitReason(WebExitReason exit_reason_) { | 183 | void QtNXWebEngineView::SetExitReason(Service::AM::Applets::WebExitReason exit_reason_) { |
| 184 | exit_reason = exit_reason_; | 184 | exit_reason = exit_reason_; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| @@ -316,6 +316,8 @@ void QtNXWebEngineView::InputThread() { | |||
| 316 | QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { | 316 | QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { |
| 317 | connect(this, &QtWebBrowser::MainWindowOpenLocalWebPage, &main_window, | 317 | connect(this, &QtWebBrowser::MainWindowOpenLocalWebPage, &main_window, |
| 318 | &GMainWindow::WebBrowserOpenLocalWebPage, Qt::QueuedConnection); | 318 | &GMainWindow::WebBrowserOpenLocalWebPage, Qt::QueuedConnection); |
| 319 | connect(&main_window, &GMainWindow::WebBrowserExtractOfflineRomFS, this, | ||
| 320 | &QtWebBrowser::MainWindowExtractOfflineRomFS, Qt::QueuedConnection); | ||
| 319 | connect(&main_window, &GMainWindow::WebBrowserClosed, this, | 321 | connect(&main_window, &GMainWindow::WebBrowserClosed, this, |
| 320 | &QtWebBrowser::MainWindowWebBrowserClosed, Qt::QueuedConnection); | 322 | &QtWebBrowser::MainWindowWebBrowserClosed, Qt::QueuedConnection); |
| 321 | } | 323 | } |
| @@ -323,7 +325,9 @@ QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { | |||
| 323 | QtWebBrowser::~QtWebBrowser() = default; | 325 | QtWebBrowser::~QtWebBrowser() = default; |
| 324 | 326 | ||
| 325 | void QtWebBrowser::OpenLocalWebPage( | 327 | void QtWebBrowser::OpenLocalWebPage( |
| 326 | std::string_view local_url, std::function<void(WebExitReason, std::string)> callback) const { | 328 | std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 329 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback) const { | ||
| 330 | this->extract_romfs_callback = std::move(extract_romfs_callback); | ||
| 327 | this->callback = std::move(callback); | 331 | this->callback = std::move(callback); |
| 328 | 332 | ||
| 329 | const auto index = local_url.find('?'); | 333 | const auto index = local_url.find('?'); |
| @@ -335,6 +339,11 @@ void QtWebBrowser::OpenLocalWebPage( | |||
| 335 | } | 339 | } |
| 336 | } | 340 | } |
| 337 | 341 | ||
| 338 | void QtWebBrowser::MainWindowWebBrowserClosed(WebExitReason exit_reason, std::string last_url) { | 342 | void QtWebBrowser::MainWindowExtractOfflineRomFS() { |
| 343 | extract_romfs_callback(); | ||
| 344 | } | ||
| 345 | |||
| 346 | void QtWebBrowser::MainWindowWebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason, | ||
| 347 | std::string last_url) { | ||
| 339 | callback(exit_reason, last_url); | 348 | callback(exit_reason, last_url); |
| 340 | } | 349 | } |
diff --git a/src/yuzu/applets/web_browser.h b/src/yuzu/applets/web_browser.h index 74f2b49d2..18b8640a7 100644 --- a/src/yuzu/applets/web_browser.h +++ b/src/yuzu/applets/web_browser.h | |||
| @@ -69,8 +69,8 @@ public: | |||
| 69 | [[nodiscard]] bool IsFinished() const; | 69 | [[nodiscard]] bool IsFinished() const; |
| 70 | void SetFinished(bool finished_); | 70 | void SetFinished(bool finished_); |
| 71 | 71 | ||
| 72 | [[nodiscard]] WebExitReason GetExitReason() const; | 72 | [[nodiscard]] Service::AM::Applets::WebExitReason GetExitReason() const; |
| 73 | void SetExitReason(WebExitReason exit_reason_); | 73 | void SetExitReason(Service::AM::Applets::WebExitReason exit_reason_); |
| 74 | 74 | ||
| 75 | [[nodiscard]] const std::string& GetLastURL() const; | 75 | [[nodiscard]] const std::string& GetLastURL() const; |
| 76 | void SetLastURL(std::string last_url_); | 76 | void SetLastURL(std::string last_url_); |
| @@ -148,7 +148,8 @@ private: | |||
| 148 | 148 | ||
| 149 | std::atomic<bool> finished{}; | 149 | std::atomic<bool> finished{}; |
| 150 | 150 | ||
| 151 | WebExitReason exit_reason{WebExitReason::EndButtonPressed}; | 151 | Service::AM::Applets::WebExitReason exit_reason{ |
| 152 | Service::AM::Applets::WebExitReason::EndButtonPressed}; | ||
| 152 | 153 | ||
| 153 | std::string last_url{"http://localhost/"}; | 154 | std::string last_url{"http://localhost/"}; |
| 154 | }; | 155 | }; |
| @@ -162,15 +163,21 @@ public: | |||
| 162 | explicit QtWebBrowser(GMainWindow& parent); | 163 | explicit QtWebBrowser(GMainWindow& parent); |
| 163 | ~QtWebBrowser() override; | 164 | ~QtWebBrowser() override; |
| 164 | 165 | ||
| 165 | void OpenLocalWebPage(std::string_view local_url, | 166 | void OpenLocalWebPage(std::string_view local_url, std::function<void()> extract_romfs_callback, |
| 166 | std::function<void(WebExitReason, std::string)> callback) const override; | 167 | std::function<void(Service::AM::Applets::WebExitReason, std::string)> |
| 168 | callback) const override; | ||
| 167 | 169 | ||
| 168 | signals: | 170 | signals: |
| 169 | void MainWindowOpenLocalWebPage(std::string_view main_url, | 171 | void MainWindowOpenLocalWebPage(std::string_view main_url, |
| 170 | std::string_view additional_args) const; | 172 | std::string_view additional_args) const; |
| 171 | 173 | ||
| 172 | private: | 174 | private: |
| 173 | void MainWindowWebBrowserClosed(WebExitReason exit_reason, std::string last_url); | 175 | void MainWindowExtractOfflineRomFS(); |
| 174 | 176 | ||
| 175 | mutable std::function<void(WebExitReason, std::string)> callback; | 177 | void MainWindowWebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason, |
| 178 | std::string last_url); | ||
| 179 | |||
| 180 | mutable std::function<void()> extract_romfs_callback; | ||
| 181 | |||
| 182 | mutable std::function<void(Service::AM::Applets::WebExitReason, std::string)> callback; | ||
| 176 | }; | 183 | }; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index bab76db1e..f696fc494 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -372,24 +372,49 @@ void GMainWindow::WebBrowserOpenLocalWebPage(std::string_view main_url, | |||
| 372 | 372 | ||
| 373 | QtNXWebEngineView web_browser_view(this, Core::System::GetInstance()); | 373 | QtNXWebEngineView web_browser_view(this, Core::System::GetInstance()); |
| 374 | 374 | ||
| 375 | web_browser_view.LoadLocalWebPage(main_url, additional_args); | ||
| 376 | |||
| 377 | ui.action_Pause->setEnabled(false); | 375 | ui.action_Pause->setEnabled(false); |
| 378 | ui.action_Restart->setEnabled(false); | 376 | ui.action_Restart->setEnabled(false); |
| 379 | ui.action_Stop->setEnabled(false); | 377 | ui.action_Stop->setEnabled(false); |
| 380 | 378 | ||
| 381 | if (render_window->IsLoadingComplete()) { | 379 | { |
| 382 | render_window->hide(); | 380 | QProgressDialog loading_progress(this); |
| 383 | } | 381 | loading_progress.setLabelText(tr("Loading Web Applet...")); |
| 382 | loading_progress.setRange(0, 3); | ||
| 383 | loading_progress.setValue(0); | ||
| 384 | |||
| 385 | if (!Common::FS::Exists(std::string(main_url))) { | ||
| 386 | loading_progress.show(); | ||
| 387 | |||
| 388 | auto future = QtConcurrent::run([this] { emit WebBrowserExtractOfflineRomFS(); }); | ||
| 389 | |||
| 390 | while (!future.isFinished()) { | ||
| 391 | QCoreApplication::processEvents(); | ||
| 392 | } | ||
| 393 | } | ||
| 384 | 394 | ||
| 385 | const auto& layout = render_window->GetFramebufferLayout(); | 395 | loading_progress.setValue(1); |
| 386 | web_browser_view.resize(layout.screen.GetWidth(), layout.screen.GetHeight()); | ||
| 387 | web_browser_view.move(layout.screen.left, layout.screen.top + menuBar()->height()); | ||
| 388 | web_browser_view.setZoomFactor(static_cast<qreal>(layout.screen.GetWidth()) / | ||
| 389 | static_cast<qreal>(Layout::ScreenUndocked::Width)); | ||
| 390 | 396 | ||
| 391 | web_browser_view.setFocus(); | 397 | web_browser_view.LoadLocalWebPage(main_url, additional_args); |
| 392 | web_browser_view.show(); | 398 | |
| 399 | if (render_window->IsLoadingComplete()) { | ||
| 400 | render_window->hide(); | ||
| 401 | } | ||
| 402 | |||
| 403 | const auto& layout = render_window->GetFramebufferLayout(); | ||
| 404 | web_browser_view.resize(layout.screen.GetWidth(), layout.screen.GetHeight()); | ||
| 405 | web_browser_view.move(layout.screen.left, layout.screen.top + menuBar()->height()); | ||
| 406 | web_browser_view.setZoomFactor(static_cast<qreal>(layout.screen.GetWidth()) / | ||
| 407 | static_cast<qreal>(Layout::ScreenUndocked::Width)); | ||
| 408 | |||
| 409 | web_browser_view.setFocus(); | ||
| 410 | web_browser_view.show(); | ||
| 411 | |||
| 412 | loading_progress.setValue(2); | ||
| 413 | |||
| 414 | QCoreApplication::processEvents(); | ||
| 415 | |||
| 416 | loading_progress.setValue(3); | ||
| 417 | } | ||
| 393 | 418 | ||
| 394 | bool exit_check = false; | 419 | bool exit_check = false; |
| 395 | 420 | ||
| @@ -402,7 +427,8 @@ void GMainWindow::WebBrowserOpenLocalWebPage(std::string_view main_url, | |||
| 402 | exit_check = false; | 427 | exit_check = false; |
| 403 | if (variant.toBool()) { | 428 | if (variant.toBool()) { |
| 404 | web_browser_view.SetFinished(true); | 429 | web_browser_view.SetFinished(true); |
| 405 | web_browser_view.SetExitReason(WebExitReason::EndButtonPressed); | 430 | web_browser_view.SetExitReason( |
| 431 | Service::AM::Applets::WebExitReason::EndButtonPressed); | ||
| 406 | } | 432 | } |
| 407 | }); | 433 | }); |
| 408 | 434 | ||
| @@ -412,7 +438,7 @@ void GMainWindow::WebBrowserOpenLocalWebPage(std::string_view main_url, | |||
| 412 | if (web_browser_view.GetCurrentURL().contains(QStringLiteral("localhost"))) { | 438 | if (web_browser_view.GetCurrentURL().contains(QStringLiteral("localhost"))) { |
| 413 | if (!web_browser_view.IsFinished()) { | 439 | if (!web_browser_view.IsFinished()) { |
| 414 | web_browser_view.SetFinished(true); | 440 | web_browser_view.SetFinished(true); |
| 415 | web_browser_view.SetExitReason(WebExitReason::CallbackURL); | 441 | web_browser_view.SetExitReason(Service::AM::Applets::WebExitReason::CallbackURL); |
| 416 | } | 442 | } |
| 417 | 443 | ||
| 418 | web_browser_view.SetLastURL(web_browser_view.GetCurrentURL().toStdString()); | 444 | web_browser_view.SetLastURL(web_browser_view.GetCurrentURL().toStdString()); |
| @@ -436,12 +462,14 @@ void GMainWindow::WebBrowserOpenLocalWebPage(std::string_view main_url, | |||
| 436 | ui.action_Restart->setEnabled(true); | 462 | ui.action_Restart->setEnabled(true); |
| 437 | ui.action_Stop->setEnabled(true); | 463 | ui.action_Stop->setEnabled(true); |
| 438 | 464 | ||
| 465 | QCoreApplication::processEvents(); | ||
| 466 | |||
| 439 | emit WebBrowserClosed(exit_reason, last_url); | 467 | emit WebBrowserClosed(exit_reason, last_url); |
| 440 | 468 | ||
| 441 | #else | 469 | #else |
| 442 | 470 | ||
| 443 | // Utilize the same fallback as the default web browser applet. | 471 | // Utilize the same fallback as the default web browser applet. |
| 444 | emit WebBrowserClosed(WebExitReason::WindowClosed, "http://localhost"); | 472 | emit WebBrowserClosed(Service::AM::Applets::WebExitReason::WindowClosed, "http://localhost"); |
| 445 | 473 | ||
| 446 | #endif | 474 | #endif |
| 447 | } | 475 | } |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 22f64fc9c..ed02df3e2 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -130,6 +130,7 @@ signals: | |||
| 130 | void SoftwareKeyboardFinishedText(std::optional<std::u16string> text); | 130 | void SoftwareKeyboardFinishedText(std::optional<std::u16string> text); |
| 131 | void SoftwareKeyboardFinishedCheckDialog(); | 131 | void SoftwareKeyboardFinishedCheckDialog(); |
| 132 | 132 | ||
| 133 | void WebBrowserExtractOfflineRomFS(); | ||
| 133 | void WebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason, std::string last_url); | 134 | void WebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason, std::string last_url); |
| 134 | 135 | ||
| 135 | public slots: | 136 | public slots: |