1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/shell/content_client/shell_content_browser_client.h"
7 #include "ash/shell/content_client/shell_browser_main_parts.h"
8 #include "content/public/common/content_descriptors.h"
9 #include "content/shell/browser/shell_browser_context.h"
10 #include "gin/v8_initializer.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
16 ShellContentBrowserClient::ShellContentBrowserClient()
18 #if defined(OS_POSIX) && !defined(OS_MACOSX)
21 #endif // OS_POSIX && !OS_MACOSX
22 shell_browser_main_parts_(nullptr) {
25 ShellContentBrowserClient::~ShellContentBrowserClient() {
28 content::BrowserMainParts
* ShellContentBrowserClient::CreateBrowserMainParts(
29 const content::MainFunctionParams
& parameters
) {
30 shell_browser_main_parts_
= new ShellBrowserMainParts(parameters
);
31 return shell_browser_main_parts_
;
34 net::URLRequestContextGetter
* ShellContentBrowserClient::CreateRequestContext(
35 content::BrowserContext
* content_browser_context
,
36 content::ProtocolHandlerMap
* protocol_handlers
,
37 content::URLRequestInterceptorScopedVector request_interceptors
) {
38 content::ShellBrowserContext
* shell_context
=
39 static_cast<content::ShellBrowserContext
*>(content_browser_context
);
40 return shell_context
->CreateRequestContext(protocol_handlers
,
41 request_interceptors
.Pass());
44 #if defined(OS_POSIX) && !defined(OS_MACOSX)
45 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
46 const base::CommandLine
& command_line
,
48 content::FileDescriptorInfo
* mappings
) {
49 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
50 if (v8_natives_fd_
.get() == -1 || v8_snapshot_fd_
.get() == -1) {
51 int v8_natives_fd
= -1;
52 int v8_snapshot_fd
= -1;
53 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd
,
55 v8_natives_fd_
.reset(v8_natives_fd
);
56 v8_snapshot_fd_
.reset(v8_snapshot_fd
);
59 DCHECK(v8_natives_fd_
.get() != -1 && v8_snapshot_fd_
.get() != -1);
60 mappings
->Share(kV8NativesDataDescriptor
, v8_natives_fd_
.get());
61 mappings
->Share(kV8SnapshotDataDescriptor
, v8_snapshot_fd_
.get());
62 #endif // V8_USE_EXTERNAL_STARTUP_DATA
64 #endif // OS_POSIX && !OS_MACOSX
66 content::ShellBrowserContext
* ShellContentBrowserClient::browser_context() {
67 return shell_browser_main_parts_
->browser_context();
70 } // namespace examples