| 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_WEB_WEBUI_WEB_UI_IOS_IMPL_H_ | 5 #ifndef IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_ |
| 6 #define IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_ | 6 #define IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_vector.h" | |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "ios/web/public/webui/web_ui_ios.h" | 15 #include "ios/web/public/webui/web_ui_ios.h" |
| 16 | 16 |
| 17 namespace web { | 17 namespace web { |
| 18 class WebStateImpl; | 18 class WebStateImpl; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace web { | 21 namespace web { |
| 22 | 22 |
| 23 class WebUIIOSImpl : public web::WebUIIOS, | 23 class WebUIIOSImpl : public web::WebUIIOS, |
| 24 public base::SupportsWeakPtr<WebUIIOSImpl> { | 24 public base::SupportsWeakPtr<WebUIIOSImpl> { |
| 25 public: | 25 public: |
| 26 explicit WebUIIOSImpl(WebStateImpl* web_state); | 26 explicit WebUIIOSImpl(WebStateImpl* web_state); |
| 27 ~WebUIIOSImpl() override; | 27 ~WebUIIOSImpl() override; |
| 28 | 28 |
| 29 // WebUIIOS implementation: | 29 // WebUIIOS implementation: |
| 30 WebState* GetWebState() const override; | 30 WebState* GetWebState() const override; |
| 31 WebUIIOSController* GetController() const override; | 31 WebUIIOSController* GetController() const override; |
| 32 void SetController(WebUIIOSController* controller) override; | 32 void SetController(WebUIIOSController* controller) override; |
| 33 void AddMessageHandler(WebUIIOSMessageHandler* handler) override; | 33 void AddMessageHandler( |
| 34 std::unique_ptr<WebUIIOSMessageHandler> handler) override; |
| 34 typedef base::Callback<void(const base::ListValue*)> MessageCallback; | 35 typedef base::Callback<void(const base::ListValue*)> MessageCallback; |
| 35 void RegisterMessageCallback(const std::string& message, | 36 void RegisterMessageCallback(const std::string& message, |
| 36 const MessageCallback& callback) override; | 37 const MessageCallback& callback) override; |
| 37 void ProcessWebUIIOSMessage(const GURL& source_url, | 38 void ProcessWebUIIOSMessage(const GURL& source_url, |
| 38 const std::string& message, | 39 const std::string& message, |
| 39 const base::ListValue& args) override; | 40 const base::ListValue& args) override; |
| 40 void CallJavascriptFunction(const std::string& function_name) override; | 41 void CallJavascriptFunction(const std::string& function_name) override; |
| 41 void CallJavascriptFunction(const std::string& function_name, | 42 void CallJavascriptFunction(const std::string& function_name, |
| 42 const base::Value& arg) override; | 43 const base::Value& arg) override; |
| 43 void CallJavascriptFunction(const std::string& function_name, | 44 void CallJavascriptFunction(const std::string& function_name, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 // Executes JavaScript asynchronously on the page. | 61 // Executes JavaScript asynchronously on the page. |
| 61 void ExecuteJavascript(const base::string16& javascript); | 62 void ExecuteJavascript(const base::string16& javascript); |
| 62 | 63 |
| 63 // A map of message name -> message handling callback. | 64 // A map of message name -> message handling callback. |
| 64 typedef std::map<std::string, MessageCallback> MessageCallbackMap; | 65 typedef std::map<std::string, MessageCallback> MessageCallbackMap; |
| 65 MessageCallbackMap message_callbacks_; | 66 MessageCallbackMap message_callbacks_; |
| 66 | 67 |
| 67 // The WebUIIOSMessageHandlers we own. | 68 // The WebUIIOSMessageHandlers we own. |
| 68 ScopedVector<WebUIIOSMessageHandler> handlers_; | 69 std::vector<std::unique_ptr<WebUIIOSMessageHandler>> handlers_; |
| 69 | 70 |
| 70 // Non-owning pointer to the WebStateImpl this WebUIIOS is associated with. | 71 // Non-owning pointer to the WebStateImpl this WebUIIOS is associated with. |
| 71 WebStateImpl* web_state_; | 72 WebStateImpl* web_state_; |
| 72 | 73 |
| 73 std::unique_ptr<WebUIIOSController> controller_; | 74 std::unique_ptr<WebUIIOSController> controller_; |
| 74 | 75 |
| 75 DISALLOW_COPY_AND_ASSIGN(WebUIIOSImpl); | 76 DISALLOW_COPY_AND_ASSIGN(WebUIIOSImpl); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace web | 79 } // namespace web |
| 79 | 80 |
| 80 #endif // IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_ | 81 #endif // IOS_WEB_WEBUI_WEB_UI_IOS_IMPL_H_ |
| OLD | NEW |