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/app/chrome_main_delegate.h" | 5 #include "chrome/app/chrome_main_delegate.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
66 #include <atlbase.h> | 66 #include <atlbase.h> |
67 #include <malloc.h> | 67 #include <malloc.h> |
68 | 68 |
69 #include <algorithm> | 69 #include <algorithm> |
70 | 70 |
71 #include "base/debug/close_handle_hook_win.h" | 71 #include "base/debug/close_handle_hook_win.h" |
72 #include "chrome/browser/downgrade/user_data_downgrade.h" | 72 #include "chrome/browser/downgrade/user_data_downgrade.h" |
73 #include "chrome/child/v8_breakpad_support_win.h" | 73 #include "chrome/child/v8_breakpad_support_win.h" |
74 #include "chrome/common/child_process_logging.h" | 74 #include "chrome/common/child_process_logging.h" |
| 75 #include "chrome/install_static/install_util.h" |
75 #include "sandbox/win/src/sandbox.h" | 76 #include "sandbox/win/src/sandbox.h" |
76 #include "ui/base/resource/resource_bundle_win.h" | 77 #include "ui/base/resource/resource_bundle_win.h" |
77 #endif | 78 #endif |
78 | 79 |
79 #if defined(OS_MACOSX) | 80 #if defined(OS_MACOSX) |
80 #include "base/mac/foundation_util.h" | 81 #include "base/mac/foundation_util.h" |
81 #include "chrome/app/chrome_main_mac.h" | 82 #include "chrome/app/chrome_main_mac.h" |
82 #include "chrome/browser/mac/relauncher.h" | 83 #include "chrome/browser/mac/relauncher.h" |
83 #include "chrome/browser/shell_integration.h" | 84 #include "chrome/browser/shell_integration.h" |
84 #include "chrome/common/mac/cfbundle_blocker.h" | 85 #include "chrome/common/mac/cfbundle_blocker.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 #endif // OS_POSIX | 380 #endif // OS_POSIX |
380 | 381 |
381 struct MainFunction { | 382 struct MainFunction { |
382 const char* name; | 383 const char* name; |
383 int (*function)(const content::MainFunctionParams&); | 384 int (*function)(const content::MainFunctionParams&); |
384 }; | 385 }; |
385 | 386 |
386 // Initializes the user data dir. Must be called before InitializeLocalState(). | 387 // Initializes the user data dir. Must be called before InitializeLocalState(). |
387 void InitializeUserDataDir(base::CommandLine* command_line) { | 388 void InitializeUserDataDir(base::CommandLine* command_line) { |
388 #if defined(OS_WIN) | 389 #if defined(OS_WIN) |
389 wchar_t user_data_dir_buf[MAX_PATH], invalid_user_data_dir_buf[MAX_PATH]; | |
390 | |
391 using GetUserDataDirectoryThunkFunction = | |
392 void (*)(wchar_t*, size_t, wchar_t*, size_t); | |
393 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName); | 390 HMODULE elf_module = GetModuleHandle(chrome::kChromeElfDllName); |
394 if (elf_module) { | 391 if (elf_module) { |
395 // If we're in a test, chrome_elf won't be loaded. | 392 // If we're in a test, chrome_elf won't be loaded. |
396 GetUserDataDirectoryThunkFunction get_user_data_directory_thunk = | 393 |
397 reinterpret_cast<GetUserDataDirectoryThunkFunction>( | 394 base::FilePath user_data_dir(install_static::GetUserDataDirectory()); |
398 GetProcAddress(elf_module, "GetUserDataDirectoryThunk")); | 395 // An empty user data directory means a failure (no fallback/default could |
399 get_user_data_directory_thunk( | 396 // be retrieved either). |
400 user_data_dir_buf, arraysize(user_data_dir_buf), | 397 CHECK(!user_data_dir.empty()); |
401 invalid_user_data_dir_buf, arraysize(invalid_user_data_dir_buf)); | 398 base::FilePath invalid_user_data_dir( |
402 base::FilePath user_data_dir(user_data_dir_buf); | 399 install_static::GetInvalidUserDataDirectory()); |
403 if (invalid_user_data_dir_buf[0] != 0) { | 400 if (!invalid_user_data_dir.empty()) { |
404 chrome::SetInvalidSpecifiedUserDataDir( | 401 chrome::SetInvalidSpecifiedUserDataDir(invalid_user_data_dir); |
405 base::FilePath(invalid_user_data_dir_buf)); | |
406 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); | 402 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
407 } | 403 } |
408 CHECK(PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA, | 404 CHECK(PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA, |
409 user_data_dir, false, true)); | 405 user_data_dir, false, true)); |
410 } else { | 406 } else { |
411 // In tests, just respect the flag if given. | 407 // In tests, just respect the flag if given. |
412 base::FilePath user_data_dir = | 408 base::FilePath user_data_dir = |
413 command_line->GetSwitchValuePath(switches::kUserDataDir); | 409 command_line->GetSwitchValuePath(switches::kUserDataDir); |
414 if (!user_data_dir.empty()) { | 410 if (!user_data_dir.empty()) { |
415 if (user_data_dir.EndsWithSeparator()) | 411 if (user_data_dir.EndsWithSeparator()) |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 | 1211 |
1216 std::unique_ptr<service_manager::Service> | 1212 std::unique_ptr<service_manager::Service> |
1217 ChromeMainDelegate::CreateEmbeddedService(const std::string& service_name) { | 1213 ChromeMainDelegate::CreateEmbeddedService(const std::string& service_name) { |
1218 #if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) | 1214 #if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) |
1219 auto mash_service = CreateEmbeddedMashService(service_name); | 1215 auto mash_service = CreateEmbeddedMashService(service_name); |
1220 if (mash_service) | 1216 if (mash_service) |
1221 return mash_service; | 1217 return mash_service; |
1222 #endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) | 1218 #endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) |
1223 return nullptr; | 1219 return nullptr; |
1224 } | 1220 } |
OLD | NEW |