OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_COMPONENT_FLASH_HINT_FILE_H_ |
| 6 #define CHROME_COMMON_COMPONENT_FLASH_HINT_FILE_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/files/file_util.h" |
| 12 #include "crypto/secure_hash.h" |
| 13 |
| 14 namespace chrome { |
| 15 |
| 16 // This class wraps the component updated flash hint file, which lives inside |
| 17 // the PepperFlash folder of the user-data-dir, so that the Linux zygote |
| 18 // process can preload the right version of flash. |
| 19 class ComponentFlashHintFile { |
| 20 public: |
| 21 ComponentFlashHintFile(); |
| 22 // Records a new flash update into the hint file. |
| 23 // unpacked_plugin is the current location of the plugin. |
| 24 // moved_plugin is the location where the plugin will be loaded from. |
| 25 bool RecordFlashUpdate(base::FilePath& unpacked_plugin, |
| 26 base::FilePath& moved_plugin, |
| 27 const std::string& version); |
| 28 // Attempts to revert the flash hint file to its previous state, before this |
| 29 // update. |
| 30 bool Revert(); |
| 31 // Reports whether or not a hints file exists. |
| 32 static bool DoesHintFileExist(); |
| 33 // Return the path of the component updated flash plugin, only if the file has |
| 34 // the correct hash sum. |
| 35 static bool VerifyAndReturnFlashLocation(base::FilePath* path, |
| 36 std::string* version); |
| 37 |
| 38 private: |
| 39 // This will serialize the file to disk as JSON. The format is: |
| 40 // { |
| 41 // "Version": 0x10, |
| 42 // "HashAlgorithm": SecureHash::SHA256, |
| 43 // "Hash": <Base64 Encoded Hash>, |
| 44 // "PluginPath": /path/to/component/updated/flash.so, |
| 45 // "PluginVersion": "1.0.0.1" |
| 46 // } |
| 47 bool WriteToDisk(int version, |
| 48 crypto::SecureHash::Algorithm algorithm, |
| 49 const std::string& hash, |
| 50 base::FilePath& plugin_path, |
| 51 const std::string& flash_version); |
| 52 // Indicates whether or not a hint file existed prior to this file being |
| 53 // written. |
| 54 bool was_previous_hint_file_; |
| 55 // Contains the contents of the previous hint file. |
| 56 std::string previous_hint_file_; |
| 57 }; |
| 58 |
| 59 } // namespace chrome |
| 60 |
| 61 #endif // CHROME_COMMON_COMPONENT_FLASH_HINT_FILE_H_ |
OLD | NEW |