Index: chrome/browser/component_updater/cros_component_installer.h |
diff --git a/chrome/browser/component_updater/cros_component_installer.h b/chrome/browser/component_updater/cros_component_installer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fdcd5c6e1565db35fff9a1aa67d5f83e4ab88c55 |
--- /dev/null |
+++ b/chrome/browser/component_updater/cros_component_installer.h |
@@ -0,0 +1,109 @@ |
+// 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.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+#ifndef CHROME_BROWSER_COMPONENT_UPDATER_CROS_COMPONENT_INSTALLER_H_ |
+#define CHROME_BROWSER_COMPONENT_UPDATER_CROS_COMPONENT_INSTALLER_H_ |
+ |
+#include "base/base_paths.h" |
+#include "base/bind.h" |
+#include "base/command_line.h" |
+#include "base/files/file_enumerator.h" |
+#include "base/files/file_path.h" |
+#include "base/files/file_util.h" |
+#include "base/json/json_file_value_serializer.h" |
+#include "base/json/json_reader.h" |
+#include "base/logging.h" |
+#include "base/memory/ptr_util.h" |
+#include "base/path_service.h" |
+#include "base/stl_util.h" |
+#include "base/strings/string_util.h" |
+#include "base/strings/stringprintf.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "base/version.h" |
+#include "build/build_config.h" |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/component_updater/component_installer_errors.h" |
+#include "chrome/browser/component_updater/cros_component_installer.h" |
+#include "chrome/browser/plugins/plugin_prefs.h" |
+#include "chrome/common/chrome_constants.h" |
+#include "chrome/common/chrome_content_client.h" |
+#include "chrome/common/chrome_paths.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "components/component_updater/component_updater_service.h" |
+#include "components/component_updater/default_component_installer.h" |
+#include "components/update_client/update_client.h" |
+#include "components/update_client/update_client_errors.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/plugin_service.h" |
+#include "content/public/common/content_constants.h" |
+#include "crypto/sha2.h" |
+ |
+#if defined(OS_CHROMEOS) |
+#include "chrome/browser/chromeos/settings/cros_settings.h" |
+#include "chrome/browser/ui/ash/system_tray_client.h" |
+#include "chrome/common/chrome_features.h" |
+#include "chromeos/dbus/dbus_method_call_status.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/dbus/image_loader_client.h" |
+#include "content/public/browser/browser_thread.h" |
+#elif defined(OS_LINUX) |
+#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.
|
+#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.
|
+ |
+namespace component_updater { |
+ |
+static const char componentConfigReaderFilepathstr[] = |
+ "/etc/cros_component.config"; |
+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.
|
+ |
+class ComponentUpdateService; |
+ |
+struct ComponentConfig { |
+ std::string name; |
+ std::string dir; |
+ std::string sha2hashstr; |
+}; |
+class CrOSComponentInstallerTraits : public ComponentInstallerTraits { |
+ public: |
+ CrOSComponentInstallerTraits(std::string dir_name, |
+ std::string name, |
+ std::string sha2HashStr); |
+ ~CrOSComponentInstallerTraits() override {} |
+ |
+ private: |
+ // The following methods override ComponentInstallerTraits. |
+ bool SupportsGroupPolicyEnabledComponentUpdates() const override; |
+ bool RequiresNetworkEncryption() const override; |
+ update_client::CrxInstaller::Result OnCustomInstall( |
+ const base::DictionaryValue& manifest, |
+ const base::FilePath& install_dir) override; |
+ bool VerifyInstallation(const base::DictionaryValue& manifest, |
+ const base::FilePath& install_dir) const override; |
+ void ComponentReady(const base::Version& version, |
+ const base::FilePath& path, |
+ std::unique_ptr<base::DictionaryValue> manifest) override; |
+ base::FilePath GetRelativeInstallDir() const override; |
+ void GetHash(std::vector<uint8_t>* hash) const override; |
+ std::string GetName() const override; |
+ update_client::InstallerAttributes GetInstallerAttributes() const override; |
+ std::vector<std::string> GetMimeTypes() const override; |
+ std::string dir_name; |
+ std::string name; |
+ uint8_t kSha2Hash_[crypto::kSHA256Length] = {}; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CrOSComponentInstallerTraits); |
+}; |
+ |
+// Register a CrOS component. |
+// It must be called on UI thread. |
+// It also assumes LoadCrOSConfig has finished loading configuration. Otherwise, |
+// it does nothing. |
+bool RegisterCrOSComponent(ComponentUpdateService* cus, |
+ const std::string& name); |
+// Load configuration into memory (only once). |
+// It is an asynchronous call issued at browser launch. |
+void LoadCrOSConfig(ComponentUpdateService* cus); |
+ |
+} // namespace component_updater |
+ |
+#endif // CHROME_BROWSER_COMPONENT_UPDATER_CROS_COMPONENT_INSTALLER_H_ |