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

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

Issue 2533873003: Add throttling to corrupt policy extensions reinstall (Closed)
Patch Set: merge latest origin/master Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/extensions/chrome_content_verifier_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
9 #include <memory>
8 #include <set> 10 #include <set>
9 #include <string> 11 #include <string>
10 12
13 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 14 #include "base/macros.h"
12 #include "extensions/browser/content_verifier_delegate.h" 15 #include "extensions/browser/content_verifier_delegate.h"
13 16
14 namespace content { 17 namespace content {
15 class BrowserContext; 18 class BrowserContext;
16 } 19 }
17 20
21 namespace net {
22 class BackoffEntry;
23 }
24
18 namespace extensions { 25 namespace extensions {
19 26
20 class ChromeContentVerifierDelegate : public ContentVerifierDelegate { 27 class ChromeContentVerifierDelegate : public ContentVerifierDelegate {
21 public: 28 public:
22 static Mode GetDefaultMode(); 29 static Mode GetDefaultMode();
23 30
24 explicit ChromeContentVerifierDelegate(content::BrowserContext* context); 31 explicit ChromeContentVerifierDelegate(content::BrowserContext* context);
25 32
26 ~ChromeContentVerifierDelegate() override; 33 ~ChromeContentVerifierDelegate() override;
27 34
28 // ContentVerifierDelegate: 35 // ContentVerifierDelegate:
29 Mode ShouldBeVerified(const Extension& extension) override; 36 Mode ShouldBeVerified(const Extension& extension) override;
30 ContentVerifierKey GetPublicKey() override; 37 ContentVerifierKey GetPublicKey() override;
31 GURL GetSignatureFetchUrl(const std::string& extension_id, 38 GURL GetSignatureFetchUrl(const std::string& extension_id,
32 const base::Version& version) override; 39 const base::Version& version) override;
33 std::set<base::FilePath> GetBrowserImagePaths( 40 std::set<base::FilePath> GetBrowserImagePaths(
34 const extensions::Extension* extension) override; 41 const extensions::Extension* extension) override;
35 void VerifyFailed(const std::string& extension_id, 42 void VerifyFailed(const std::string& extension_id,
36 ContentVerifyJob::FailureReason reason) override; 43 ContentVerifyJob::FailureReason reason) override;
37 44
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
38 private: 52 private:
39 content::BrowserContext* context_; 53 content::BrowserContext* context_;
40 ContentVerifierDelegate::Mode default_mode_; 54 ContentVerifierDelegate::Mode default_mode_;
41 55
56 // This maps an extension id to a backoff entry for slowing down
57 // redownload/reinstall of corrupt policy extensions if it keeps happening
58 // in a loop (eg crbug.com/661738).
59 std::map<std::string, std::unique_ptr<net::BackoffEntry>>
60 policy_reinstall_backoff_;
61
42 // For reporting metrics in BOOTSTRAP mode, when an extension would be 62 // For reporting metrics in BOOTSTRAP mode, when an extension would be
43 // disabled if content verification was in ENFORCE mode. 63 // disabled if content verification was in ENFORCE mode.
44 std::set<std::string> would_be_disabled_ids_; 64 std::set<std::string> would_be_disabled_ids_;
45 65
46 DISALLOW_COPY_AND_ASSIGN(ChromeContentVerifierDelegate); 66 DISALLOW_COPY_AND_ASSIGN(ChromeContentVerifierDelegate);
47 }; 67 };
48 68
49 } // namespace extensions 69 } // namespace extensions
50 70
51 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_ 71 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/chrome_content_verifier_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698