incantations for WebContentsPreferences::GetPreloadPath wide strings
This commit is contained in:
parent
451e0931bf
commit
205f572181
1 changed files with 21 additions and 0 deletions
|
@ -61,6 +61,21 @@ bool GetAsString(const base::Value* val,
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
bool GetAsString(const base::Value* val,
|
||||
base::FilePath::StringPieceType path,
|
||||
std::u16string* out) {
|
||||
if (val) {
|
||||
auto* found = val->FindKeyOfType(path, base::Value::Type::STRING);
|
||||
if (found) {
|
||||
*out = base::UTF8ToWide(found->GetString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool GetAsInteger(const base::Value* val, base::StringPiece path, int* out) {
|
||||
if (val) {
|
||||
auto* found = val->FindKey(path);
|
||||
|
@ -246,6 +261,12 @@ bool WebContentsPreferences::GetPreloadPath(base::FilePath* path) const {
|
|||
} else if (GetAsString(&preference_, options::kPreloadURL, &preload_path)) {
|
||||
// Translate to file path if there is "preload-url" option.
|
||||
base::FilePath preload;
|
||||
GURL preload_url;
|
||||
#if defined(OS_WIN)
|
||||
preload_url = GURL(base::WideToUTF8(preload_path));
|
||||
#else
|
||||
preload_url = GURL(preload_path);
|
||||
#endif
|
||||
if (net::FileURLToFilePath(GURL(preload_path), &preload)) {
|
||||
*path = std::move(preload);
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue