electron_api_crash_reporter_renderer.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2020 Slack Technologies, 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/mas.h"
  5. #include "shell/common/gin_helper/dictionary.h"
  6. #include "shell/common/node_includes.h"
  7. #if !IS_MAS_BUILD()
  8. #include "shell/common/crash_keys.h"
  9. #endif
  10. namespace {
  11. v8::Local<v8::Value> GetParameters(v8::Isolate* isolate) {
  12. std::map<std::string, std::string> keys;
  13. #if !IS_MAS_BUILD()
  14. electron::crash_keys::GetCrashKeys(&keys);
  15. #endif
  16. return gin::ConvertToV8(isolate, keys);
  17. }
  18. #if IS_MAS_BUILD()
  19. void SetCrashKeyStub(const std::string& key, const std::string& value) {}
  20. void ClearCrashKeyStub(const std::string& key) {}
  21. #endif
  22. void Initialize(v8::Local<v8::Object> exports,
  23. v8::Local<v8::Value> unused,
  24. v8::Local<v8::Context> context,
  25. void* priv) {
  26. gin_helper::Dictionary dict(context->GetIsolate(), exports);
  27. #if IS_MAS_BUILD()
  28. dict.SetMethod("addExtraParameter", &SetCrashKeyStub);
  29. dict.SetMethod("removeExtraParameter", &ClearCrashKeyStub);
  30. #else
  31. dict.SetMethod("addExtraParameter", &electron::crash_keys::SetCrashKey);
  32. dict.SetMethod("removeExtraParameter", &electron::crash_keys::ClearCrashKey);
  33. #endif
  34. dict.SetMethod("getParameters", &GetParameters);
  35. }
  36. } // namespace
  37. NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_crash_reporter, Initialize)