Index: content/public/browser/web_ui_data_source.h |
=================================================================== |
--- content/public/browser/web_ui_data_source.h (revision 0) |
+++ content/public/browser/web_ui_data_source.h (revision 0) |
@@ -0,0 +1,73 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ |
+#define CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ |
+ |
+#include <string> |
+ |
+#include "content/common/content_export.h" |
+#include "base/callback.h" |
+ |
+class MessageLoop; |
+ |
+namespace base { |
+class RefCountedMemory; |
+} |
+/* |
+namespace content { |
+ |
+// A data source that can help with implementing the common operations needed by |
+// WebUI pages. |
+class URLDataSource { |
+ public: |
+ // Used as a parameter to GotDataCallback. The caller has to run this callback |
+ // with the result for the path that they filtered, passing ownership of the |
+ // memory. |
+ typedef base::Callback<void(base::RefCountedMemory*)> GotDataCallback; |
+ |
+ // Used by SetRequestFilter. The string parameter is the path of the request. |
+ // If the callee doesn't want to handle the data, false is returned. Otherwise |
+ // true is returned and the GotDataCallback parameter is called either then or |
+ // asynchronously with the response. |
+ typedef base::Callback<bool(const std::string&, const GotDataCallback&)> |
+ HandleRequestCallback; |
+ |
+ // Adds a string keyed to its name to our dictionary. |
+ void AddString(const std::string& name, const string16& value); |
+ |
+ // Adds a string keyed to its name to our dictionary. |
+ void AddString(const std::string& name, const std::string& value); |
+ |
+ // Adds a localized string with resource |ids| keyed to its name to our |
+ // dictionary. |
+ void AddLocalizedString(const std::string& name, int ids); |
+ |
+ // Add strings from |localized_strings| to our dictionary. |
+ void AddLocalizedStrings(const DictionaryValue& localized_strings); |
+ |
+ // Allows a caller to add a filter for URL requests. |
+ void SetRequestFilter(const HandleRequestCallback& callback); |
+ |
+ // Sets the path which will return the JSON strings. |
+ void set_json_path(const std::string& path) { json_path_ = path; } |
+ |
+ // Sets the data source to use a slightly different format for json data. Some |
+ // day this should become the default. |
+ void set_use_json_js_format_v2() { json_js_format_v2_ = true; } |
+ |
+ // Adds a mapping between a path name and a resource to return. |
+ void add_resource_path(const std::string &path, int resource_id) { |
+ path_to_idr_map_[path] = resource_id; |
+ } |
+ |
+ // Sets the resource to returned when no other paths match. |
+ void set_default_resource(int resource_id) { |
+ default_resource_ = resource_id; |
+ } |
+}; |
+ |
+} // namespace content |
+*/ |
+#endif // CONTENT_PUBLIC_BROWSER_WEB_UI_DATA_SOURCE_H_ |
Property changes on: content\public\browser\web_ui_data_source.h |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |