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