| 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 "content/shell/app/shell_main_delegate.h" | 5 #include "content/shell/app/shell_main_delegate.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/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (exit_code) | 203 if (exit_code) |
| 204 *exit_code = 1; | 204 *exit_code = 1; |
| 205 return true; | 205 return true; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 SetContentClient(&content_client_); | 208 SetContentClient(&content_client_); |
| 209 return false; | 209 return false; |
| 210 } | 210 } |
| 211 | 211 |
| 212 void ShellMainDelegate::PreSandboxStartup() { | 212 void ShellMainDelegate::PreSandboxStartup() { |
| 213 LOG(ERROR) << "auraclank: ShellMainDelegate::PreSandboxStartup"; |
| 213 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) | 214 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) |
| 214 // Create an instance of the CPU class to parse /proc/cpuinfo and cache | 215 // Create an instance of the CPU class to parse /proc/cpuinfo and cache |
| 215 // cpu_brand info. | 216 // cpu_brand info. |
| 216 base::CPU cpu_info; | 217 base::CPU cpu_info; |
| 217 #endif | 218 #endif |
| 218 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 219 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 219 switches::kEnableCrashReporter)) { | 220 switches::kEnableCrashReporter)) { |
| 220 std::string process_type = | 221 std::string process_type = |
| 221 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 222 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 222 switches::kProcessType); | 223 switches::kProcessType); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 std::string process_type = | 280 std::string process_type = |
| 280 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 281 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 281 switches::kProcessType); | 282 switches::kProcessType); |
| 282 breakpad::InitCrashReporter(process_type); | 283 breakpad::InitCrashReporter(process_type); |
| 283 } | 284 } |
| 284 } | 285 } |
| 285 #endif | 286 #endif |
| 286 | 287 |
| 287 void ShellMainDelegate::InitializeResourceBundle() { | 288 void ShellMainDelegate::InitializeResourceBundle() { |
| 288 #if defined(OS_ANDROID) | 289 #if defined(OS_ANDROID) |
| 290 LOG(ERROR) << "auraclank: ShellMainDelegate::InitializeResourceBundle()"; |
| 289 // On Android, the renderer runs with a different UID and can never access | 291 // On Android, the renderer runs with a different UID and can never access |
| 290 // the file system. Use the file descriptor passed in at launch time. | 292 // the file system. Use the file descriptor passed in at launch time. |
| 291 auto* global_descriptors = base::GlobalDescriptors::GetInstance(); | 293 auto* global_descriptors = base::GlobalDescriptors::GetInstance(); |
| 292 int pak_fd = global_descriptors->MaybeGet(kShellPakDescriptor); | 294 int pak_fd = global_descriptors->MaybeGet(kShellPakDescriptor); |
| 293 base::MemoryMappedFile::Region pak_region; | 295 base::MemoryMappedFile::Region pak_region; |
| 294 if (pak_fd >= 0) { | 296 if (pak_fd >= 0) { |
| 295 pak_region = global_descriptors->GetRegion(kShellPakDescriptor); | 297 pak_region = global_descriptors->GetRegion(kShellPakDescriptor); |
| 296 } else { | 298 } else { |
| 297 pak_fd = | 299 pak_fd = |
| 298 base::android::OpenApkAsset("assets/content_shell.pak", &pak_region); | 300 base::android::OpenApkAsset("assets/content_shell.pak", &pak_region); |
| 299 // Loaded from disk for browsertests. | 301 // Loaded from disk for browsertests. |
| 300 if (pak_fd < 0) { | 302 if (pak_fd < 0) { |
| 301 base::FilePath pak_file; | 303 base::FilePath pak_file; |
| 302 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 304 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); |
| 303 DCHECK(r); | 305 DCHECK(r); |
| 304 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 306 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); |
| 305 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); | 307 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); |
| 306 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 308 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
| 307 pak_fd = base::File(pak_file, flags).TakePlatformFile(); | 309 pak_fd = base::File(pak_file, flags).TakePlatformFile(); |
| 308 pak_region = base::MemoryMappedFile::Region::kWholeFile; | 310 pak_region = base::MemoryMappedFile::Region::kWholeFile; |
| 309 } | 311 } |
| 310 global_descriptors->Set(kShellPakDescriptor, pak_fd, pak_region); | 312 global_descriptors->Set(kShellPakDescriptor, pak_fd, pak_region); |
| 311 } | 313 } |
| 312 DCHECK_GE(pak_fd, 0); | 314 DCHECK_GE(pak_fd, 0); |
| 315 LOG(ERROR) << "auraclank: ShellMainDelegate::InitializeResourceBundle() - cras
h now?"; |
| 313 // This is clearly wrong. See crbug.com/330930 | 316 // This is clearly wrong. See crbug.com/330930 |
| 314 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd), | 317 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd), |
| 315 pak_region); | 318 pak_region); |
| 316 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( | 319 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( |
| 317 base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P); | 320 base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P); |
| 318 #else // defined(OS_ANDROID) | 321 #else // defined(OS_ANDROID) |
| 319 #if defined(OS_MACOSX) | 322 #if defined(OS_MACOSX) |
| 320 base::FilePath pak_file = GetResourcesPakFilePath(); | 323 base::FilePath pak_file = GetResourcesPakFilePath(); |
| 321 #else | 324 #else |
| 322 base::FilePath pak_file; | 325 base::FilePath pak_file; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 345 | 348 |
| 346 return renderer_client_.get(); | 349 return renderer_client_.get(); |
| 347 } | 350 } |
| 348 | 351 |
| 349 ContentUtilityClient* ShellMainDelegate::CreateContentUtilityClient() { | 352 ContentUtilityClient* ShellMainDelegate::CreateContentUtilityClient() { |
| 350 utility_client_.reset(new ShellContentUtilityClient); | 353 utility_client_.reset(new ShellContentUtilityClient); |
| 351 return utility_client_.get(); | 354 return utility_client_.get(); |
| 352 } | 355 } |
| 353 | 356 |
| 354 } // namespace content | 357 } // namespace content |
| OLD | NEW |