Add ICU message format support
[chromium-blink-merge.git] / ios / web / webui / web_ui_ios_impl.h
blob20b0fc3ef734cc5318785dd5d3acbb7802c14628
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_WEB_WEBUI_WEB_UI_IOS_IMPL_H_
6 #define IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_
8 #include <map>
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ios/public/provider/web/web_ui_ios.h"
15 namespace web {
16 class WebStateImpl;
19 namespace web {
21 class WebUIIOSImpl : public web::WebUIIOS,
22 public base::SupportsWeakPtr<WebUIIOSImpl> {
23 public:
24 explicit WebUIIOSImpl(WebStateImpl* web_state);
25 ~WebUIIOSImpl() override;
27 // WebUIIOS implementation:
28 WebState* GetWebState() const override;
29 WebUIIOSController* GetController() const override;
30 void SetController(WebUIIOSController* controller) override;
31 void AddMessageHandler(WebUIIOSMessageHandler* handler) override;
32 typedef base::Callback<void(const base::ListValue*)> MessageCallback;
33 void RegisterMessageCallback(const std::string& message,
34 const MessageCallback& callback) override;
35 void ProcessWebUIIOSMessage(const GURL& source_url,
36 const std::string& message,
37 const base::ListValue& args) override;
38 void CallJavascriptFunction(const std::string& function_name) override;
39 void CallJavascriptFunction(const std::string& function_name,
40 const base::Value& arg) override;
41 void CallJavascriptFunction(const std::string& function_name,
42 const base::Value& arg1,
43 const base::Value& arg2) override;
44 void CallJavascriptFunction(const std::string& function_name,
45 const base::Value& arg1,
46 const base::Value& arg2,
47 const base::Value& arg3) override;
48 void CallJavascriptFunction(const std::string& function_name,
49 const base::Value& arg1,
50 const base::Value& arg2,
51 const base::Value& arg3,
52 const base::Value& arg4) override;
53 void CallJavascriptFunction(
54 const std::string& function_name,
55 const std::vector<const base::Value*>& args) override;
57 private:
58 // Executes JavaScript asynchronously on the page.
59 void ExecuteJavascript(const base::string16& javascript);
61 // A map of message name -> message handling callback.
62 typedef std::map<std::string, MessageCallback> MessageCallbackMap;
63 MessageCallbackMap message_callbacks_;
65 // The WebUIIOSMessageHandlers we own.
66 ScopedVector<WebUIIOSMessageHandler> handlers_;
68 // Non-owning pointer to the WebStateImpl this WebUIIOS is associated with.
69 WebStateImpl* web_state_;
71 scoped_ptr<WebUIIOSController> controller_;
73 DISALLOW_COPY_AND_ASSIGN(WebUIIOSImpl);
76 } // namespace web
78 #endif // IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_