// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_ #define IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_ #include #include "base/compiler_specific.h" #include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "ios/public/provider/web/web_ui_ios.h" namespace web { class WebStateImpl; } namespace web { class WebUIIOSImpl : public web::WebUIIOS, public base::SupportsWeakPtr { public: explicit WebUIIOSImpl(WebStateImpl* web_state); ~WebUIIOSImpl() override; // WebUIIOS implementation: WebState* GetWebState() const override; WebUIIOSController* GetController() const override; void SetController(WebUIIOSController* controller) override; void AddMessageHandler(WebUIIOSMessageHandler* handler) override; typedef base::Callback MessageCallback; void RegisterMessageCallback(const std::string& message, const MessageCallback& callback) override; void ProcessWebUIIOSMessage(const GURL& source_url, const std::string& message, const base::ListValue& args) override; void CallJavascriptFunction(const std::string& function_name) override; void CallJavascriptFunction(const std::string& function_name, const base::Value& arg) override; void CallJavascriptFunction(const std::string& function_name, const base::Value& arg1, const base::Value& arg2) override; void CallJavascriptFunction(const std::string& function_name, const base::Value& arg1, const base::Value& arg2, const base::Value& arg3) override; void CallJavascriptFunction(const std::string& function_name, const base::Value& arg1, const base::Value& arg2, const base::Value& arg3, const base::Value& arg4) override; void CallJavascriptFunction( const std::string& function_name, const std::vector& args) override; private: // Executes JavaScript asynchronously on the page. void ExecuteJavascript(const base::string16& javascript); // A map of message name -> message handling callback. typedef std::map MessageCallbackMap; MessageCallbackMap message_callbacks_; // The WebUIIOSMessageHandlers we own. ScopedVector handlers_; // Non-owning pointer to the WebStateImpl this WebUIIOS is associated with. WebStateImpl* web_state_; scoped_ptr controller_; DISALLOW_COPY_AND_ASSIGN(WebUIIOSImpl); }; } // namespace web #endif // IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_