Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Unified Diff: content/common/sandbox_win.cc

Issue 231763003: Support sideloaded fonts via command line option for blink layout_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/sandbox_win.cc
diff --git a/content/common/sandbox_win.cc b/content/common/sandbox_win.cc
index 6f063d7d8384610e714dc3721e6bb4031ddcf34c..603dcbe9e17c0ce761ec1ee1314451d37e37fe4a 100644
--- a/content/common/sandbox_win.cc
+++ b/content/common/sandbox_win.cc
@@ -15,8 +15,10 @@
#include "base/hash.h"
#include "base/path_service.h"
#include "base/process/launch.h"
+#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/win/iat_patch_function.h"
#include "base/win/scoped_handle.h"
#include "base/win/scoped_process_information.h"
@@ -581,6 +583,19 @@ bool ShouldUseDirectWrite() {
base::win::GetVersion() >= base::win::VERSION_WIN7;
}
+bool GetSideloadFontFiles(std::vector<std::string>* files) {
+ files->clear();
jam 2014/04/14 05:40:02 nit: no need for return value and out parameter, j
scottmg 2014/04/14 15:48:58 Done.
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kRegisterFontFiles)) {
+ std::vector<std::string> font_files;
+ base::SplitString(
+ command_line.GetSwitchValueASCII(switches::kRegisterFontFiles),
+ ';',
+ files);
+ }
+ return !files->empty();
+}
+
base::ProcessHandle StartSandboxedProcess(
SandboxedProcessLauncherDelegate* delegate,
CommandLine* cmd_line) {
@@ -654,6 +669,16 @@ base::ProcessHandle StartSandboxedProcess(
true,
sandbox::TargetPolicy::FILES_ALLOW_READONLY,
policy);
+ std::vector<std::string> font_files;
+ if (GetSideloadFontFiles(&font_files)) {
+ for (std::vector<std::string>::const_iterator i(font_files.begin());
+ i != font_files.end();
+ ++i) {
+ policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
+ sandbox::TargetPolicy::FILES_ALLOW_READONLY,
+ base::UTF8ToWide(i->c_str()).c_str());
jam 2014/04/14 05:40:02 nit: the first c_str() isn't needed
scottmg 2014/04/14 15:48:58 Done.
+ }
+ }
}
} else {
// Hack for Google Desktop crash. Trick GD into not injecting its DLL into

Powered by Google App Engine
This is Rietveld 408576698