i18n_hooks_delegate.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2018 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_I18N_HOOKS_DELEGATE_H_
  5. #define EXTENSIONS_RENDERER_I18N_HOOKS_DELEGATE_H_
  6. #include <vector>
  7. #include "extensions/renderer/bindings/api_binding_hooks_delegate.h"
  8. #include "extensions/renderer/bindings/api_signature.h"
  9. #include "v8/include/v8-forward.h"
  10. namespace extensions {
  11. class ScriptContext;
  12. // Custom native hooks for the i18n API.
  13. class I18nHooksDelegate : public APIBindingHooksDelegate {
  14. public:
  15. I18nHooksDelegate();
  16. I18nHooksDelegate(const I18nHooksDelegate&) = delete;
  17. I18nHooksDelegate& operator=(const I18nHooksDelegate&) = delete;
  18. ~I18nHooksDelegate() override;
  19. // APIBindingHooksDelegate:
  20. APIBindingHooks::RequestResult HandleRequest(
  21. const std::string& method_name,
  22. const APISignature* signature,
  23. v8::Local<v8::Context> context,
  24. std::vector<v8::Local<v8::Value>>* arguments,
  25. const APITypeReferenceMap& refs) override;
  26. private:
  27. // Method handlers:
  28. APIBindingHooks::RequestResult HandleGetMessage(
  29. ScriptContext* script_context,
  30. const APISignature::V8ParseResult& parse_result);
  31. APIBindingHooks::RequestResult HandleGetUILanguage(
  32. ScriptContext* script_context,
  33. const APISignature::V8ParseResult& parse_result);
  34. APIBindingHooks::RequestResult HandleDetectLanguage(
  35. ScriptContext* script_context,
  36. const APISignature::V8ParseResult& parse_result);
  37. };
  38. } // namespace extensions
  39. #endif // EXTENSIONS_RENDERER_I18N_HOOKS_DELEGATE_H_