Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
waffles
2017/03/01 18:49:20
no (c) after Copyright, and use 2017. See https://
xiaochu
2017/03/02 01:50:05
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_CROS_COMPONENT_INSTALLER_H_ | |
| 5 #define CHROME_BROWSER_COMPONENT_UPDATER_CROS_COMPONENT_INSTALLER_H_ | |
| 6 | |
| 7 #include "base/base_paths.h" | |
| 8 #include "base/bind.h" | |
| 9 #include "base/command_line.h" | |
| 10 #include "base/files/file_enumerator.h" | |
| 11 #include "base/files/file_path.h" | |
| 12 #include "base/files/file_util.h" | |
| 13 #include "base/json/json_file_value_serializer.h" | |
| 14 #include "base/json/json_reader.h" | |
| 15 #include "base/logging.h" | |
| 16 #include "base/memory/ptr_util.h" | |
| 17 #include "base/path_service.h" | |
| 18 #include "base/stl_util.h" | |
| 19 #include "base/strings/string_util.h" | |
| 20 #include "base/strings/stringprintf.h" | |
| 21 #include "base/strings/utf_string_conversions.h" | |
| 22 #include "base/version.h" | |
| 23 #include "build/build_config.h" | |
| 24 #include "chrome/browser/browser_process.h" | |
| 25 #include "chrome/browser/component_updater/component_installer_errors.h" | |
| 26 #include "chrome/browser/component_updater/cros_component_installer.h" | |
| 27 #include "chrome/browser/plugins/plugin_prefs.h" | |
| 28 #include "chrome/common/chrome_constants.h" | |
| 29 #include "chrome/common/chrome_content_client.h" | |
| 30 #include "chrome/common/chrome_paths.h" | |
| 31 #include "chrome/common/chrome_switches.h" | |
| 32 #include "components/component_updater/component_updater_service.h" | |
| 33 #include "components/component_updater/default_component_installer.h" | |
| 34 #include "components/update_client/update_client.h" | |
| 35 #include "components/update_client/update_client_errors.h" | |
| 36 #include "content/public/browser/browser_thread.h" | |
| 37 #include "content/public/browser/plugin_service.h" | |
| 38 #include "content/public/common/content_constants.h" | |
| 39 #include "crypto/sha2.h" | |
| 40 | |
| 41 #if defined(OS_CHROMEOS) | |
| 42 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 43 #include "chrome/browser/ui/ash/system_tray_client.h" | |
| 44 #include "chrome/common/chrome_features.h" | |
| 45 #include "chromeos/dbus/dbus_method_call_status.h" | |
| 46 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 47 #include "chromeos/dbus/image_loader_client.h" | |
| 48 #include "content/public/browser/browser_thread.h" | |
| 49 #elif defined(OS_LINUX) | |
| 50 #include "chrome/common/component_flash_hint_file_linux.h" | |
|
waffles
2017/03/01 18:49:20
Do you really need this? I'm also unsure about man
xiaochu
2017/03/02 01:50:05
Done.
| |
| 51 #endif // defined(OS_CHROMEOS) | |
|
waffles
2017/03/01 18:49:20
Do you want to consider having the entire CrOSComp
xiaochu
2017/03/02 01:50:05
Done.
| |
| 52 | |
| 53 namespace component_updater { | |
| 54 | |
| 55 static const char componentConfigReaderFilepathstr[] = | |
| 56 "/etc/cros_component.config"; | |
| 57 static std::unique_ptr<base::Value> componentConfigReaderRoot = nullptr; | |
|
waffles
2017/03/01 18:49:20
Not sure this is allowed. See https://google.githu
xiaochu
2017/03/02 01:50:05
Done.
| |
| 58 | |
| 59 class ComponentUpdateService; | |
| 60 | |
| 61 struct ComponentConfig { | |
| 62 std::string name; | |
| 63 std::string dir; | |
| 64 std::string sha2hashstr; | |
| 65 }; | |
| 66 class CrOSComponentInstallerTraits : public ComponentInstallerTraits { | |
| 67 public: | |
| 68 CrOSComponentInstallerTraits(std::string dir_name, | |
| 69 std::string name, | |
| 70 std::string sha2HashStr); | |
| 71 ~CrOSComponentInstallerTraits() override {} | |
| 72 | |
| 73 private: | |
| 74 // The following methods override ComponentInstallerTraits. | |
| 75 bool SupportsGroupPolicyEnabledComponentUpdates() const override; | |
| 76 bool RequiresNetworkEncryption() const override; | |
| 77 update_client::CrxInstaller::Result OnCustomInstall( | |
| 78 const base::DictionaryValue& manifest, | |
| 79 const base::FilePath& install_dir) override; | |
| 80 bool VerifyInstallation(const base::DictionaryValue& manifest, | |
| 81 const base::FilePath& install_dir) const override; | |
| 82 void ComponentReady(const base::Version& version, | |
| 83 const base::FilePath& path, | |
| 84 std::unique_ptr<base::DictionaryValue> manifest) override; | |
| 85 base::FilePath GetRelativeInstallDir() const override; | |
| 86 void GetHash(std::vector<uint8_t>* hash) const override; | |
| 87 std::string GetName() const override; | |
| 88 update_client::InstallerAttributes GetInstallerAttributes() const override; | |
| 89 std::vector<std::string> GetMimeTypes() const override; | |
| 90 std::string dir_name; | |
| 91 std::string name; | |
| 92 uint8_t kSha2Hash_[crypto::kSHA256Length] = {}; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTraits); | |
| 95 }; | |
| 96 | |
| 97 // Register a CrOS component. | |
| 98 // It must be called on UI thread. | |
| 99 // It also assumes LoadCrOSConfig has finished loading configuration. Otherwise, | |
| 100 // it does nothing. | |
| 101 bool RegisterCrOSComponent(ComponentUpdateService* cus, | |
| 102 const std::string& name); | |
| 103 // Load configuration into memory (only once). | |
| 104 // It is an asynchronous call issued at browser launch. | |
| 105 void LoadCrOSConfig(ComponentUpdateService* cus); | |
| 106 | |
| 107 } // namespace component_updater | |
| 108 | |
| 109 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CROS_COMPONENT_INSTALLER_H_ | |
| OLD | NEW |