| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_H_ | 5 #ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_H_ |
| 6 #define EXTENSIONS_BROWSER_CONTENT_VERIFIER_H_ | 6 #define EXTENSIONS_BROWSER_CONTENT_VERIFIER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 class BrowserContext; | 25 class BrowserContext; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace extensions { | 28 namespace extensions { |
| 29 | 29 |
| 30 class Extension; | 30 class Extension; |
| 31 class ContentHashFetcher; | 31 class ContentHashFetcher; |
| 32 class ContentVerifierIOData; | 32 class ContentVerifierIOData; |
| 33 class ManagementPolicy; |
| 33 | 34 |
| 34 // Used for managing overall content verification - both fetching content | 35 // Used for managing overall content verification - both fetching content |
| 35 // hashes as needed, and supplying job objects to verify file contents as they | 36 // hashes as needed, and supplying job objects to verify file contents as they |
| 36 // are read. | 37 // are read. |
| 37 class ContentVerifier : public base::RefCountedThreadSafe<ContentVerifier>, | 38 class ContentVerifier : public base::RefCountedThreadSafe<ContentVerifier>, |
| 38 public ExtensionRegistryObserver { | 39 public ExtensionRegistryObserver { |
| 39 public: | 40 public: |
| 40 class TestObserver { | 41 class TestObserver { |
| 41 public: | 42 public: |
| 42 virtual void OnFetchComplete(const std::string& extension_id, | 43 virtual void OnFetchComplete(const std::string& extension_id, |
| 43 bool success) = 0; | 44 bool success) = 0; |
| 44 }; | 45 }; |
| 46 // Returns true if content verifier should repair the extension (|id|) if it |
| 47 // became courrpted. |
| 48 // Note that this method doesn't check whether |id| is corrupted or not. |
| 49 static bool ShouldRepairIfCorrupted(const ManagementPolicy* management_policy, |
| 50 const Extension* id); |
| 51 |
| 45 static void SetObserverForTests(TestObserver* observer); | 52 static void SetObserverForTests(TestObserver* observer); |
| 46 | 53 |
| 47 ContentVerifier(content::BrowserContext* context, | 54 ContentVerifier(content::BrowserContext* context, |
| 48 std::unique_ptr<ContentVerifierDelegate> delegate); | 55 std::unique_ptr<ContentVerifierDelegate> delegate); |
| 49 void Start(); | 56 void Start(); |
| 50 void Shutdown(); | 57 void Shutdown(); |
| 51 | 58 |
| 52 // Call this before reading a file within an extension. The caller owns the | 59 // Call this before reading a file within an extension. The caller owns the |
| 53 // returned job. | 60 // returned job. |
| 54 ContentVerifyJob* CreateJobFor(const std::string& extension_id, | 61 ContentVerifyJob* CreateJobFor(const std::string& extension_id, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // For observing the ExtensionRegistry. | 109 // For observing the ExtensionRegistry. |
| 103 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> observer_; | 110 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> observer_; |
| 104 | 111 |
| 105 // Data that should only be used on the IO thread. | 112 // Data that should only be used on the IO thread. |
| 106 scoped_refptr<ContentVerifierIOData> io_data_; | 113 scoped_refptr<ContentVerifierIOData> io_data_; |
| 107 }; | 114 }; |
| 108 | 115 |
| 109 } // namespace extensions | 116 } // namespace extensions |
| 110 | 117 |
| 111 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_H_ | 118 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_H_ |
| OLD | NEW |