| 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_URL_DATA_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
| 14 | 14 |
| 15 class ChromeURLDataManagerBackend; | 15 class ChromeURLDataManagerBackend; |
| 16 class DictionaryValue; | |
| 17 class FilePath; | 16 class FilePath; |
| 18 class MessageLoop; | 17 class MessageLoop; |
| 19 class Profile; | 18 class Profile; |
| 20 class RefCountedMemory; | 19 class RefCountedMemory; |
| 21 | 20 |
| 21 namespace base { |
| 22 class DictionaryValue; |
| 23 } |
| 24 |
| 22 // To serve dynamic data off of chrome: URLs, implement the | 25 // To serve dynamic data off of chrome: URLs, implement the |
| 23 // ChromeURLDataManager::DataSource interface and register your handler | 26 // ChromeURLDataManager::DataSource interface and register your handler |
| 24 // with AddDataSource. DataSources must be added on the UI thread (they are also | 27 // with AddDataSource. DataSources must be added on the UI thread (they are also |
| 25 // deleted on the UI thread). Internally the DataSources are maintained by | 28 // deleted on the UI thread). Internally the DataSources are maintained by |
| 26 // ChromeURLDataManagerBackend, see it for details. | 29 // ChromeURLDataManagerBackend, see it for details. |
| 27 class ChromeURLDataManager { | 30 class ChromeURLDataManager { |
| 28 public: | 31 public: |
| 29 class DataSource; | 32 class DataSource; |
| 30 | 33 |
| 31 // Trait used to handle deleting a DataSource. Deletion happens on the UI | 34 // Trait used to handle deleting a DataSource. Deletion happens on the UI |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 98 |
| 96 // Returns true if this DataSource should replace an existing DataSource | 99 // Returns true if this DataSource should replace an existing DataSource |
| 97 // with the same name that has already been registered. The default is | 100 // with the same name that has already been registered. The default is |
| 98 // true. | 101 // true. |
| 99 // | 102 // |
| 100 // WARNING: this is invoked on the IO thread. | 103 // WARNING: this is invoked on the IO thread. |
| 101 // | 104 // |
| 102 // TODO: nuke this and convert all callers to not replace. | 105 // TODO: nuke this and convert all callers to not replace. |
| 103 virtual bool ShouldReplaceExistingSource() const; | 106 virtual bool ShouldReplaceExistingSource() const; |
| 104 | 107 |
| 105 static void SetFontAndTextDirection(DictionaryValue* localized_strings); | 108 static void SetFontAndTextDirection( |
| 109 base::DictionaryValue* localized_strings); |
| 106 | 110 |
| 107 protected: | 111 protected: |
| 108 virtual ~DataSource(); | 112 virtual ~DataSource(); |
| 109 | 113 |
| 110 private: | 114 private: |
| 111 friend class ChromeURLDataManagerBackend; | 115 friend class ChromeURLDataManagerBackend; |
| 112 friend class ChromeURLDataManager; | 116 friend class ChromeURLDataManager; |
| 113 friend class DeleteTask<DataSource>; | 117 friend class DeleteTask<DataSource>; |
| 114 | 118 |
| 115 // SendResponse invokes this on the IO thread. Notifies the backend to | 119 // SendResponse invokes this on the IO thread. Notifies the backend to |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Lock used when accessing |data_sources_|. | 176 // Lock used when accessing |data_sources_|. |
| 173 static base::Lock delete_lock_; | 177 static base::Lock delete_lock_; |
| 174 | 178 |
| 175 // |data_sources_| that are no longer referenced and scheduled for deletion. | 179 // |data_sources_| that are no longer referenced and scheduled for deletion. |
| 176 static DataSources* data_sources_; | 180 static DataSources* data_sources_; |
| 177 | 181 |
| 178 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManager); | 182 DISALLOW_COPY_AND_ASSIGN(ChromeURLDataManager); |
| 179 }; | 183 }; |
| 180 | 184 |
| 181 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ | 185 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_URL_DATA_MANAGER_H_ |
| OLD | NEW |