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 5 #ifndef EXTENSIONS_RENDERER_I18N_HOOKS_DELEGATE_H_ 6 #define EXTENSIONS_RENDERER_I18N_HOOKS_DELEGATE_H_ 7 8 #include <vector> 9 10 #include "base/macros.h" 11 #include "extensions/renderer/bindings/api_binding_hooks_delegate.h" 12 #include "v8/include/v8.h" 13 14 namespace extensions { 15 class ScriptContext; 16 17 // Custom native hooks for the i18n API. 18 class I18nHooksDelegate : public APIBindingHooksDelegate { 19 public: 20 I18nHooksDelegate(); 21 ~I18nHooksDelegate() override; 22 23 // APIBindingHooksDelegate: 24 APIBindingHooks::RequestResult HandleRequest( 25 const std::string& method_name, 26 const APISignature* signature, 27 v8::Local<v8::Context> context, 28 std::vector<v8::Local<v8::Value>>* arguments, 29 const APITypeReferenceMap& refs) override; 30 31 private: 32 // Method handlers: 33 APIBindingHooks::RequestResult HandleGetMessage( 34 ScriptContext* script_context, 35 const std::vector<v8::Local<v8::Value>>& parsed_arguments); 36 APIBindingHooks::RequestResult HandleGetUILanguage( 37 ScriptContext* script_context, 38 const std::vector<v8::Local<v8::Value>>& parsed_arguments); 39 APIBindingHooks::RequestResult HandleDetectLanguage( 40 ScriptContext* script_context, 41 const std::vector<v8::Local<v8::Value>>& parsed_arguments); 42 43 DISALLOW_COPY_AND_ASSIGN(I18nHooksDelegate); 44 }; 45 46 } // namespace extensions 47 48 #endif // EXTENSIONS_RENDERER_I18N_HOOKS_DELEGATE_H_ 49