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

Side by Side Diff: content/shell/browser/shell_content_browser_client.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: move to content/shell 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/browser/shell_content_browser_client.h" 5 #include "content/shell/browser/shell_content_browser_client.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/strings/utf_string_conversions.h"
12 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
13 #include "content/public/browser/resource_dispatcher_host.h" 14 #include "content/public/browser/resource_dispatcher_host.h"
14 #include "content/public/browser/storage_partition.h" 15 #include "content/public/browser/storage_partition.h"
15 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
16 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
17 #include "content/shell/browser/shell.h" 18 #include "content/shell/browser/shell.h"
18 #include "content/shell/browser/shell_browser_context.h" 19 #include "content/shell/browser/shell_browser_context.h"
19 #include "content/shell/browser/shell_browser_main_parts.h" 20 #include "content/shell/browser/shell_browser_main_parts.h"
20 #include "content/shell/browser/shell_devtools_delegate.h" 21 #include "content/shell/browser/shell_devtools_delegate.h"
21 #include "content/shell/browser/shell_message_filter.h" 22 #include "content/shell/browser/shell_message_filter.h"
(...skipping 18 matching lines...) Expand all
40 #endif 41 #endif
41 42
42 #if defined(OS_POSIX) && !defined(OS_MACOSX) 43 #if defined(OS_POSIX) && !defined(OS_MACOSX)
43 #include "base/debug/leak_annotations.h" 44 #include "base/debug/leak_annotations.h"
44 #include "base/platform_file.h" 45 #include "base/platform_file.h"
45 #include "components/breakpad/app/breakpad_linux.h" 46 #include "components/breakpad/app/breakpad_linux.h"
46 #include "components/breakpad/browser/crash_handler_host_linux.h" 47 #include "components/breakpad/browser/crash_handler_host_linux.h"
47 #include "content/public/common/content_descriptors.h" 48 #include "content/public/common/content_descriptors.h"
48 #endif 49 #endif
49 50
51 #if defined(OS_WIN)
52 #include "content/common/sandbox_win.h"
53 #include "sandbox/win/src/sandbox.h"
54 #endif
55
50 namespace content { 56 namespace content {
51 57
52 namespace { 58 namespace {
53 59
54 ShellContentBrowserClient* g_browser_client; 60 ShellContentBrowserClient* g_browser_client;
55 bool g_swap_processes_for_redirect = false; 61 bool g_swap_processes_for_redirect = false;
56 62
57 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) 63 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
58 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost( 64 breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
59 const std::string& process_type) { 65 const std::string& process_type) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 224 }
219 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashDumpsDir)) { 225 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashDumpsDir)) {
220 command_line->AppendSwitchPath( 226 command_line->AppendSwitchPath(
221 switches::kCrashDumpsDir, 227 switches::kCrashDumpsDir,
222 CommandLine::ForCurrentProcess()->GetSwitchValuePath( 228 CommandLine::ForCurrentProcess()->GetSwitchValuePath(
223 switches::kCrashDumpsDir)); 229 switches::kCrashDumpsDir));
224 } 230 }
225 if (CommandLine::ForCurrentProcess()->HasSwitch( 231 if (CommandLine::ForCurrentProcess()->HasSwitch(
226 switches::kEnableLeakDetection)) 232 switches::kEnableLeakDetection))
227 command_line->AppendSwitch(switches::kEnableLeakDetection); 233 command_line->AppendSwitch(switches::kEnableLeakDetection);
234 if (CommandLine::ForCurrentProcess()->HasSwitch(
235 switches::kRegisterFontFiles)) {
236 command_line->AppendSwitchASCII(
237 switches::kRegisterFontFiles,
238 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
239 switches::kRegisterFontFiles));
240 }
228 } 241 }
229 242
230 void ShellContentBrowserClient::OverrideWebkitPrefs( 243 void ShellContentBrowserClient::OverrideWebkitPrefs(
231 RenderViewHost* render_view_host, 244 RenderViewHost* render_view_host,
232 const GURL& url, 245 const GURL& url,
233 WebPreferences* prefs) { 246 WebPreferences* prefs) {
234 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) 247 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
235 return; 248 return;
236 WebKitTestController::Get()->OverrideWebkitPrefs(prefs); 249 WebKitTestController::Get()->OverrideWebkitPrefs(prefs);
237 } 250 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 #else // !defined(OS_ANDROID) 333 #else // !defined(OS_ANDROID)
321 int crash_signal_fd = GetCrashSignalFD(command_line); 334 int crash_signal_fd = GetCrashSignalFD(command_line);
322 if (crash_signal_fd >= 0) { 335 if (crash_signal_fd >= 0) {
323 mappings->push_back(FileDescriptorInfo( 336 mappings->push_back(FileDescriptorInfo(
324 kCrashDumpSignal, base::FileDescriptor(crash_signal_fd, false))); 337 kCrashDumpSignal, base::FileDescriptor(crash_signal_fd, false)));
325 } 338 }
326 #endif // defined(OS_ANDROID) 339 #endif // defined(OS_ANDROID)
327 } 340 }
328 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 341 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
329 342
343 #if defined(OS_WIN)
344 void ShellContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy,
345 bool* success) {
346 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS
347 // addition in |StartSandboxedProcess|.
348 std::vector<std::string> font_files = GetSideloadFontFiles();
349 for (std::vector<std::string>::const_iterator i(font_files.begin());
350 i != font_files.end();
351 ++i) {
352 policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
353 sandbox::TargetPolicy::FILES_ALLOW_READONLY,
354 base::UTF8ToWide(*i).c_str());
355 }
356 }
357 #endif // OS_WIN
358
330 ShellBrowserContext* ShellContentBrowserClient::browser_context() { 359 ShellBrowserContext* ShellContentBrowserClient::browser_context() {
331 return shell_browser_main_parts_->browser_context(); 360 return shell_browser_main_parts_->browser_context();
332 } 361 }
333 362
334 ShellBrowserContext* 363 ShellBrowserContext*
335 ShellContentBrowserClient::off_the_record_browser_context() { 364 ShellContentBrowserClient::off_the_record_browser_context() {
336 return shell_browser_main_parts_->off_the_record_browser_context(); 365 return shell_browser_main_parts_->off_the_record_browser_context();
337 } 366 }
338 367
339 AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() { 368 AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() {
340 return new ShellAccessTokenStore(browser_context()); 369 return new ShellAccessTokenStore(browser_context());
341 } 370 }
342 371
343 ShellBrowserContext* 372 ShellBrowserContext*
344 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( 373 ShellContentBrowserClient::ShellBrowserContextForBrowserContext(
345 BrowserContext* content_browser_context) { 374 BrowserContext* content_browser_context) {
346 if (content_browser_context == browser_context()) 375 if (content_browser_context == browser_context())
347 return browser_context(); 376 return browser_context();
348 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); 377 DCHECK_EQ(content_browser_context, off_the_record_browser_context());
349 return off_the_record_browser_context(); 378 return off_the_record_browser_context();
350 } 379 }
351 380
352 } // namespace content 381 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698