features.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright (c) 2018 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "atom/common/node_includes.h"
  5. #include "native_mate/dictionary.h"
  6. namespace {
  7. bool IsDesktopCapturerEnabled() {
  8. #if defined(ENABLE_DESKTOP_CAPTURER)
  9. return true;
  10. #else
  11. return false;
  12. #endif
  13. }
  14. bool IsOffscreenRenderingEnabled() {
  15. #if defined(ENABLE_OSR)
  16. return true;
  17. #else
  18. return false;
  19. #endif
  20. }
  21. bool IsPDFViewerEnabled() {
  22. #if defined(ENABLE_PDF_VIEWER)
  23. return true;
  24. #else
  25. return false;
  26. #endif
  27. }
  28. bool IsFakeLocationProviderEnabled() {
  29. #if defined(OVERRIDE_LOCATION_PROVIDER)
  30. return true;
  31. #else
  32. return false;
  33. #endif
  34. }
  35. bool IsViewApiEnabled() {
  36. #if defined(ENABLE_VIEW_API)
  37. return true;
  38. #else
  39. return false;
  40. #endif
  41. }
  42. void Initialize(v8::Local<v8::Object> exports,
  43. v8::Local<v8::Value> unused,
  44. v8::Local<v8::Context> context,
  45. void* priv) {
  46. mate::Dictionary dict(context->GetIsolate(), exports);
  47. dict.SetMethod("isDesktopCapturerEnabled", &IsDesktopCapturerEnabled);
  48. dict.SetMethod("isOffscreenRenderingEnabled", &IsOffscreenRenderingEnabled);
  49. dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
  50. dict.SetMethod("isFakeLocationProviderEnabled",
  51. &IsFakeLocationProviderEnabled);
  52. dict.SetMethod("isViewApiEnabled", &IsViewApiEnabled);
  53. }
  54. } // namespace
  55. NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_features, Initialize)