Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ios / public / provider / web / web_ui_ios.h
blob4a88043f23670b1e91d8a0f4406580fe67507611
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.
5 #ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_
6 #define IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/strings/string16.h"
14 class GURL;
16 namespace base {
17 class ListValue;
18 class Value;
21 namespace web {
23 class WebState;
24 class WebUIIOSController;
25 class WebUIIOSMessageHandler;
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);
37 virtual ~WebUIIOS() {}
39 virtual web::WebState* GetWebState() const = 0;
41 virtual WebUIIOSController* GetController() const = 0;
42 virtual void SetController(WebUIIOSController* controller) = 0;
44 // Takes ownership of |handler|, which will be destroyed when the WebUIIOS is.
45 virtual void AddMessageHandler(WebUIIOSMessageHandler* handler) = 0;
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;
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;
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;
85 } // namespace web
87 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_H_