activity_log_converter_strategy.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef EXTENSIONS_RENDERER_ACTIVITY_LOG_CONVERTER_STRATEGY_H_
  5. #define EXTENSIONS_RENDERER_ACTIVITY_LOG_CONVERTER_STRATEGY_H_
  6. #include "base/compiler_specific.h"
  7. #include "content/public/renderer/v8_value_converter.h"
  8. #include "v8/include/v8-forward.h"
  9. namespace extensions {
  10. // This class is used by activity logger and extends behavior of
  11. // V8ValueConverter. It overwrites conversion of V8 arrays and objects. When
  12. // converting arrays and objects, we must not invoke any JS code which may
  13. // result in triggering activity logger. In such case, the log entries will be
  14. // generated due to V8 object conversion rather than extension activity.
  15. class ActivityLogConverterStrategy
  16. : public content::V8ValueConverter::Strategy {
  17. public:
  18. ActivityLogConverterStrategy();
  19. ActivityLogConverterStrategy(const ActivityLogConverterStrategy&) = delete;
  20. ActivityLogConverterStrategy& operator=(const ActivityLogConverterStrategy&) =
  21. delete;
  22. ~ActivityLogConverterStrategy() override;
  23. // content::V8ValueConverter::Strategy implementation.
  24. bool FromV8Object(v8::Local<v8::Object> value,
  25. std::unique_ptr<base::Value>* out,
  26. v8::Isolate* isolate) override;
  27. bool FromV8Array(v8::Local<v8::Array> value,
  28. std::unique_ptr<base::Value>* out,
  29. v8::Isolate* isolate) override;
  30. private:
  31. bool FromV8Internal(v8::Local<v8::Object> value,
  32. std::unique_ptr<base::Value>* out,
  33. v8::Isolate* isolate) const;
  34. };
  35. } // namespace extensions
  36. #endif // EXTENSIONS_RENDERER_ACTIVITY_LOG_CONVERTER_STRATEGY_H_