Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/browser/extensions/chrome_content_verifier_delegate.h

Issue 2790823004: Retry reinstallation of corrupted policy extensions. (Closed)
Patch Set: address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "extensions/browser/content_verifier_delegate.h" 15 #include "extensions/browser/content_verifier_delegate.h"
16 16
17 namespace content { 17 namespace content {
18 class BrowserContext; 18 class BrowserContext;
19 } 19 }
20 20
21 namespace net { 21 namespace net {
22 class BackoffEntry; 22 class BackoffEntry;
23 } 23 }
24 24
25 namespace extensions { 25 namespace extensions {
26 26
27 class PolicyExtensionReinstaller;
28
27 class ChromeContentVerifierDelegate : public ContentVerifierDelegate { 29 class ChromeContentVerifierDelegate : public ContentVerifierDelegate {
28 public: 30 public:
29 static Mode GetDefaultMode(); 31 static Mode GetDefaultMode();
30 32
31 explicit ChromeContentVerifierDelegate(content::BrowserContext* context); 33 explicit ChromeContentVerifierDelegate(content::BrowserContext* context);
32 34
33 ~ChromeContentVerifierDelegate() override; 35 ~ChromeContentVerifierDelegate() override;
34 36
35 // ContentVerifierDelegate: 37 // ContentVerifierDelegate:
36 Mode ShouldBeVerified(const Extension& extension) override; 38 Mode ShouldBeVerified(const Extension& extension) override;
37 ContentVerifierKey GetPublicKey() override; 39 ContentVerifierKey GetPublicKey() override;
38 GURL GetSignatureFetchUrl(const std::string& extension_id, 40 GURL GetSignatureFetchUrl(const std::string& extension_id,
39 const base::Version& version) override; 41 const base::Version& version) override;
40 std::set<base::FilePath> GetBrowserImagePaths( 42 std::set<base::FilePath> GetBrowserImagePaths(
41 const extensions::Extension* extension) override; 43 const extensions::Extension* extension) override;
42 void VerifyFailed(const std::string& extension_id, 44 void VerifyFailed(const std::string& extension_id,
43 ContentVerifyJob::FailureReason reason) override; 45 ContentVerifyJob::FailureReason reason) override;
44 46 void Shutdown() override;
45 protected:
46 FRIEND_TEST_ALL_PREFIXES(ContentVerifierPolicyTest, Backoff);
47 // For tests, overrides the default action to take to initiate policy
48 // force-reinstalls.
49 static void set_policy_reinstall_action_for_test(
50 base::Callback<void(base::TimeDelta delay)>* action);
51 47
52 private: 48 private:
53 content::BrowserContext* context_; 49 content::BrowserContext* context_;
54 ContentVerifierDelegate::Mode default_mode_; 50 ContentVerifierDelegate::Mode default_mode_;
55 51
56 // This maps an extension id to a backoff entry for slowing down 52 // This maps an extension id to a backoff entry for slowing down
57 // redownload/reinstall of corrupt policy extensions if it keeps happening 53 // redownload/reinstall of corrupt policy extensions if it keeps happening
58 // in a loop (eg crbug.com/661738). 54 // in a loop (eg crbug.com/661738).
59 std::map<std::string, std::unique_ptr<net::BackoffEntry>> 55 std::map<std::string, std::unique_ptr<net::BackoffEntry>>
60 policy_reinstall_backoff_; 56 policy_reinstall_backoff_;
61 57
62 // For reporting metrics in BOOTSTRAP mode, when an extension would be 58 // For reporting metrics in BOOTSTRAP mode, when an extension would be
63 // disabled if content verification was in ENFORCE mode. 59 // disabled if content verification was in ENFORCE mode.
64 std::set<std::string> would_be_disabled_ids_; 60 std::set<std::string> would_be_disabled_ids_;
65 61
62 std::unique_ptr<PolicyExtensionReinstaller> policy_extension_reinstaller_;
63
66 DISALLOW_COPY_AND_ASSIGN(ChromeContentVerifierDelegate); 64 DISALLOW_COPY_AND_ASSIGN(ChromeContentVerifierDelegate);
67 }; 65 };
68 66
69 } // namespace extensions 67 } // namespace extensions
70 68
71 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_ 69 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/BUILD.gn ('k') | chrome/browser/extensions/chrome_content_verifier_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698