Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / ash / shell / content_client / shell_content_browser_client.cc
blob51b0107d5ad9f1b8a532e3793655f9a506b1f193
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 "base/command_line.h"
9 #include "content/public/common/content_descriptors.h"
10 #include "content/public/common/content_switches.h"
11 #include "content/shell/browser/shell_browser_context.h"
12 #include "gin/v8_initializer.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
15 namespace ash {
16 namespace shell {
18 ShellContentBrowserClient::ShellContentBrowserClient()
20 #if defined(OS_POSIX) && !defined(OS_MACOSX)
21 v8_natives_fd_(-1),
22 v8_snapshot_fd_(-1),
23 #endif // OS_POSIX && !OS_MACOSX
24 shell_browser_main_parts_(nullptr) {
27 ShellContentBrowserClient::~ShellContentBrowserClient() {
30 content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
31 const content::MainFunctionParams& parameters) {
32 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters);
33 return shell_browser_main_parts_;
36 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext(
37 content::BrowserContext* content_browser_context,
38 content::ProtocolHandlerMap* protocol_handlers,
39 content::URLRequestInterceptorScopedVector request_interceptors) {
40 content::ShellBrowserContext* shell_context =
41 static_cast<content::ShellBrowserContext*>(content_browser_context);
42 return shell_context->CreateRequestContext(protocol_handlers,
43 request_interceptors.Pass());
46 void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
47 base::CommandLine* command_line,
48 int child_process_id) {
49 #if defined(OS_POSIX) && !defined(OS_MACOSX)
50 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
51 std::string process_type =
52 command_line->GetSwitchValueASCII(switches::kProcessType);
53 if (process_type != switches::kZygoteProcess) {
54 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
55 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
57 #endif // V8_USE_EXTERNAL_STARTUP_DATA
58 #endif // OS_POSIX && !OS_MACOSX
61 #if defined(OS_POSIX) && !defined(OS_MACOSX)
62 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
63 const base::CommandLine& command_line,
64 int child_process_id,
65 content::FileDescriptorInfo* mappings) {
66 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
67 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) {
68 int v8_natives_fd = -1;
69 int v8_snapshot_fd = -1;
70 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
71 &v8_snapshot_fd)) {
72 v8_natives_fd_.reset(v8_natives_fd);
73 v8_snapshot_fd_.reset(v8_snapshot_fd);
76 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1);
77 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
78 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
79 #endif // V8_USE_EXTERNAL_STARTUP_DATA
81 #endif // OS_POSIX && !OS_MACOSX
83 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() {
84 return shell_browser_main_parts_->browser_context();
87 } // namespace examples
88 } // namespace views