diff --git a/src/backend/globals.cpp.in b/src/backend/globals.cpp.in index 5102c80e..b3f54da2 100644 --- a/src/backend/globals.cpp.in +++ b/src/backend/globals.cpp.in @@ -37,6 +37,7 @@ namespace loot { //Common paths. const boost::filesystem::path g_path_readme = boost::filesystem::current_path() / "docs" / "LOOT Readme.html"; const boost::filesystem::path g_path_report = boost::filesystem::current_path() / "resources" / "report" / "report.html"; + const boost::filesystem::path g_path_imports = boost::filesystem::current_path() / "resources" / "report" / "html"; const boost::filesystem::path g_path_l10n = boost::filesystem::current_path() / "resources" / "l10n"; #ifdef _WIN32 const boost::filesystem::path g_path_local = GetLocalAppDataPath() / "LOOT"; diff --git a/src/backend/globals.h b/src/backend/globals.h index 8bee789e..82bc9514 100644 --- a/src/backend/globals.h +++ b/src/backend/globals.h @@ -20,14 +20,13 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #ifndef __LOOT_GLOBALS__ #define __LOOT_GLOBALS__ #include namespace loot { - //Version numbers. extern const unsigned int g_version_major; extern const unsigned int g_version_minor; @@ -39,6 +38,7 @@ namespace loot { //Common paths. extern const boost::filesystem::path g_path_readme; extern const boost::filesystem::path g_path_report; + extern const boost::filesystem::path g_path_imports; extern const boost::filesystem::path g_path_l10n; extern const boost::filesystem::path g_path_local; extern const boost::filesystem::path g_path_settings; diff --git a/src/gui/app.cpp b/src/gui/app.cpp index c535a87f..330e0e69 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -95,8 +95,9 @@ namespace loot { // Set the handler for browser-level callbacks. CefRefPtr handler(new LootHandler()); - // Register the custom "loot" scheme handler. + // Register the custom "loot" scheme handlers. CefRegisterSchemeHandlerFactory("loot", "l10n", new LootSchemeHandlerFactory()); + CefRegisterSchemeHandlerFactory("loot", "import", new LootSchemeHandlerFactory()); // Specify CEF browser settings here. CefBrowserSettings browser_settings; diff --git a/src/gui/scheme.cpp b/src/gui/scheme.cpp index 9a72eddd..e4641eb5 100644 --- a/src/gui/scheme.cpp +++ b/src/gui/scheme.cpp @@ -30,6 +30,7 @@ along with LOOT. If not, see #include #include +#include using namespace std; @@ -44,8 +45,19 @@ namespace loot { CefRefPtr request) { BOOST_LOG_TRIVIAL(trace) << "Handling custom scheme: " << string(request->GetURL()); - // Get the file from the custom URL. - string file = (g_path_l10n / string(request->GetURL()).substr(12)).string(); + /* Two custom URLs are possible: + loot://l10n/ + loot://import/ + */ + + // Get the path from the custom URL. + string file; + if (boost::starts_with(request->GetURL().ToString(), "loot://l10n/")) { + file = (g_path_l10n / request->GetURL().ToString().substr(12)).string(); + } + else { + file = (g_path_imports / request->GetURL().ToString().substr(14)).string(); + } CefResponse::HeaderMap headers; headers.emplace("Access-Control-Allow-Origin", "*");