Chromium Code Reviews| 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 void ExcludePathFromGzip(const std::string& path); | |
|
Charlie Reis
2016/10/13 19:40:12
nit: Please add a comment, since it's not obvious
Dan Beam
2016/10/13 21:49:47
Done.
| |
| 54 | |
| 52 protected: | 55 protected: |
| 53 ~WebUIDataSourceImpl() override; | 56 ~WebUIDataSourceImpl() override; |
| 54 | 57 |
| 55 // Completes a request by sending our dictionary of localized strings. | 58 // Completes a request by sending our dictionary of localized strings. |
| 56 void SendLocalizedStringsAsJSON( | 59 void SendLocalizedStringsAsJSON( |
| 57 const URLDataSource::GotDataCallback& callback); | 60 const URLDataSource::GotDataCallback& callback); |
| 58 | 61 |
| 59 private: | 62 private: |
| 60 class InternalDataSource; | 63 class InternalDataSource; |
| 61 friend class InternalDataSource; | 64 friend class InternalDataSource; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 78 add_load_time_data_defaults_ = false; | 81 add_load_time_data_defaults_ = false; |
| 79 } | 82 } |
| 80 | 83 |
| 81 // The name of this source. | 84 // The name of this source. |
| 82 // E.g., for favicons, this could be "favicon", which results in paths for | 85 // E.g., for favicons, this could be "favicon", which results in paths for |
| 83 // specific resources like "favicon/34" getting sent to this source. | 86 // specific resources like "favicon/34" getting sent to this source. |
| 84 std::string source_name_; | 87 std::string source_name_; |
| 85 int default_resource_; | 88 int default_resource_; |
| 86 std::string json_path_; | 89 std::string json_path_; |
| 87 std::map<std::string, int> path_to_idr_map_; | 90 std::map<std::string, int> path_to_idr_map_; |
| 91 std::unordered_set<std::string> excluded_paths_; | |
| 88 // The |replacements_| is intended to replace |localized_strings_|. | 92 // The |replacements_| is intended to replace |localized_strings_|. |
| 89 // TODO(dschuyler): phase out |localized_strings_| in Q1 2016. (Or rename | 93 // 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). | 94 // to |load_time_flags_| if the usage is reduced to storing flags only). |
| 91 ui::TemplateReplacements replacements_; | 95 ui::TemplateReplacements replacements_; |
| 92 base::DictionaryValue localized_strings_; | 96 base::DictionaryValue localized_strings_; |
| 93 WebUIDataSource::HandleRequestCallback filter_callback_; | 97 WebUIDataSource::HandleRequestCallback filter_callback_; |
| 94 bool add_csp_; | 98 bool add_csp_; |
| 95 bool object_src_set_; | 99 bool object_src_set_; |
| 96 std::string object_src_; | 100 std::string object_src_; |
| 97 bool frame_src_set_; | 101 bool frame_src_set_; |
| 98 std::string frame_src_; | 102 std::string frame_src_; |
| 99 bool deny_xframe_options_; | 103 bool deny_xframe_options_; |
| 100 bool add_load_time_data_defaults_; | 104 bool add_load_time_data_defaults_; |
| 101 bool replace_existing_source_; | 105 bool replace_existing_source_; |
| 102 bool use_gzip_for_all_paths_; | 106 bool use_gzip_for_all_paths_; |
| 103 | 107 |
| 104 DISALLOW_COPY_AND_ASSIGN(WebUIDataSourceImpl); | 108 DISALLOW_COPY_AND_ASSIGN(WebUIDataSourceImpl); |
| 105 }; | 109 }; |
| 106 | 110 |
| 107 } // namespace content | 111 } // namespace content |
| 108 | 112 |
| 109 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ | 113 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ |
| OLD | NEW |