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 "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 #include "content/public/browser/render_process_host.h" | 116 #include "content/public/browser/render_process_host.h" |
117 #include "content/public/browser/render_view_host.h" | 117 #include "content/public/browser/render_view_host.h" |
118 #include "content/public/browser/resource_context.h" | 118 #include "content/public/browser/resource_context.h" |
119 #include "content/public/browser/site_instance.h" | 119 #include "content/public/browser/site_instance.h" |
120 #include "content/public/browser/web_contents.h" | 120 #include "content/public/browser/web_contents.h" |
121 #include "content/public/common/child_process_host.h" | 121 #include "content/public/common/child_process_host.h" |
122 #include "content/public/common/content_descriptors.h" | 122 #include "content/public/common/content_descriptors.h" |
123 #include "content/public/common/service_registry.h" | 123 #include "content/public/common/service_registry.h" |
124 #include "content/public/common/url_utils.h" | 124 #include "content/public/common/url_utils.h" |
125 #include "content/public/common/web_preferences.h" | 125 #include "content/public/common/web_preferences.h" |
126 #include "gin/v8_initializer.h" | |
127 #include "net/base/mime_util.h" | 126 #include "net/base/mime_util.h" |
128 #include "net/cookies/canonical_cookie.h" | 127 #include "net/cookies/canonical_cookie.h" |
129 #include "net/cookies/cookie_options.h" | 128 #include "net/cookies/cookie_options.h" |
130 #include "net/ssl/ssl_cert_request_info.h" | 129 #include "net/ssl/ssl_cert_request_info.h" |
131 #include "ppapi/host/ppapi_host.h" | 130 #include "ppapi/host/ppapi_host.h" |
132 #include "storage/browser/fileapi/external_mount_points.h" | 131 #include "storage/browser/fileapi/external_mount_points.h" |
133 #include "ui/base/l10n/l10n_util.h" | 132 #include "ui/base/l10n/l10n_util.h" |
134 #include "ui/base/resource/resource_bundle.h" | 133 #include "ui/base/resource/resource_bundle.h" |
135 #include "ui/resources/grit/ui_resources.h" | 134 #include "ui/resources/grit/ui_resources.h" |
136 | 135 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 incognito)); | 600 incognito)); |
602 } | 601 } |
603 #endif // defined(ENABLE_EXTENSIONS) | 602 #endif // defined(ENABLE_EXTENSIONS) |
604 | 603 |
605 } // namespace | 604 } // namespace |
606 | 605 |
607 namespace chrome { | 606 namespace chrome { |
608 | 607 |
609 ChromeContentBrowserClient::ChromeContentBrowserClient() | 608 ChromeContentBrowserClient::ChromeContentBrowserClient() |
610 : | 609 : |
611 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
612 v8_natives_fd_(-1), | |
613 v8_snapshot_fd_(-1), | |
614 #endif // OS_POSIX && !OS_MACOSX | |
615 weak_factory_(this) { | 610 weak_factory_(this) { |
616 #if defined(ENABLE_PLUGINS) | 611 #if defined(ENABLE_PLUGINS) |
617 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) | 612 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) |
618 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); | 613 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); |
619 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) | 614 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) |
620 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); | 615 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); |
621 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) | 616 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
622 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); | 617 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
623 | 618 |
624 extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart); | 619 extra_parts_.push_back(new ChromeContentBrowserClientPluginsPart); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 // of the old files using an open fd. This fd is passed to subprocesses | 1175 // of the old files using an open fd. This fd is passed to subprocesses |
1181 // like renderers. Here we add the flag to tell the subprocesses where | 1176 // like renderers. Here we add the flag to tell the subprocesses where |
1182 // to find these file descriptors. | 1177 // to find these file descriptors. |
1183 void ChromeContentBrowserClient::AppendMappedFileCommandLineSwitches( | 1178 void ChromeContentBrowserClient::AppendMappedFileCommandLineSwitches( |
1184 base::CommandLine* command_line) { | 1179 base::CommandLine* command_line) { |
1185 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1180 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
1186 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 1181 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
1187 std::string process_type = | 1182 std::string process_type = |
1188 command_line->GetSwitchValueASCII(switches::kProcessType); | 1183 command_line->GetSwitchValueASCII(switches::kProcessType); |
1189 if (process_type != switches::kZygoteProcess) { | 1184 if (process_type != switches::kZygoteProcess) { |
1190 // We want to pass the natives by fd because after an update the file may | 1185 DCHECK(v8_files_.natives_fd.is_valid()); |
1191 // be updated, but we want the newly launched renderers to get the old one, | |
1192 // opened by the browser when it started. | |
1193 DCHECK(natives_fd_exists()); | |
1194 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); | 1186 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
1195 if (snapshot_fd_exists()) | 1187 if (v8_files_.snapshot_fd.is_valid()) { |
1196 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | 1188 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
| 1189 } |
1197 } | 1190 } |
1198 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 1191 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
1199 #endif // OS_POSIX && !OS_MACOSX | 1192 #endif // OS_POSIX && !OS_MACOSX |
1200 } | 1193 } |
1201 | 1194 |
1202 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( | 1195 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
1203 base::CommandLine* command_line, | 1196 base::CommandLine* command_line, |
1204 int child_process_id) { | 1197 int child_process_id) { |
1205 #if defined(OS_MACOSX) | 1198 #if defined(OS_MACOSX) |
1206 scoped_ptr<metrics::ClientInfo> client_info = | 1199 scoped_ptr<metrics::ClientInfo> client_info = |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2240 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 2233 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
2241 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 2234 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
2242 const base::CommandLine& command_line, | 2235 const base::CommandLine& command_line, |
2243 int child_process_id, | 2236 int child_process_id, |
2244 FileDescriptorInfo* mappings | 2237 FileDescriptorInfo* mappings |
2245 #if defined(OS_ANDROID) | 2238 #if defined(OS_ANDROID) |
2246 , std::map<int, base::MemoryMappedFile::Region>* regions | 2239 , std::map<int, base::MemoryMappedFile::Region>* regions |
2247 #endif | 2240 #endif |
2248 ) { | 2241 ) { |
2249 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 2242 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
2250 if (!natives_fd_exists()) { | 2243 if (!v8_files_.natives_fd.is_valid()) { |
2251 int v8_natives_fd = -1; | 2244 gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_files_); |
2252 int v8_snapshot_fd = -1; | |
2253 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | |
2254 &v8_snapshot_fd)) { | |
2255 v8_natives_fd_.reset(v8_natives_fd); | |
2256 v8_snapshot_fd_.reset(v8_snapshot_fd); | |
2257 } | |
2258 } | 2245 } |
2259 // V8 can't start up without the source of the natives, but it can | 2246 DCHECK(v8_files_.natives_fd.is_valid()); |
2260 // start up (slower) without the snapshot. | 2247 mappings->Share(kV8NativesDataDescriptor, v8_files_.natives_fd.get()); |
2261 DCHECK(natives_fd_exists()); | 2248 #if defined(OS_ANDROID) |
2262 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 2249 regions->insert( |
2263 if (snapshot_fd_exists()) | 2250 std::make_pair(kV8NativesDataDescriptor, v8_files_.natives_region)); |
2264 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 2251 #endif |
| 2252 if (v8_files_.snapshot_fd.is_valid()) { |
| 2253 mappings->Share(kV8SnapshotDataDescriptor, v8_files_.snapshot_fd.get()); |
| 2254 #if defined(OS_ANDROID) |
| 2255 regions->insert( |
| 2256 std::make_pair(kV8SnapshotDataDescriptor, v8_files_.snapshot_region)); |
| 2257 #endif |
| 2258 } |
2265 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 2259 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
2266 | 2260 |
2267 #if defined(OS_ANDROID) | 2261 #if defined(OS_ANDROID) |
2268 base::FilePath data_path; | 2262 base::FilePath data_path; |
2269 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); | 2263 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); |
2270 DCHECK(!data_path.empty()); | 2264 DCHECK(!data_path.empty()); |
2271 | 2265 |
2272 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 2266 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
2273 base::FilePath chrome_resources_pak = | 2267 base::FilePath chrome_resources_pak = |
2274 data_path.AppendASCII("chrome_100_percent.pak"); | 2268 data_path.AppendASCII("chrome_100_percent.pak"); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2480 switches::kDisableWebRtcEncryption, | 2474 switches::kDisableWebRtcEncryption, |
2481 }; | 2475 }; |
2482 to_command_line->CopySwitchesFrom(from_command_line, | 2476 to_command_line->CopySwitchesFrom(from_command_line, |
2483 kWebRtcDevSwitchNames, | 2477 kWebRtcDevSwitchNames, |
2484 arraysize(kWebRtcDevSwitchNames)); | 2478 arraysize(kWebRtcDevSwitchNames)); |
2485 } | 2479 } |
2486 } | 2480 } |
2487 #endif // defined(ENABLE_WEBRTC) | 2481 #endif // defined(ENABLE_WEBRTC) |
2488 | 2482 |
2489 } // namespace chrome | 2483 } // namespace chrome |
OLD | NEW |