| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/component_updater/caps_installer_win.h" | 5 #include "chrome/browser/component_updater/caps_installer_win.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 // CRX hash. The extension id is: bcpgokokgekmnfkohklccmonnakdimfh. | 45 // CRX hash. The extension id is: bcpgokokgekmnfkohklccmonnakdimfh. |
| 46 const uint8_t kSha256Hash[] = {0x12, 0xf6, 0xea, 0xea, 0x64, 0xac, 0xd5, 0xae, | 46 const uint8_t kSha256Hash[] = {0x12, 0xf6, 0xea, 0xea, 0x64, 0xac, 0xd5, 0xae, |
| 47 0x7a, 0xb2, 0x2c, 0xed, 0xd0, 0xa3, 0x8c, 0x57, | 47 0x7a, 0xb2, 0x2c, 0xed, 0xd0, 0xa3, 0x8c, 0x57, |
| 48 0x49, 0x05, 0x8f, 0x7d, 0x14, 0xa4, 0x22, 0x4d, | 48 0x49, 0x05, 0x8f, 0x7d, 0x14, 0xa4, 0x22, 0x4d, |
| 49 0x9b, 0xf6, 0x14, 0x99, 0xdf, 0xf8, 0xc9, 0xb3}; | 49 0x9b, 0xf6, 0x14, 0x99, 0xdf, 0xf8, 0xc9, 0xb3}; |
| 50 | 50 |
| 51 const base::FilePath::CharType kCapsBinary[] = | 51 const base::FilePath::CharType kCapsBinary[] = |
| 52 FILE_PATH_LITERAL("chrome_crash_svc.exe"); | 52 FILE_PATH_LITERAL("chrome_crash_svc.exe"); |
| 53 | 53 |
| 54 const base::FilePath::CharType kCapsDirectory[] = | |
| 55 FILE_PATH_LITERAL("Caps"); | |
| 56 | |
| 57 // This function is called from a worker thread to launch crash service. | 54 // This function is called from a worker thread to launch crash service. |
| 58 void LaunchService(const base::FilePath& exe_path) { | 55 void LaunchService(const base::FilePath& exe_path) { |
| 59 base::CommandLine service_cmdline(exe_path); | 56 base::CommandLine service_cmdline(exe_path); |
| 60 service_cmdline.AppendSwitch("caps-update"); | 57 service_cmdline.AppendSwitch("caps-update"); |
| 61 base::Process service = | 58 base::Process service = |
| 62 base::LaunchProcess(service_cmdline, base::LaunchOptions()); | 59 base::LaunchProcess(service_cmdline, base::LaunchOptions()); |
| 63 CAPSUmaValue uma_step = service.IsValid() ? | 60 CAPSUmaValue uma_step = service.IsValid() ? |
| 64 CAPS_SERVICE_STARTED : CAPS_SERVICE_FAILED_TO_START; | 61 CAPS_SERVICE_STARTED : CAPS_SERVICE_FAILED_TO_START; |
| 65 ReportUmaStep(uma_step); | 62 ReportUmaStep(uma_step); |
| 66 } | 63 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 const base::FilePath& install_dir, | 88 const base::FilePath& install_dir, |
| 92 std::unique_ptr<base::DictionaryValue> manifest) override { | 89 std::unique_ptr<base::DictionaryValue> manifest) override { |
| 93 // Can't block here. This is usually the browser UI thread. | 90 // Can't block here. This is usually the browser UI thread. |
| 94 base::WorkerPool::PostTask( | 91 base::WorkerPool::PostTask( |
| 95 FROM_HERE, | 92 FROM_HERE, |
| 96 base::Bind(&LaunchService, install_dir.Append(kCapsBinary)), | 93 base::Bind(&LaunchService, install_dir.Append(kCapsBinary)), |
| 97 false); | 94 false); |
| 98 } | 95 } |
| 99 | 96 |
| 100 // Directory is usually "%appdata%\Local\Chrome\User Data\Caps". | 97 // Directory is usually "%appdata%\Local\Chrome\User Data\Caps". |
| 101 base::FilePath GetBaseDirectory() const override { | 98 base::FilePath GetRelativeInstallDir() const override { |
| 102 base::FilePath user_data; | 99 return base::FilePath(FILE_PATH_LITERAL("Caps")); |
| 103 PathService::Get(chrome::DIR_USER_DATA, &user_data); | |
| 104 return user_data.Append(kCapsDirectory); | |
| 105 } | 100 } |
| 106 | 101 |
| 107 void GetHash(std::vector<uint8_t>* hash) const override { | 102 void GetHash(std::vector<uint8_t>* hash) const override { |
| 108 hash->assign(kSha256Hash, | 103 hash->assign(kSha256Hash, |
| 109 kSha256Hash + arraysize(kSha256Hash)); | 104 kSha256Hash + arraysize(kSha256Hash)); |
| 110 } | 105 } |
| 111 | 106 |
| 112 // This string is shown in chrome://components. | 107 // This string is shown in chrome://components. |
| 113 std::string GetName() const override { return "Chrome Crash Service"; } | 108 std::string GetName() const override { return "Chrome Crash Service"; } |
| 114 | 109 |
| 115 std::string GetAp() const override { return std::string(); } | 110 std::string GetAp() const override { return std::string(); } |
| 116 }; | 111 }; |
| 117 | 112 |
| 118 } // namespace | 113 } // namespace |
| 119 | 114 |
| 120 void RegisterCAPSComponent(ComponentUpdateService* cus) { | 115 void RegisterCAPSComponent(ComponentUpdateService* cus) { |
| 121 // The component updater takes ownership of |installer|. | 116 // The component updater takes ownership of |installer|. |
| 122 std::unique_ptr<ComponentInstallerTraits> traits(new CAPSInstallerTraits()); | 117 std::unique_ptr<ComponentInstallerTraits> traits(new CAPSInstallerTraits()); |
| 123 DefaultComponentInstaller* installer = | 118 DefaultComponentInstaller* installer = |
| 124 new DefaultComponentInstaller(std::move(traits)); | 119 new DefaultComponentInstaller(std::move(traits)); |
| 125 installer->Register(cus, base::Closure()); | 120 installer->Register(cus, base::Closure()); |
| 126 } | 121 } |
| 127 | 122 |
| 128 } // namespace component_updater | 123 } // namespace component_updater |
| OLD | NEW |