From e4fa77ef6ac42d36c880db1658dfdd67dcf5d025 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 17 Jan 2019 11:08:02 -0500 Subject: yuzu/web_browser: Make slot functions private These currently aren't used by anything other than the QtWebBrowser class itself, and can be made private. --- src/yuzu/applets/web_browser.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/yuzu/applets/web_browser.h b/src/yuzu/applets/web_browser.h index bba273767..983886586 100644 --- a/src/yuzu/applets/web_browser.h +++ b/src/yuzu/applets/web_browser.h @@ -43,11 +43,10 @@ public: signals: void MainWindowOpenPage(std::string_view filename, std::string_view additional_args) const; -public slots: +private: void MainWindowUnpackRomFS(); void MainWindowFinishedBrowsing(); -private: mutable std::function unpack_romfs_callback; mutable std::function finished_callback; }; -- cgit v1.2.3 From 66978a772da04e438571cdd98529c736663817ee Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 17 Jan 2019 11:10:31 -0500 Subject: yuzu/web_browser: std::move std::function instances in OpenPage() Avoids the need to potentially reallocate the contained callbacks. --- src/yuzu/applets/web_browser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yuzu/applets/web_browser.cpp b/src/yuzu/applets/web_browser.cpp index c59b7ade1..b801d38fe 100644 --- a/src/yuzu/applets/web_browser.cpp +++ b/src/yuzu/applets/web_browser.cpp @@ -87,8 +87,8 @@ QtWebBrowser::~QtWebBrowser() = default; void QtWebBrowser::OpenPage(std::string_view url, std::function unpack_romfs_callback, std::function finished_callback) const { - this->unpack_romfs_callback = unpack_romfs_callback; - this->finished_callback = finished_callback; + this->unpack_romfs_callback = std::move(unpack_romfs_callback); + this->finished_callback = std::move(finished_callback); const auto index = url.find('?'); if (index == std::string::npos) { -- cgit v1.2.3 From a661025637f301013d9da781e67334853162c6b3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 17 Jan 2019 11:19:44 -0500 Subject: core/frontend/applets/web_browser: Make OpenPage() non-const This is a function that definitely doesn't always have a non-modifying behavior across all implementations, so this should be made non-const. This gets rid of the need to mark data members as mutable to work around the fact mutating data members needs to occur. --- src/core/core.cpp | 16 ++++++++++------ src/core/core.h | 13 +++++++------ src/core/frontend/applets/web_browser.cpp | 2 +- src/core/frontend/applets/web_browser.h | 4 ++-- src/core/hle/service/am/applets/web_browser.cpp | 2 +- src/yuzu/applets/web_browser.cpp | 2 +- src/yuzu/applets/web_browser.h | 6 +++--- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 31c590866..572814e4b 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -443,27 +443,31 @@ std::shared_ptr System::GetFilesystem() const { return impl->virtual_filesystem; } -void System::SetProfileSelector(std::unique_ptr applet) { +void System::SetProfileSelector(std::unique_ptr applet) { impl->profile_selector = std::move(applet); } -const Core::Frontend::ProfileSelectApplet& System::GetProfileSelector() const { +const Frontend::ProfileSelectApplet& System::GetProfileSelector() const { return *impl->profile_selector; } -void System::SetSoftwareKeyboard(std::unique_ptr applet) { +void System::SetSoftwareKeyboard(std::unique_ptr applet) { impl->software_keyboard = std::move(applet); } -const Core::Frontend::SoftwareKeyboardApplet& System::GetSoftwareKeyboard() const { +const Frontend::SoftwareKeyboardApplet& System::GetSoftwareKeyboard() const { return *impl->software_keyboard; } -void System::SetWebBrowser(std::unique_ptr applet) { +void System::SetWebBrowser(std::unique_ptr applet) { impl->web_browser = std::move(applet); } -const Core::Frontend::WebBrowserApplet& System::GetWebBrowser() const { +Frontend::WebBrowserApplet& System::GetWebBrowser() { + return *impl->web_browser; +} + +const Frontend::WebBrowserApplet& System::GetWebBrowser() const { return *impl->web_browser; } diff --git a/src/core/core.h b/src/core/core.h index a53dbb4d4..511a5ad3a 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -243,17 +243,18 @@ public: std::shared_ptr GetFilesystem() const; - void SetProfileSelector(std::unique_ptr applet); + void SetProfileSelector(std::unique_ptr applet); - const Core::Frontend::ProfileSelectApplet& GetProfileSelector() const; + const Frontend::ProfileSelectApplet& GetProfileSelector() const; - void SetSoftwareKeyboard(std::unique_ptr applet); + void SetSoftwareKeyboard(std::unique_ptr applet); - const Core::Frontend::SoftwareKeyboardApplet& GetSoftwareKeyboard() const; + const Frontend::SoftwareKeyboardApplet& GetSoftwareKeyboard() const; - void SetWebBrowser(std::unique_ptr applet); + void SetWebBrowser(std::unique_ptr applet); - const Core::Frontend::WebBrowserApplet& GetWebBrowser() const; + Frontend::WebBrowserApplet& GetWebBrowser(); + const Frontend::WebBrowserApplet& GetWebBrowser() const; private: System(); diff --git a/src/core/frontend/applets/web_browser.cpp b/src/core/frontend/applets/web_browser.cpp index 6a36b4b8f..3a3d3d0bf 100644 --- a/src/core/frontend/applets/web_browser.cpp +++ b/src/core/frontend/applets/web_browser.cpp @@ -13,7 +13,7 @@ DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; void DefaultWebBrowserApplet::OpenPage(std::string_view filename, std::function unpack_romfs_callback, - std::function finished_callback) const { + std::function finished_callback) { LOG_INFO(Service_AM, "(STUBBED) called - No suitable web browser implementation found to open website page " "at '{}'!", diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h index 41d272d26..f952856af 100644 --- a/src/core/frontend/applets/web_browser.h +++ b/src/core/frontend/applets/web_browser.h @@ -14,7 +14,7 @@ public: virtual ~WebBrowserApplet(); virtual void OpenPage(std::string_view url, std::function unpack_romfs_callback, - std::function finished_callback) const = 0; + std::function finished_callback) = 0; }; class DefaultWebBrowserApplet final : public WebBrowserApplet { @@ -22,7 +22,7 @@ public: ~DefaultWebBrowserApplet() override; void OpenPage(std::string_view url, std::function unpack_romfs_callback, - std::function finished_callback) const override; + std::function finished_callback) override; }; } // 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 d975207f5..ba2650e8b 100644 --- a/src/core/hle/service/am/applets/web_browser.cpp +++ b/src/core/hle/service/am/applets/web_browser.cpp @@ -146,7 +146,7 @@ void WebBrowser::Execute() { return; } - const auto& frontend{Core::System::GetInstance().GetWebBrowser()}; + auto& frontend{Core::System::GetInstance().GetWebBrowser()}; frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); }); } diff --git a/src/yuzu/applets/web_browser.cpp b/src/yuzu/applets/web_browser.cpp index b801d38fe..6a9138d53 100644 --- a/src/yuzu/applets/web_browser.cpp +++ b/src/yuzu/applets/web_browser.cpp @@ -86,7 +86,7 @@ QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { QtWebBrowser::~QtWebBrowser() = default; void QtWebBrowser::OpenPage(std::string_view url, std::function unpack_romfs_callback, - std::function finished_callback) const { + std::function finished_callback) { this->unpack_romfs_callback = std::move(unpack_romfs_callback); this->finished_callback = std::move(finished_callback); diff --git a/src/yuzu/applets/web_browser.h b/src/yuzu/applets/web_browser.h index 983886586..1a3d67353 100644 --- a/src/yuzu/applets/web_browser.h +++ b/src/yuzu/applets/web_browser.h @@ -38,7 +38,7 @@ public: ~QtWebBrowser() override; void OpenPage(std::string_view url, std::function unpack_romfs_callback, - std::function finished_callback) const override; + std::function finished_callback) override; signals: void MainWindowOpenPage(std::string_view filename, std::string_view additional_args) const; @@ -47,6 +47,6 @@ private: void MainWindowUnpackRomFS(); void MainWindowFinishedBrowsing(); - mutable std::function unpack_romfs_callback; - mutable std::function finished_callback; + std::function unpack_romfs_callback; + std::function finished_callback; }; -- cgit v1.2.3 From 59619285438ce72a62e2e6522a9ca135419cbefd Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 17 Jan 2019 11:25:34 -0500 Subject: core/frontend/applets/web_browser: Include missing headers Gets rid of a few indirect inclusions. --- src/core/hle/service/am/applets/web_browser.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp index ba2650e8b..9b0aa7f5f 100644 --- a/src/core/hle/service/am/applets/web_browser.cpp +++ b/src/core/hle/service/am/applets/web_browser.cpp @@ -2,9 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include +#include + +#include "common/assert.h" +#include "common/common_funcs.h" #include "common/common_paths.h" +#include "common/file_util.h" #include "common/hex_util.h" -#include "common/logging/backend.h" +#include "common/logging/log.h" #include "common/string_util.h" #include "core/core.h" #include "core/file_sys/content_archive.h" @@ -12,7 +19,6 @@ #include "core/file_sys/nca_metadata.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs.h" -#include "core/file_sys/romfs_factory.h" #include "core/file_sys/vfs_types.h" #include "core/frontend/applets/web_browser.h" #include "core/hle/kernel/process.h" -- cgit v1.2.3