set_icon_natives.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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_SET_ICON_NATIVES_H_
  5. #define EXTENSIONS_RENDERER_SET_ICON_NATIVES_H_
  6. #include "extensions/renderer/object_backed_native_handler.h"
  7. #include "v8/include/v8-forward.h"
  8. namespace extensions {
  9. class ScriptContext;
  10. // Functions exposed to extension JS to implement the setIcon extension API.
  11. class SetIconNatives : public ObjectBackedNativeHandler {
  12. public:
  13. explicit SetIconNatives(ScriptContext* context);
  14. SetIconNatives(const SetIconNatives&) = delete;
  15. SetIconNatives& operator=(const SetIconNatives&) = delete;
  16. // ObjectBackedNativeHandler:
  17. void AddRoutes() override;
  18. private:
  19. bool ConvertImageDataToBitmapValue(const v8::Local<v8::Object> image_data,
  20. v8::Local<v8::Value>* image_data_bitmap);
  21. bool ConvertImageDataSetToBitmapValueSet(
  22. v8::Local<v8::Object>& details,
  23. v8::Local<v8::Object>* bitmap_set_value);
  24. void SetIconCommon(const v8::FunctionCallbackInfo<v8::Value>& args);
  25. // Determines if the associated script context is for a ServiceWorker.
  26. void IsInServiceWorker(const v8::FunctionCallbackInfo<v8::Value>& args);
  27. };
  28. } // namespace extensions
  29. #endif // EXTENSIONS_RENDERER_SET_ICON_NATIVES_H_