Commit 018fd0e8 authored by skyostil's avatar skyostil Committed by Commit bot

headless: Load resources based on locale

ui::ResourceBundle::InitSharedInstanceWithPakPath is only meant for test
use.

BUG=612904

Review-Url: https://codereview.chromium.org/2591833002
Cr-Commit-Position: refs/heads/master@{#439882}
parent 71aaf189
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "headless/lib/browser/headless_browser_impl.h" #include "headless/lib/browser/headless_browser_impl.h"
#include "headless/lib/browser/headless_content_browser_client.h" #include "headless/lib/browser/headless_content_browser_client.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gfx/switches.h" #include "ui/gfx/switches.h"
#include "ui/gl/gl_switches.h" #include "ui/gl/gl_switches.h"
#include "ui/ozone/public/ozone_switches.h" #include "ui/ozone/public/ozone_switches.h"
...@@ -114,14 +115,20 @@ void HeadlessContentMainDelegate::InitializeResourceBundle() { ...@@ -114,14 +115,20 @@ void HeadlessContentMainDelegate::InitializeResourceBundle() {
base::FilePath pak_file; base::FilePath pak_file;
bool result = PathService::Get(base::DIR_MODULE, &dir_module); bool result = PathService::Get(base::DIR_MODULE, &dir_module);
DCHECK(result); DCHECK(result);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
const std::string locale = command_line->GetSwitchValueASCII(switches::kLang);
ui::ResourceBundle::InitSharedInstanceWithLocale(
locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
// Try loading the headless library pak file first. If it doesn't exist (i.e., // Try loading the headless library pak file first. If it doesn't exist (i.e.,
// when we're running with the --headless switch), fall back to the browser's // when we're running with the --headless switch), fall back to the browser's
// resource pak. // resource pak.
pak_file = dir_module.Append(FILE_PATH_LITERAL("headless_lib.pak")); pak_file = dir_module.Append(FILE_PATH_LITERAL("headless_lib.pak"));
if (!base::PathExists(pak_file)) if (!base::PathExists(pak_file))
pak_file = dir_module.Append(FILE_PATH_LITERAL("resources.pak")); pak_file = dir_module.Append(FILE_PATH_LITERAL("resources.pak"));
// TODO(skyostil): Use the locale-based loader instead. ResourceBundle::GetSharedInstance().AddDataPackFromPath(
ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); pak_file, ui::SCALE_FACTOR_NONE);
} }
content::ContentBrowserClient* content::ContentBrowserClient*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment