electron_api_crash_reporter_renderer.cc 1.3 KB

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