| 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_MESSAGE_HANDLER_H_ | 5 #ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_MESSAGE_HANDLER_H_ |
| 6 #define IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_MESSAGE_HANDLER_H_ | 6 #define IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_MESSAGE_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/strings/string16.h" | 8 // TODO(crbug.com/524467): Remove this file once downstream code is switched to |
| 9 | 9 // use correct header. |
| 10 class GURL; | 10 #include "ios/web/public/webui/web_ui_ios_message_handler.h" |
| 11 | |
| 12 namespace base { | |
| 13 class DictionaryValue; | |
| 14 class ListValue; | |
| 15 } | |
| 16 | |
| 17 namespace web { | |
| 18 | |
| 19 class WebUIIOS; | |
| 20 class WebUIIOSImpl; | |
| 21 | |
| 22 // Messages sent from the DOM are forwarded via the WebUIIOS to handler | |
| 23 // classes. These objects are owned by WebUIIOS and destroyed when the | |
| 24 // host is destroyed. | |
| 25 class WebUIIOSMessageHandler { | |
| 26 public: | |
| 27 WebUIIOSMessageHandler() : web_ui_(NULL) {} | |
| 28 virtual ~WebUIIOSMessageHandler() {} | |
| 29 | |
| 30 protected: | |
| 31 // Helper methods: | |
| 32 | |
| 33 // Extract an integer value from a list Value. | |
| 34 static bool ExtractIntegerValue(const base::ListValue* value, int* out_int); | |
| 35 | |
| 36 // Extract a floating point (double) value from a list Value. | |
| 37 static bool ExtractDoubleValue(const base::ListValue* value, | |
| 38 double* out_value); | |
| 39 | |
| 40 // Extract a string value from a list Value. | |
| 41 static base::string16 ExtractStringValue(const base::ListValue* value); | |
| 42 | |
| 43 // This is where subclasses specify which messages they'd like to handle and | |
| 44 // perform any additional initialization. At this point web_ui() will return | |
| 45 // the associated WebUIIOS object. | |
| 46 virtual void RegisterMessages() = 0; | |
| 47 | |
| 48 // Returns the attached WebUIIOS for this handler. | |
| 49 WebUIIOS* web_ui() const { return web_ui_; } | |
| 50 | |
| 51 // Sets the attached WebUIIOS - exposed to subclasses for testing purposes. | |
| 52 void set_web_ui(WebUIIOS* web_ui) { web_ui_ = web_ui; } | |
| 53 | |
| 54 private: | |
| 55 // Provide external classes access to web_ui() and set_web_ui(). | |
| 56 friend class WebUIIOSImpl; | |
| 57 | |
| 58 WebUIIOS* web_ui_; | |
| 59 }; | |
| 60 | |
| 61 } // namespace web | |
| 62 | 11 |
| 63 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_MESSAGE_HANDLER_H_ | 12 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_MESSAGE_HANDLER_H_ |
| OLD | NEW |