| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/service_manager/service_overrides.h" | 5 #include "services/service_manager/service_overrides.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 | 41 |
| 42 std::string executable_path_value; | 42 std::string executable_path_value; |
| 43 if (value->GetString(kExecutablePathKey, &executable_path_value)) { | 43 if (value->GetString(kExecutablePathKey, &executable_path_value)) { |
| 44 base::FilePath exe_dir; | 44 base::FilePath exe_dir; |
| 45 CHECK(base::PathService::Get(base::DIR_EXE, &exe_dir)); | 45 CHECK(base::PathService::Get(base::DIR_EXE, &exe_dir)); |
| 46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 47 executable_path_value += ".exe"; | 47 executable_path_value += ".exe"; |
| 48 base::ReplaceFirstSubstringAfterOffset( | 48 base::ReplaceFirstSubstringAfterOffset( |
| 49 &executable_path_value, 0, "$EXE_DIR", | 49 &executable_path_value, 0, "@EXE_DIR", |
| 50 base::UTF16ToUTF8(exe_dir.value())); | 50 base::UTF16ToUTF8(exe_dir.value())); |
| 51 new_entry.executable_path = | 51 new_entry.executable_path = |
| 52 base::FilePath(base::UTF8ToUTF16(executable_path_value)); | 52 base::FilePath(base::UTF8ToUTF16(executable_path_value)); |
| 53 #else | 53 #else |
| 54 base::ReplaceFirstSubstringAfterOffset( | 54 base::ReplaceFirstSubstringAfterOffset( |
| 55 &executable_path_value, 0, "$EXE_DIR", | 55 &executable_path_value, 0, "@EXE_DIR", |
| 56 exe_dir.value()); | 56 exe_dir.value()); |
| 57 new_entry.executable_path = base::FilePath(executable_path_value); | 57 new_entry.executable_path = base::FilePath(executable_path_value); |
| 58 #endif | 58 #endif |
| 59 } | 59 } |
| 60 | 60 |
| 61 value->GetString(kPackageNameKey, &new_entry.package_name); | 61 value->GetString(kPackageNameKey, &new_entry.package_name); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 ServiceOverrides::~ServiceOverrides() {} | 65 ServiceOverrides::~ServiceOverrides() {} |
| 66 | 66 |
| 67 bool ServiceOverrides::GetExecutablePathOverride( | 67 bool ServiceOverrides::GetExecutablePathOverride( |
| 68 const std::string& service_name, | 68 const std::string& service_name, |
| 69 base::FilePath* path) const { | 69 base::FilePath* path) const { |
| 70 auto iter = entries_.find(service_name); | 70 auto iter = entries_.find(service_name); |
| 71 if (iter == entries_.end() || iter->second.executable_path.empty()) | 71 if (iter == entries_.end() || iter->second.executable_path.empty()) |
| 72 return false; | 72 return false; |
| 73 | 73 |
| 74 *path = iter->second.executable_path; | 74 *path = iter->second.executable_path; |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace service_manager | 78 } // namespace service_manager |
| OLD | NEW |