| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ash/shell/content_client/shell_content_browser_client.h" | 5 #include "ash/shell/content_client/shell_content_browser_client.h" |
| 6 | 6 |
| 7 #include "ash/shell/content_client/shell_browser_main_parts.h" | 7 #include "ash/shell/content_client/shell_browser_main_parts.h" |
| 8 #include "content/public/common/content_descriptors.h" |
| 8 #include "content/shell/browser/shell_browser_context.h" | 9 #include "content/shell/browser/shell_browser_context.h" |
| 10 #include "gin/public/isolate_holder.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 | 12 |
| 11 namespace ash { | 13 namespace ash { |
| 12 namespace shell { | 14 namespace shell { |
| 13 | 15 |
| 14 ShellContentBrowserClient::ShellContentBrowserClient() | 16 ShellContentBrowserClient::ShellContentBrowserClient() |
| 15 : shell_browser_main_parts_(NULL) { | 17 : |
| 18 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 19 v8_natives_fd_(-1), |
| 20 v8_snapshot_fd_(-1), |
| 21 #endif // OS_POSIX && !OS_MACOSX |
| 22 shell_browser_main_parts_(nullptr) { |
| 16 } | 23 } |
| 17 | 24 |
| 18 ShellContentBrowserClient::~ShellContentBrowserClient() { | 25 ShellContentBrowserClient::~ShellContentBrowserClient() { |
| 19 } | 26 } |
| 20 | 27 |
| 21 content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( | 28 content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( |
| 22 const content::MainFunctionParams& parameters) { | 29 const content::MainFunctionParams& parameters) { |
| 23 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); | 30 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); |
| 24 return shell_browser_main_parts_; | 31 return shell_browser_main_parts_; |
| 25 } | 32 } |
| 26 | 33 |
| 27 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | 34 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
| 28 content::BrowserContext* content_browser_context, | 35 content::BrowserContext* content_browser_context, |
| 29 content::ProtocolHandlerMap* protocol_handlers, | 36 content::ProtocolHandlerMap* protocol_handlers, |
| 30 content::URLRequestInterceptorScopedVector request_interceptors) { | 37 content::URLRequestInterceptorScopedVector request_interceptors) { |
| 31 content::ShellBrowserContext* shell_context = | 38 content::ShellBrowserContext* shell_context = |
| 32 static_cast<content::ShellBrowserContext*>(content_browser_context); | 39 static_cast<content::ShellBrowserContext*>(content_browser_context); |
| 33 return shell_context->CreateRequestContext(protocol_handlers, | 40 return shell_context->CreateRequestContext(protocol_handlers, |
| 34 request_interceptors.Pass()); | 41 request_interceptors.Pass()); |
| 35 } | 42 } |
| 36 | 43 |
| 44 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 45 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 46 const base::CommandLine& command_line, |
| 47 int child_process_id, |
| 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::IsolateHolder::OpenV8FilesForChildProcesses(&v8_natives_fd, |
| 54 &v8_snapshot_fd)) { |
| 55 v8_natives_fd_.reset(v8_natives_fd); |
| 56 v8_snapshot_fd_.reset(v8_snapshot_fd); |
| 57 } |
| 58 } |
| 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 |
| 63 } |
| 64 #endif // OS_POSIX && !OS_MACOSX |
| 65 |
| 37 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() { | 66 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() { |
| 38 return shell_browser_main_parts_->browser_context(); | 67 return shell_browser_main_parts_->browser_context(); |
| 39 } | 68 } |
| 40 | 69 |
| 41 } // namespace examples | 70 } // namespace examples |
| 42 } // namespace views | 71 } // namespace views |
| OLD | NEW |