1
0
Fork 0
forked from suyu/suyu

Merge pull request #2031 from lioncash/priv

yuzu/web_browser: Minor cleanup
This commit is contained in:
bunnei 2019-01-19 12:57:09 -05:00 committed by GitHub
commit 83f8d1aa2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 26 deletions

View file

@ -443,27 +443,31 @@ std::shared_ptr<FileSys::VfsFilesystem> System::GetFilesystem() const {
return impl->virtual_filesystem; return impl->virtual_filesystem;
} }
void System::SetProfileSelector(std::unique_ptr<Core::Frontend::ProfileSelectApplet> applet) { void System::SetProfileSelector(std::unique_ptr<Frontend::ProfileSelectApplet> applet) {
impl->profile_selector = std::move(applet); impl->profile_selector = std::move(applet);
} }
const Core::Frontend::ProfileSelectApplet& System::GetProfileSelector() const { const Frontend::ProfileSelectApplet& System::GetProfileSelector() const {
return *impl->profile_selector; return *impl->profile_selector;
} }
void System::SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet) { void System::SetSoftwareKeyboard(std::unique_ptr<Frontend::SoftwareKeyboardApplet> applet) {
impl->software_keyboard = std::move(applet); impl->software_keyboard = std::move(applet);
} }
const Core::Frontend::SoftwareKeyboardApplet& System::GetSoftwareKeyboard() const { const Frontend::SoftwareKeyboardApplet& System::GetSoftwareKeyboard() const {
return *impl->software_keyboard; return *impl->software_keyboard;
} }
void System::SetWebBrowser(std::unique_ptr<Core::Frontend::WebBrowserApplet> applet) { void System::SetWebBrowser(std::unique_ptr<Frontend::WebBrowserApplet> applet) {
impl->web_browser = std::move(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; return *impl->web_browser;
} }

View file

@ -243,17 +243,18 @@ public:
std::shared_ptr<FileSys::VfsFilesystem> GetFilesystem() const; std::shared_ptr<FileSys::VfsFilesystem> GetFilesystem() const;
void SetProfileSelector(std::unique_ptr<Core::Frontend::ProfileSelectApplet> applet); void SetProfileSelector(std::unique_ptr<Frontend::ProfileSelectApplet> applet);
const Core::Frontend::ProfileSelectApplet& GetProfileSelector() const; const Frontend::ProfileSelectApplet& GetProfileSelector() const;
void SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet); void SetSoftwareKeyboard(std::unique_ptr<Frontend::SoftwareKeyboardApplet> applet);
const Core::Frontend::SoftwareKeyboardApplet& GetSoftwareKeyboard() const; const Frontend::SoftwareKeyboardApplet& GetSoftwareKeyboard() const;
void SetWebBrowser(std::unique_ptr<Core::Frontend::WebBrowserApplet> applet); void SetWebBrowser(std::unique_ptr<Frontend::WebBrowserApplet> applet);
const Core::Frontend::WebBrowserApplet& GetWebBrowser() const; Frontend::WebBrowserApplet& GetWebBrowser();
const Frontend::WebBrowserApplet& GetWebBrowser() const;
private: private:
System(); System();

View file

@ -13,7 +13,7 @@ DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default;
void DefaultWebBrowserApplet::OpenPage(std::string_view filename, void DefaultWebBrowserApplet::OpenPage(std::string_view filename,
std::function<void()> unpack_romfs_callback, std::function<void()> unpack_romfs_callback,
std::function<void()> finished_callback) const { std::function<void()> finished_callback) {
LOG_INFO(Service_AM, LOG_INFO(Service_AM,
"(STUBBED) called - No suitable web browser implementation found to open website page " "(STUBBED) called - No suitable web browser implementation found to open website page "
"at '{}'!", "at '{}'!",

View file

@ -14,7 +14,7 @@ public:
virtual ~WebBrowserApplet(); virtual ~WebBrowserApplet();
virtual void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, virtual void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
std::function<void()> finished_callback) const = 0; std::function<void()> finished_callback) = 0;
}; };
class DefaultWebBrowserApplet final : public WebBrowserApplet { class DefaultWebBrowserApplet final : public WebBrowserApplet {
@ -22,7 +22,7 @@ public:
~DefaultWebBrowserApplet() override; ~DefaultWebBrowserApplet() override;
void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
std::function<void()> finished_callback) const override; std::function<void()> finished_callback) override;
}; };
} // namespace Core::Frontend } // namespace Core::Frontend

View file

@ -2,9 +2,16 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <array>
#include <cstring>
#include <vector>
#include "common/assert.h"
#include "common/common_funcs.h"
#include "common/common_paths.h" #include "common/common_paths.h"
#include "common/file_util.h"
#include "common/hex_util.h" #include "common/hex_util.h"
#include "common/logging/backend.h" #include "common/logging/log.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/core.h" #include "core/core.h"
#include "core/file_sys/content_archive.h" #include "core/file_sys/content_archive.h"
@ -12,7 +19,6 @@
#include "core/file_sys/nca_metadata.h" #include "core/file_sys/nca_metadata.h"
#include "core/file_sys/registered_cache.h" #include "core/file_sys/registered_cache.h"
#include "core/file_sys/romfs.h" #include "core/file_sys/romfs.h"
#include "core/file_sys/romfs_factory.h"
#include "core/file_sys/vfs_types.h" #include "core/file_sys/vfs_types.h"
#include "core/frontend/applets/web_browser.h" #include "core/frontend/applets/web_browser.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
@ -146,7 +152,7 @@ void WebBrowser::Execute() {
return; return;
} }
const auto& frontend{Core::System::GetInstance().GetWebBrowser()}; auto& frontend{Core::System::GetInstance().GetWebBrowser()};
frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); }); frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); });
} }

View file

@ -86,9 +86,9 @@ QtWebBrowser::QtWebBrowser(GMainWindow& main_window) {
QtWebBrowser::~QtWebBrowser() = default; QtWebBrowser::~QtWebBrowser() = default;
void QtWebBrowser::OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, void QtWebBrowser::OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
std::function<void()> finished_callback) const { std::function<void()> finished_callback) {
this->unpack_romfs_callback = unpack_romfs_callback; this->unpack_romfs_callback = std::move(unpack_romfs_callback);
this->finished_callback = finished_callback; this->finished_callback = std::move(finished_callback);
const auto index = url.find('?'); const auto index = url.find('?');
if (index == std::string::npos) { if (index == std::string::npos) {

View file

@ -38,16 +38,15 @@ public:
~QtWebBrowser() override; ~QtWebBrowser() override;
void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
std::function<void()> finished_callback) const override; std::function<void()> finished_callback) override;
signals: signals:
void MainWindowOpenPage(std::string_view filename, std::string_view additional_args) const; void MainWindowOpenPage(std::string_view filename, std::string_view additional_args) const;
public slots: private:
void MainWindowUnpackRomFS(); void MainWindowUnpackRomFS();
void MainWindowFinishedBrowsing(); void MainWindowFinishedBrowsing();
private: std::function<void()> unpack_romfs_callback;
mutable std::function<void()> unpack_romfs_callback; std::function<void()> finished_callback;
mutable std::function<void()> finished_callback;
}; };