OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
6 #define CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 6 #define CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/task.h" | 12 #include "base/task.h" |
13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
14 | 14 |
15 class DictionaryValue; | 15 class DictionaryValue; |
16 class FilePath; | 16 class FilePath; |
17 class GURL; | 17 class GURL; |
18 class MessageLoop; | 18 class MessageLoop; |
19 class RefCountedMemory; | 19 class RefCountedMemory; |
| 20 class URLRequestChromeJob; |
| 21 |
| 22 namespace net { |
20 class URLRequest; | 23 class URLRequest; |
21 class URLRequestChromeJob; | |
22 class URLRequestJob; | 24 class URLRequestJob; |
| 25 } // namespace net |
23 | 26 |
24 // To serve dynamic data off of chrome: URLs, implement the | 27 // To serve dynamic data off of chrome: URLs, implement the |
25 // ChromeURLDataManager::DataSource interface and register your handler | 28 // ChromeURLDataManager::DataSource interface and register your handler |
26 // with AddDataSource. | 29 // with AddDataSource. |
27 | 30 |
28 // ChromeURLDataManager lives on the IO thread, so any interfacing with | 31 // ChromeURLDataManager lives on the IO thread, so any interfacing with |
29 // it from the UI thread needs to go through an InvokeLater. | 32 // it from the UI thread needs to go through an InvokeLater. |
30 class ChromeURLDataManager { | 33 class ChromeURLDataManager { |
31 public: | 34 public: |
32 ChromeURLDataManager(); | 35 ChromeURLDataManager(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // InvokeLater. | 110 // InvokeLater. |
108 void AddDataSource(scoped_refptr<DataSource> source); | 111 void AddDataSource(scoped_refptr<DataSource> source); |
109 | 112 |
110 // Add/remove a path from the collection of file sources. | 113 // Add/remove a path from the collection of file sources. |
111 // A file source acts like a file:// URL to the specified path. | 114 // A file source acts like a file:// URL to the specified path. |
112 // Calling this from threads other the IO thread must be done via | 115 // Calling this from threads other the IO thread must be done via |
113 // InvokeLater. | 116 // InvokeLater. |
114 void AddFileSource(const std::string& source_name, const FilePath& path); | 117 void AddFileSource(const std::string& source_name, const FilePath& path); |
115 void RemoveFileSource(const std::string& source_name); | 118 void RemoveFileSource(const std::string& source_name); |
116 | 119 |
117 static URLRequestJob* Factory(URLRequest* request, const std::string& scheme); | 120 static net::URLRequestJob* Factory(net::URLRequest* request, |
| 121 const std::string& scheme); |
118 | 122 |
119 private: | 123 private: |
120 friend class URLRequestChromeJob; | 124 friend class URLRequestChromeJob; |
121 | 125 |
122 // Parse a URL into the components used to resolve its request. | 126 // Parse a URL into the components used to resolve its request. |
123 static void URLToRequest(const GURL& url, | 127 static void URLToRequest(const GURL& url, |
124 std::string* source, | 128 std::string* source, |
125 std::string* path); | 129 std::string* path); |
126 | 130 |
127 // Translate a chrome resource URL into a local file path if there is one. | 131 // Translate a chrome resource URL into a local file path if there is one. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager); | 170 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager); |
167 | 171 |
168 // Register our special URL handler under our special URL scheme. | 172 // Register our special URL handler under our special URL scheme. |
169 // Must be done once at startup. | 173 // Must be done once at startup. |
170 void RegisterURLRequestChromeJob(); | 174 void RegisterURLRequestChromeJob(); |
171 | 175 |
172 // Undoes the registration done by RegisterURLRequestChromeJob. | 176 // Undoes the registration done by RegisterURLRequestChromeJob. |
173 void UnregisterURLRequestChromeJob(); | 177 void UnregisterURLRequestChromeJob(); |
174 | 178 |
175 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ | 179 #endif // CHROME_BROWSER_DOM_UI_CHROME_URL_DATA_MANAGER_H_ |
OLD | NEW |