| OLD | NEW |
| 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" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 BrowserContext::GetDefaultStoragePartition(browser_context()) | 155 BrowserContext::GetDefaultStoragePartition(browser_context()) |
| 156 ->GetQuotaManager(), | 156 ->GetQuotaManager(), |
| 157 BrowserContext::GetDefaultStoragePartition(browser_context()) | 157 BrowserContext::GetDefaultStoragePartition(browser_context()) |
| 158 ->GetURLRequestContext())); | 158 ->GetURLRequestContext())); |
| 159 host->Send(new ShellViewMsg_SetWebKitSourceDir(webkit_source_dir_)); | 159 host->Send(new ShellViewMsg_SetWebKitSourceDir(webkit_source_dir_)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | 162 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
| 163 BrowserContext* content_browser_context, | 163 BrowserContext* content_browser_context, |
| 164 ProtocolHandlerMap* protocol_handlers, | 164 ProtocolHandlerMap* protocol_handlers, |
| 165 ProtocolHandlerScopedVector protocol_interceptors) { | 165 URLRequestInterceptorScopedVector request_interceptors) { |
| 166 ShellBrowserContext* shell_browser_context = | 166 ShellBrowserContext* shell_browser_context = |
| 167 ShellBrowserContextForBrowserContext(content_browser_context); | 167 ShellBrowserContextForBrowserContext(content_browser_context); |
| 168 return shell_browser_context->CreateRequestContext( | 168 return shell_browser_context->CreateRequestContext( |
| 169 protocol_handlers, protocol_interceptors.Pass()); | 169 protocol_handlers, request_interceptors.Pass()); |
| 170 } | 170 } |
| 171 | 171 |
| 172 net::URLRequestContextGetter* | 172 net::URLRequestContextGetter* |
| 173 ShellContentBrowserClient::CreateRequestContextForStoragePartition( | 173 ShellContentBrowserClient::CreateRequestContextForStoragePartition( |
| 174 BrowserContext* content_browser_context, | 174 BrowserContext* content_browser_context, |
| 175 const base::FilePath& partition_path, | 175 const base::FilePath& partition_path, |
| 176 bool in_memory, | 176 bool in_memory, |
| 177 ProtocolHandlerMap* protocol_handlers, | 177 ProtocolHandlerMap* protocol_handlers, |
| 178 ProtocolHandlerScopedVector protocol_interceptors) { | 178 URLRequestInterceptorScopedVector request_interceptors) { |
| 179 ShellBrowserContext* shell_browser_context = | 179 ShellBrowserContext* shell_browser_context = |
| 180 ShellBrowserContextForBrowserContext(content_browser_context); | 180 ShellBrowserContextForBrowserContext(content_browser_context); |
| 181 return shell_browser_context->CreateRequestContextForStoragePartition( | 181 return shell_browser_context->CreateRequestContextForStoragePartition( |
| 182 partition_path, | 182 partition_path, |
| 183 in_memory, | 183 in_memory, |
| 184 protocol_handlers, | 184 protocol_handlers, |
| 185 protocol_interceptors.Pass()); | 185 request_interceptors.Pass()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { | 188 bool ShellContentBrowserClient::IsHandledURL(const GURL& url) { |
| 189 if (!url.is_valid()) | 189 if (!url.is_valid()) |
| 190 return false; | 190 return false; |
| 191 DCHECK_EQ(url.scheme(), StringToLowerASCII(url.scheme())); | 191 DCHECK_EQ(url.scheme(), StringToLowerASCII(url.scheme())); |
| 192 // Keep in sync with ProtocolHandlers added by | 192 // Keep in sync with ProtocolHandlers added by |
| 193 // ShellURLRequestContextGetter::GetURLRequestContext(). | 193 // ShellURLRequestContextGetter::GetURLRequestContext(). |
| 194 static const char* const kProtocolList[] = { | 194 static const char* const kProtocolList[] = { |
| 195 url::kBlobScheme, | 195 url::kBlobScheme, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 ResourceContext* resource_context, | 287 ResourceContext* resource_context, |
| 288 const GURL& current_url, | 288 const GURL& current_url, |
| 289 const GURL& new_url) { | 289 const GURL& new_url) { |
| 290 return g_swap_processes_for_redirect; | 290 return g_swap_processes_for_redirect; |
| 291 } | 291 } |
| 292 | 292 |
| 293 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 293 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 294 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 294 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 295 const CommandLine& command_line, | 295 const CommandLine& command_line, |
| 296 int child_process_id, | 296 int child_process_id, |
| 297 std::vector<content::FileDescriptorInfo>* mappings) { | 297 std::vector<FileDescriptorInfo>* mappings) { |
| 298 #if defined(OS_ANDROID) | 298 #if defined(OS_ANDROID) |
| 299 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; | 299 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; |
| 300 base::FilePath pak_file; | 300 base::FilePath pak_file; |
| 301 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 301 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); |
| 302 CHECK(r); | 302 CHECK(r); |
| 303 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 303 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); |
| 304 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); | 304 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); |
| 305 | 305 |
| 306 base::File f(pak_file, flags); | 306 base::File f(pak_file, flags); |
| 307 if (!f.IsValid()) { | 307 if (!f.IsValid()) { |
| 308 NOTREACHED() << "Failed to open file when creating renderer process: " | 308 NOTREACHED() << "Failed to open file when creating renderer process: " |
| 309 << "content_shell.pak"; | 309 << "content_shell.pak"; |
| 310 } | 310 } |
| 311 mappings->push_back( | 311 mappings->push_back( |
| 312 content::FileDescriptorInfo(kShellPakDescriptor, | 312 FileDescriptorInfo(kShellPakDescriptor, base::FileDescriptor(f.Pass()))); |
| 313 base::FileDescriptor(f.Pass()))); | |
| 314 | 313 |
| 315 if (breakpad::IsCrashReporterEnabled()) { | 314 if (breakpad::IsCrashReporterEnabled()) { |
| 316 f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( | 315 f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( |
| 317 child_process_id); | 316 child_process_id); |
| 318 if (!f.IsValid()) { | 317 if (!f.IsValid()) { |
| 319 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " | 318 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " |
| 320 << "be disabled for this process."; | 319 << "be disabled for this process."; |
| 321 } else { | 320 } else { |
| 322 mappings->push_back( | 321 mappings->push_back( |
| 323 FileDescriptorInfo(kAndroidMinidumpDescriptor, | 322 FileDescriptorInfo(kAndroidMinidumpDescriptor, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 ShellBrowserContext* | 365 ShellBrowserContext* |
| 367 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 366 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
| 368 BrowserContext* content_browser_context) { | 367 BrowserContext* content_browser_context) { |
| 369 if (content_browser_context == browser_context()) | 368 if (content_browser_context == browser_context()) |
| 370 return browser_context(); | 369 return browser_context(); |
| 371 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 370 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
| 372 return off_the_record_browser_context(); | 371 return off_the_record_browser_context(); |
| 373 } | 372 } |
| 374 | 373 |
| 375 } // namespace content | 374 } // namespace content |
| OLD | NEW |