features.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "electron/buildflags/buildflags.h"
  5. #include "printing/buildflags/buildflags.h"
  6. #include "shell/common/gin_helper/dictionary.h"
  7. #include "shell/common/node_includes.h"
  8. namespace {
  9. bool IsBuiltinSpellCheckerEnabled() {
  10. return BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER);
  11. }
  12. bool IsPDFViewerEnabled() {
  13. return BUILDFLAG(ENABLE_PDF_VIEWER);
  14. }
  15. bool IsFakeLocationProviderEnabled() {
  16. return BUILDFLAG(OVERRIDE_LOCATION_PROVIDER);
  17. }
  18. bool IsPrintingEnabled() {
  19. return BUILDFLAG(ENABLE_PRINTING);
  20. }
  21. bool IsExtensionsEnabled() {
  22. return BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS);
  23. }
  24. bool IsComponentBuild() {
  25. #if defined(COMPONENT_BUILD)
  26. return true;
  27. #else
  28. return false;
  29. #endif
  30. }
  31. void Initialize(v8::Local<v8::Object> exports,
  32. v8::Local<v8::Value> unused,
  33. v8::Local<v8::Context> context,
  34. void* priv) {
  35. gin_helper::Dictionary dict(context->GetIsolate(), exports);
  36. dict.SetMethod("isBuiltinSpellCheckerEnabled", &IsBuiltinSpellCheckerEnabled);
  37. dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
  38. dict.SetMethod("isFakeLocationProviderEnabled",
  39. &IsFakeLocationProviderEnabled);
  40. dict.SetMethod("isPrintingEnabled", &IsPrintingEnabled);
  41. dict.SetMethod("isComponentBuild", &IsComponentBuild);
  42. dict.SetMethod("isExtensionsEnabled", &IsExtensionsEnabled);
  43. }
  44. } // namespace
  45. NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_features, Initialize)