features.cc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 IsViewApiEnabled() {
  19. return BUILDFLAG(ENABLE_VIEWS_API);
  20. }
  21. bool IsPrintingEnabled() {
  22. return BUILDFLAG(ENABLE_PRINTING);
  23. }
  24. bool IsExtensionsEnabled() {
  25. return BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS);
  26. }
  27. bool IsComponentBuild() {
  28. #if defined(COMPONENT_BUILD)
  29. return true;
  30. #else
  31. return false;
  32. #endif
  33. }
  34. void Initialize(v8::Local<v8::Object> exports,
  35. v8::Local<v8::Value> unused,
  36. v8::Local<v8::Context> context,
  37. void* priv) {
  38. gin_helper::Dictionary dict(context->GetIsolate(), exports);
  39. dict.SetMethod("isBuiltinSpellCheckerEnabled", &IsBuiltinSpellCheckerEnabled);
  40. dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
  41. dict.SetMethod("isFakeLocationProviderEnabled",
  42. &IsFakeLocationProviderEnabled);
  43. dict.SetMethod("isViewApiEnabled", &IsViewApiEnabled);
  44. dict.SetMethod("isPrintingEnabled", &IsPrintingEnabled);
  45. dict.SetMethod("isComponentBuild", &IsComponentBuild);
  46. dict.SetMethod("isExtensionsEnabled", &IsExtensionsEnabled);
  47. }
  48. } // namespace
  49. NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_features, Initialize)