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