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

Side by Side Diff: extensions/browser/preload_check.h

Issue 2693373003: PreloadCheck class for extension pre-install checks (Closed)
Patch Set: don't break enable_extensions=false 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
« no previous file with comments | « extensions/browser/policy_check_unittest.cc ('k') | extensions/browser/preload_check.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 EXTENSIONS_BROWSER_PRELOAD_CHECK_H_
6 #define EXTENSIONS_BROWSER_PRELOAD_CHECK_H_
7
8 #include <set>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/strings/string16.h"
14
15 namespace extensions {
16
17 class Extension;
18
19 // Encapsulates a possibly asynchronous operation to verify whether a
20 // precondition holds for loading the given extension.
21 class PreloadCheck {
22 public:
23 // These enumerators should only be referred to by name, so it is safe to
24 // insert or remove values as necessary.
25 enum Error {
26 NONE,
27 BLACKLISTED_ID,
28 BLACKLISTED_UNKNOWN,
29 DISALLOWED_BY_POLICY,
30 };
31
32 using Errors = std::set<Error>;
33 using ResultCallback = base::OnceCallback<void(Errors)>;
34
35 explicit PreloadCheck(scoped_refptr<const Extension> extension);
36 virtual ~PreloadCheck();
37
38 // This function must be called on the UI thread. The callback also occurs on
39 // the UI thread.
40 virtual void Start(ResultCallback callback) = 0;
41
42 // Subclasses may provide an error message.
43 virtual base::string16 GetErrorMessage() const;
44
45 const Extension* extension() { return extension_.get(); }
46
47 private:
48 // The extension to check.
49 scoped_refptr<const Extension> extension_;
50
51 DISALLOW_COPY_AND_ASSIGN(PreloadCheck);
52 };
53
54 } // namespace extensions
55
56 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_H_
OLDNEW
« no previous file with comments | « extensions/browser/policy_check_unittest.cc ('k') | extensions/browser/preload_check.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698