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_MESSAGE_HANDLER_H_
6 #define IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_MESSAGE_HANDLER_H_
8 #include "base/basictypes.h"
9 #include "base/strings/string16.h"
14 class DictionaryValue
;
23 // Messages sent from the DOM are forwarded via the WebUIIOS to handler
24 // classes. These objects are owned by WebUIIOS and destroyed when the
26 class WebUIIOSMessageHandler
{
28 WebUIIOSMessageHandler() : web_ui_(NULL
) {}
29 virtual ~WebUIIOSMessageHandler() {}
34 // Extract an integer value from a list Value.
35 static bool ExtractIntegerValue(const base::ListValue
* value
, int* out_int
);
37 // Extract a floating point (double) value from a list Value.
38 static bool ExtractDoubleValue(const base::ListValue
* value
,
41 // Extract a string value from a list Value.
42 static base::string16
ExtractStringValue(const base::ListValue
* value
);
44 // This is where subclasses specify which messages they'd like to handle and
45 // perform any additional initialization. At this point web_ui() will return
46 // the associated WebUIIOS object.
47 virtual void RegisterMessages() = 0;
49 // Returns the attached WebUIIOS for this handler.
50 WebUIIOS
* web_ui() const { return web_ui_
; }
52 // Sets the attached WebUIIOS - exposed to subclasses for testing purposes.
53 void set_web_ui(WebUIIOS
* web_ui
) { web_ui_
= web_ui
; }
56 // Provide external classes access to web_ui() and set_web_ui().
57 friend class WebUIIOSImpl
;
64 #endif // IOS_PUBLIC_PROVIDER_WEB_WEB_UI_IOS_MESSAGE_HANDLER_H_