OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // Adds a mapping between a path name and a resource to return. | 42 // Adds a mapping between a path name and a resource to return. |
43 void add_resource_path(const std::string &path, int resource_id) { | 43 void add_resource_path(const std::string &path, int resource_id) { |
44 path_to_idr_map_[path] = resource_id; | 44 path_to_idr_map_[path] = resource_id; |
45 } | 45 } |
46 | 46 |
47 // Sets the resource to returned when no other paths match. | 47 // Sets the resource to returned when no other paths match. |
48 void set_default_resource(int resource_id) { | 48 void set_default_resource(int resource_id) { |
49 default_resource_ = resource_id; | 49 default_resource_ = resource_id; |
50 } | 50 } |
51 | 51 |
| 52 protected: |
52 virtual ~ChromeWebUIDataSource(); | 53 virtual ~ChromeWebUIDataSource(); |
53 | 54 |
54 protected: | |
55 // Completes a request by sending our dictionary of localized strings. | 55 // Completes a request by sending our dictionary of localized strings. |
56 void SendLocalizedStringsAsJSON(int request_id); | 56 void SendLocalizedStringsAsJSON(int request_id); |
57 | 57 |
58 // Completes a request by sending the file specified by |idr|. | 58 // Completes a request by sending the file specified by |idr|. |
59 void SendFromResourceBundle(int request_id, int idr); | 59 void SendFromResourceBundle(int request_id, int idr); |
60 | 60 |
61 // ChromeURLDataManager | 61 // ChromeURLDataManager |
62 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; | 62 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; |
63 virtual void StartDataRequest(const std::string& path, | 63 virtual void StartDataRequest(const std::string& path, |
64 bool is_incognito, | 64 bool is_incognito, |
65 int request_id) OVERRIDE; | 65 int request_id) OVERRIDE; |
66 | 66 |
67 private: | 67 private: |
68 int default_resource_; | 68 int default_resource_; |
69 std::string json_path_; | 69 std::string json_path_; |
70 std::map<std::string, int> path_to_idr_map_; | 70 std::map<std::string, int> path_to_idr_map_; |
71 DictionaryValue localized_strings_; | 71 DictionaryValue localized_strings_; |
72 DISALLOW_COPY_AND_ASSIGN(ChromeWebUIDataSource); | 72 DISALLOW_COPY_AND_ASSIGN(ChromeWebUIDataSource); |
73 }; | 73 }; |
74 | 74 |
75 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ | 75 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_DATA_SOURCE_H_ |
OLD | NEW |