| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_ | 5 #ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_ |
| 6 #define IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_ | 6 #define IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 // TODO(crbug.com/524467): Remove this file once downstream code is switched to |
| 9 | 9 // use correct header. |
| 10 #include "base/callback.h" | 10 #include "ios/web/public/webui/web_ui_ios.h" |
| 11 #include "base/strings/string16.h" | |
| 12 | |
| 13 class GURL; | |
| 14 | |
| 15 namespace base { | |
| 16 class ListValue; | |
| 17 class Value; | |
| 18 } | |
| 19 | |
| 20 namespace web { | |
| 21 | |
| 22 class WebState; | |
| 23 class WebUIIOSController; | |
| 24 class WebUIIOSMessageHandler; | |
| 25 | |
| 26 // A WebUIIOS sets up the datasources and message handlers for a given | |
| 27 // HTML-based UI. | |
| 28 class WebUIIOS { | |
| 29 public: | |
| 30 // Returns JavaScript code that, when executed, calls the function specified | |
| 31 // by |function_name| with the arguments specified in |arg_list|. | |
| 32 static base::string16 GetJavascriptCall( | |
| 33 const std::string& function_name, | |
| 34 const std::vector<const base::Value*>& arg_list); | |
| 35 | |
| 36 virtual ~WebUIIOS() {} | |
| 37 | |
| 38 virtual web::WebState* GetWebState() const = 0; | |
| 39 | |
| 40 virtual WebUIIOSController* GetController() const = 0; | |
| 41 virtual void SetController(WebUIIOSController* controller) = 0; | |
| 42 | |
| 43 // Takes ownership of |handler|, which will be destroyed when the WebUIIOS is. | |
| 44 virtual void AddMessageHandler(WebUIIOSMessageHandler* handler) = 0; | |
| 45 | |
| 46 // Used by WebUIIOSMessageHandlers. If the given message is already | |
| 47 // registered, the call has no effect unless |register_callback_overwrites_| | |
| 48 // is set to true. | |
| 49 typedef base::Callback<void(const base::ListValue*)> MessageCallback; | |
| 50 virtual void RegisterMessageCallback(const std::string& message, | |
| 51 const MessageCallback& callback) = 0; | |
| 52 | |
| 53 // This is only needed if an embedder overrides handling of a WebUIIOSMessage | |
| 54 // and then later wants to undo that, or to route it to a different WebUIIOS | |
| 55 // object. | |
| 56 virtual void ProcessWebUIIOSMessage(const GURL& source_url, | |
| 57 const std::string& message, | |
| 58 const base::ListValue& args) = 0; | |
| 59 | |
| 60 // Call a Javascript function. This is asynchronous; there's no way to get | |
| 61 // the result of the call, and should be thought of more like sending a | |
| 62 // message to the page. All function names in WebUI must consist of only | |
| 63 // ASCII characters. There are variants for calls with more arguments. | |
| 64 virtual void CallJavascriptFunction(const std::string& function_name) = 0; | |
| 65 virtual void CallJavascriptFunction(const std::string& function_name, | |
| 66 const base::Value& arg) = 0; | |
| 67 virtual void CallJavascriptFunction(const std::string& function_name, | |
| 68 const base::Value& arg1, | |
| 69 const base::Value& arg2) = 0; | |
| 70 virtual void CallJavascriptFunction(const std::string& function_name, | |
| 71 const base::Value& arg1, | |
| 72 const base::Value& arg2, | |
| 73 const base::Value& arg3) = 0; | |
| 74 virtual void CallJavascriptFunction(const std::string& function_name, | |
| 75 const base::Value& arg1, | |
| 76 const base::Value& arg2, | |
| 77 const base::Value& arg3, | |
| 78 const base::Value& arg4) = 0; | |
| 79 virtual void CallJavascriptFunction( | |
| 80 const std::string& function_name, | |
| 81 const std::vector<const base::Value*>& args) = 0; | |
| 82 }; | |
| 83 | |
| 84 } // namespace web | |
| 85 | 11 |
| 86 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_ | 12 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_ |
| OLD | NEW |