| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ | 6 #define CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <unordered_set> |
| 12 | 13 |
| 13 #include "base/callback.h" | 14 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "content/browser/webui/url_data_manager.h" | 18 #include "content/browser/webui/url_data_manager.h" |
| 18 #include "content/browser/webui/url_data_source_impl.h" | 19 #include "content/browser/webui/url_data_source_impl.h" |
| 19 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 20 #include "content/public/browser/url_data_source.h" | 21 #include "content/public/browser/url_data_source.h" |
| 21 #include "content/public/browser/web_ui_data_source.h" | 22 #include "content/public/browser/web_ui_data_source.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 42 void SetDefaultResource(int resource_id) override; | 43 void SetDefaultResource(int resource_id) override; |
| 43 void SetRequestFilter( | 44 void SetRequestFilter( |
| 44 const WebUIDataSource::HandleRequestCallback& callback) override; | 45 const WebUIDataSource::HandleRequestCallback& callback) override; |
| 45 void DisableReplaceExistingSource() override; | 46 void DisableReplaceExistingSource() override; |
| 46 void DisableContentSecurityPolicy() override; | 47 void DisableContentSecurityPolicy() override; |
| 47 void OverrideContentSecurityPolicyObjectSrc(const std::string& data) override; | 48 void OverrideContentSecurityPolicyObjectSrc(const std::string& data) override; |
| 48 void OverrideContentSecurityPolicyChildSrc(const std::string& data) override; | 49 void OverrideContentSecurityPolicyChildSrc(const std::string& data) override; |
| 49 void DisableDenyXFrameOptions() override; | 50 void DisableDenyXFrameOptions() override; |
| 50 void DisableI18nAndUseGzipForAllPaths() override; | 51 void DisableI18nAndUseGzipForAllPaths() override; |
| 51 | 52 |
| 53 // When DisableI18nAndUseGzipForAllPaths is enabled, exclude the given |path|. |
| 54 void ExcludePathFromGzip(const std::string& path); |
| 55 |
| 52 protected: | 56 protected: |
| 53 ~WebUIDataSourceImpl() override; | 57 ~WebUIDataSourceImpl() override; |
| 54 | 58 |
| 55 // Completes a request by sending our dictionary of localized strings. | 59 // Completes a request by sending our dictionary of localized strings. |
| 56 void SendLocalizedStringsAsJSON( | 60 void SendLocalizedStringsAsJSON( |
| 57 const URLDataSource::GotDataCallback& callback); | 61 const URLDataSource::GotDataCallback& callback); |
| 58 | 62 |
| 59 private: | 63 private: |
| 60 class InternalDataSource; | 64 class InternalDataSource; |
| 61 friend class InternalDataSource; | 65 friend class InternalDataSource; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 78 add_load_time_data_defaults_ = false; | 82 add_load_time_data_defaults_ = false; |
| 79 } | 83 } |
| 80 | 84 |
| 81 // The name of this source. | 85 // The name of this source. |
| 82 // E.g., for favicons, this could be "favicon", which results in paths for | 86 // E.g., for favicons, this could be "favicon", which results in paths for |
| 83 // specific resources like "favicon/34" getting sent to this source. | 87 // specific resources like "favicon/34" getting sent to this source. |
| 84 std::string source_name_; | 88 std::string source_name_; |
| 85 int default_resource_; | 89 int default_resource_; |
| 86 std::string json_path_; | 90 std::string json_path_; |
| 87 std::map<std::string, int> path_to_idr_map_; | 91 std::map<std::string, int> path_to_idr_map_; |
| 92 std::unordered_set<std::string> excluded_paths_; |
| 88 // The |replacements_| is intended to replace |localized_strings_|. | 93 // The |replacements_| is intended to replace |localized_strings_|. |
| 89 // TODO(dschuyler): phase out |localized_strings_| in Q1 2016. (Or rename | 94 // TODO(dschuyler): phase out |localized_strings_| in Q1 2016. (Or rename |
| 90 // to |load_time_flags_| if the usage is reduced to storing flags only). | 95 // to |load_time_flags_| if the usage is reduced to storing flags only). |
| 91 ui::TemplateReplacements replacements_; | 96 ui::TemplateReplacements replacements_; |
| 92 base::DictionaryValue localized_strings_; | 97 base::DictionaryValue localized_strings_; |
| 93 WebUIDataSource::HandleRequestCallback filter_callback_; | 98 WebUIDataSource::HandleRequestCallback filter_callback_; |
| 94 bool add_csp_; | 99 bool add_csp_; |
| 95 bool object_src_set_; | 100 bool object_src_set_; |
| 96 std::string object_src_; | 101 std::string object_src_; |
| 97 bool frame_src_set_; | 102 bool frame_src_set_; |
| 98 std::string frame_src_; | 103 std::string frame_src_; |
| 99 bool deny_xframe_options_; | 104 bool deny_xframe_options_; |
| 100 bool add_load_time_data_defaults_; | 105 bool add_load_time_data_defaults_; |
| 101 bool replace_existing_source_; | 106 bool replace_existing_source_; |
| 102 bool use_gzip_for_all_paths_; | 107 bool use_gzip_for_all_paths_; |
| 103 | 108 |
| 104 DISALLOW_COPY_AND_ASSIGN(WebUIDataSourceImpl); | 109 DISALLOW_COPY_AND_ASSIGN(WebUIDataSourceImpl); |
| 105 }; | 110 }; |
| 106 | 111 |
| 107 } // namespace content | 112 } // namespace content |
| 108 | 113 |
| 109 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ | 114 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ |
| OLD | NEW |