Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 <memory> | |
|
Devlin
2017/03/16 01:42:44
Needed?
michaelpg
2017/03/17 02:34:26
Done.
| |
| 9 #include <set> | |
| 10 #include <utility> | |
|
Devlin
2017/03/16 01:42:44
needed?
michaelpg
2017/03/17 02:34:26
Done.
| |
| 11 | |
| 12 #include "base/callback.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/strings/string16.h" | |
| 16 #include "extensions/common/extension.h" | |
|
Devlin
2017/03/16 01:42:44
nit: forward declaration instead of this include
michaelpg
2017/03/17 02:34:26
Done.
| |
| 17 | |
| 18 namespace extensions { | |
| 19 | |
| 20 // Encapsulates a possibly asynchronous operation to verify whether a | |
| 21 // precondition holds for loading the given extension. | |
| 22 class PreloadCheck { | |
| 23 public: | |
| 24 // These enumerators should only be referred to by name, so it is safe to | |
| 25 // insert or remove values as necessary. | |
| 26 enum Error { | |
| 27 NONE, | |
| 28 BLACKLISTED_ID, | |
| 29 BLACKLISTED_UNKNOWN, | |
| 30 DISALLOWED_BY_POLICY, | |
| 31 }; | |
| 32 | |
| 33 using Errors = std::set<Error>; | |
| 34 using ResultCallback = base::OnceCallback<void(Errors)>; | |
| 35 | |
| 36 explicit PreloadCheck(scoped_refptr<const Extension> extension); | |
| 37 virtual ~PreloadCheck(); | |
| 38 | |
| 39 // This function must be called on the UI thread. The callback also occurs on | |
| 40 // the UI thread. | |
| 41 virtual void Start(ResultCallback callback) = 0; | |
| 42 | |
| 43 // Subclasses may provide an error message. | |
| 44 virtual base::string16 GetErrorMessage() const; | |
| 45 | |
| 46 const Extension* extension() { return extension_.get(); } | |
| 47 | |
| 48 private: | |
| 49 // The extension to check. | |
| 50 scoped_refptr<const Extension> extension_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(PreloadCheck); | |
| 53 }; | |
| 54 | |
| 55 } // namespace extensions | |
| 56 | |
| 57 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_H_ | |
| OLD | NEW |