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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 std::string process_type = | 284 std::string process_type = |
285 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 285 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
286 switches::kProcessType); | 286 switches::kProcessType); |
287 breakpad::InitCrashReporter(process_type); | 287 breakpad::InitCrashReporter(process_type); |
288 } | 288 } |
289 } | 289 } |
290 #endif | 290 #endif |
291 | 291 |
292 void ShellMainDelegate::InitializeResourceBundle() { | 292 void ShellMainDelegate::InitializeResourceBundle() { |
293 #if defined(OS_ANDROID) | 293 #if defined(OS_ANDROID) |
| 294 LOG(ERROR) << "ShellMainDelegate::InitializeResourceBundle()"; |
294 // On Android, the renderer runs with a different UID and can never access | 295 // On Android, the renderer runs with a different UID and can never access |
295 // the file system. Use the file descriptor passed in at launch time. | 296 // the file system. Use the file descriptor passed in at launch time. |
296 auto* global_descriptors = base::GlobalDescriptors::GetInstance(); | 297 auto* global_descriptors = base::GlobalDescriptors::GetInstance(); |
297 int pak_fd = global_descriptors->MaybeGet(kShellPakDescriptor); | 298 int pak_fd = global_descriptors->MaybeGet(kShellPakDescriptor); |
298 base::MemoryMappedFile::Region pak_region; | 299 base::MemoryMappedFile::Region pak_region; |
299 if (pak_fd >= 0) { | 300 if (pak_fd >= 0) { |
300 pak_region = global_descriptors->GetRegion(kShellPakDescriptor); | 301 pak_region = global_descriptors->GetRegion(kShellPakDescriptor); |
301 } else { | 302 } else { |
302 pak_fd = | 303 pak_fd = |
303 base::android::OpenApkAsset("assets/content_shell.pak", &pak_region); | 304 base::android::OpenApkAsset("assets/content_shell.pak", &pak_region); |
304 // Loaded from disk for browsertests. | 305 // Loaded from disk for browsertests. |
305 if (pak_fd < 0) { | 306 if (pak_fd < 0) { |
306 base::FilePath pak_file; | 307 base::FilePath pak_file; |
307 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 308 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); |
308 DCHECK(r); | 309 DCHECK(r); |
309 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 310 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); |
310 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); | 311 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); |
311 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 312 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
312 pak_fd = base::File(pak_file, flags).TakePlatformFile(); | 313 pak_fd = base::File(pak_file, flags).TakePlatformFile(); |
313 pak_region = base::MemoryMappedFile::Region::kWholeFile; | 314 pak_region = base::MemoryMappedFile::Region::kWholeFile; |
314 } | 315 } |
315 global_descriptors->Set(kShellPakDescriptor, pak_fd, pak_region); | 316 global_descriptors->Set(kShellPakDescriptor, pak_fd, pak_region); |
316 } | 317 } |
317 DCHECK_GE(pak_fd, 0); | 318 DCHECK_GE(pak_fd, 0); |
| 319 LOG(ERROR) << "ShellMainDelegate::InitializeResourceBundle() - crash now?"; |
318 // This is clearly wrong. See crbug.com/330930 | 320 // This is clearly wrong. See crbug.com/330930 |
319 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd), | 321 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd), |
320 pak_region); | 322 pak_region); |
321 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( | 323 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( |
322 base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P); | 324 base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P); |
323 #else // defined(OS_ANDROID) | 325 #else // defined(OS_ANDROID) |
324 #if defined(OS_MACOSX) | 326 #if defined(OS_MACOSX) |
325 base::FilePath pak_file = GetResourcesPakFilePath(); | 327 base::FilePath pak_file = GetResourcesPakFilePath(); |
326 #else | 328 #else |
327 base::FilePath pak_file; | 329 base::FilePath pak_file; |
(...skipping 22 matching lines...) Expand all Loading... |
350 | 352 |
351 return renderer_client_.get(); | 353 return renderer_client_.get(); |
352 } | 354 } |
353 | 355 |
354 ContentUtilityClient* ShellMainDelegate::CreateContentUtilityClient() { | 356 ContentUtilityClient* ShellMainDelegate::CreateContentUtilityClient() { |
355 utility_client_.reset(new ShellContentUtilityClient); | 357 utility_client_.reset(new ShellContentUtilityClient); |
356 return utility_client_.get(); | 358 return utility_client_.get(); |
357 } | 359 } |
358 | 360 |
359 } // namespace content | 361 } // namespace content |
OLD | NEW |