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

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

Issue 2768723002: Update ExtensionInstallChecker to use PreloadCheck classes (Closed)
Patch Set: remove redundant DCHECKs that fail in tests Created 3 years, 9 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 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_CHECKER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_CHECKER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_CHECKER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_CHECKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "extensions/browser/blacklist_state.h" 16 #include "extensions/browser/preload_check.h"
17 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
18 18
19 class Profile; 19 class Profile;
20 20
21 namespace extensions { 21 namespace extensions {
22 22
23 class RequirementsChecker; 23 class RequirementsChecker;
24 24
25 // Performs common checks for validating whether an extension may be installed. 25 // Performs common checks for validating whether an extension may be installed.
26 // This class should be Start()-ed at most once. 26 // This class should be Start()-ed at most once.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // Returns true if any checks are currently running. 60 // Returns true if any checks are currently running.
61 bool is_running() const { return running_checks_ != 0; } 61 bool is_running() const { return running_checks_ != 0; }
62 62
63 // Returns the requirement violations. A non-empty list is considered to be 63 // Returns the requirement violations. A non-empty list is considered to be
64 // a check failure. 64 // a check failure.
65 const std::vector<std::string>& requirement_errors() const { 65 const std::vector<std::string>& requirement_errors() const {
66 return requirement_errors_; 66 return requirement_errors_;
67 } 67 }
68 68
69 // Returns the blacklist state of the extension. A blacklist state of 69 // Returns the blacklist error of the extension. Note that there is only an
70 // BLACKLISTED_MALWARE is considered to be a check failure. 70 // error if the BlacklistState is BLACKLISTED_MALWARE or BLACKLISTED_UNKNOWN.
71 BlacklistState blacklist_state() const { return blacklist_state_; } 71 PreloadCheck::Error blacklist_error() const { return blacklist_error_; }
72 72
73 // Returns whether management policy permits installation of the extension. 73 // Returns whether management policy permits installation of the extension.
74 bool policy_allows_load() const { return policy_allows_load_; }
75 const std::string& policy_error() const { return policy_error_; } 74 const std::string& policy_error() const { return policy_error_; }
76 75
76 void SetBlacklistCheckForTesting(std::unique_ptr<PreloadCheck> policy_check) {
77 blacklist_check_ = std::move(policy_check);
78 }
79 void SetPolicyCheckForTesting(std::unique_ptr<PreloadCheck> policy_check) {
80 policy_check_ = std::move(policy_check);
81 }
82
77 protected: 83 protected:
78 virtual void CheckManagementPolicy(); 84 virtual void CheckManagementPolicy();
79 void OnManagementPolicyCheckDone(bool allows_load, const std::string& error); 85 void OnManagementPolicyCheckDone(PreloadCheck::Errors errors);
80 86
81 virtual void CheckRequirements(); 87 virtual void CheckRequirements();
82 void OnRequirementsCheckDone(const std::vector<std::string>& errors); 88 void OnRequirementsCheckDone(const std::vector<std::string>& errors);
83 89
84 virtual void CheckBlacklistState(); 90 virtual void CheckBlacklistState();
85 void OnBlacklistStateCheckDone(BlacklistState state); 91 void OnBlacklistStateCheckDone(PreloadCheck::Errors errors);
86 92
87 private: 93 private:
88 void MaybeInvokeCallback(); 94 void MaybeInvokeCallback();
89 95
90 std::unique_ptr<RequirementsChecker> requirements_checker_;
91
92 // The Profile where the extension is being installed in. 96 // The Profile where the extension is being installed in.
93 Profile* profile_; 97 Profile* profile_;
94 98
95 // The extension to run checks for. 99 // The extension to run checks for.
96 scoped_refptr<const Extension> extension_; 100 scoped_refptr<const Extension> extension_;
97 101
98 // Requirement violations. 102 // Checks requirements specified in the manifest.
103 std::unique_ptr<RequirementsChecker> requirements_checker_;
99 std::vector<std::string> requirement_errors_; 104 std::vector<std::string> requirement_errors_;
100 105
101 // Result of the blacklist state check. 106 // Checks if the extension is blacklisted.
102 BlacklistState blacklist_state_; 107 std::unique_ptr<PreloadCheck> blacklist_check_;
108 PreloadCheck::Error blacklist_error_ = PreloadCheck::NONE;
103 109
104 // Whether the extension can be installed, according to management policies. 110 // Checks whether management policies allow the extension to be installed.
105 bool policy_allows_load_; 111 std::unique_ptr<PreloadCheck> policy_check_;
106 std::string policy_error_; 112 std::string policy_error_;
107 113
108 // Bitmask of enabled checks. 114 // Bitmask of enabled checks.
109 int enabled_checks_; 115 int enabled_checks_;
110 116
111 // Bitmask of currently running checks. 117 // Bitmask of currently running checks.
112 // TODO(michaelpg): Consolidate this with enabled_checks_. 118 // TODO(michaelpg): Consolidate this with enabled_checks_.
113 int running_checks_; 119 int running_checks_;
114 120
115 // If true, the callback is invoked when the first check fails. 121 // If true, the callback is invoked when the first check fails.
116 bool fail_fast_; 122 bool fail_fast_;
117 123
118 // The callback to invoke when checks are complete. 124 // The callback to invoke when checks are complete.
119 Callback callback_; 125 Callback callback_;
120 126
121 base::WeakPtrFactory<ExtensionInstallChecker> weak_ptr_factory_; 127 base::WeakPtrFactory<ExtensionInstallChecker> weak_ptr_factory_;
122 128
123 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallChecker); 129 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallChecker);
124 }; 130 };
125 131
126 } // namespace extensions 132 } // namespace extensions
127 133
128 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_CHECKER_H_ 134 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_CHECKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/crx_installer.cc ('k') | chrome/browser/extensions/extension_install_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698