mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Added workaround for HTML Imports.
This commit is contained 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";
|
||||
|
||||
@@ -20,14 +20,13 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LOOT. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
#ifndef __LOOT_GLOBALS__
|
||||
#define __LOOT_GLOBALS__
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
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;
|
||||
|
||||
+2
-1
@@ -95,8 +95,9 @@ namespace loot {
|
||||
// Set the handler for browser-level callbacks.
|
||||
CefRefPtr<LootHandler> 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;
|
||||
|
||||
+14
-2
@@ -30,6 +30,7 @@ along with LOOT. If not, see
|
||||
|
||||
#include <string>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -44,8 +45,19 @@ namespace loot {
|
||||
CefRefPtr<CefRequest> 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/<l10n path>
|
||||
loot://import/<import filename>
|
||||
*/
|
||||
|
||||
// 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", "*");
|
||||
|
||||
Reference in New Issue
Block a user