Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: content/browser/webui/web_ui_data_source_impl.h

Issue 2544683002: [MD settings] i18n source stream filtering (Closed)
Patch Set: added unit test Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 void SetDefaultResource(int resource_id) override; 43 void SetDefaultResource(int resource_id) override;
44 void SetRequestFilter( 44 void SetRequestFilter(
45 const WebUIDataSource::HandleRequestCallback& callback) override; 45 const WebUIDataSource::HandleRequestCallback& callback) override;
46 void DisableReplaceExistingSource() override; 46 void DisableReplaceExistingSource() override;
47 void DisableContentSecurityPolicy() override; 47 void DisableContentSecurityPolicy() override;
48 void OverrideContentSecurityPolicyScriptSrc(const std::string& data) override; 48 void OverrideContentSecurityPolicyScriptSrc(const std::string& data) override;
49 void OverrideContentSecurityPolicyObjectSrc(const std::string& data) override; 49 void OverrideContentSecurityPolicyObjectSrc(const std::string& data) override;
50 void OverrideContentSecurityPolicyChildSrc(const std::string& data) override; 50 void OverrideContentSecurityPolicyChildSrc(const std::string& data) override;
51 void DisableDenyXFrameOptions() override; 51 void DisableDenyXFrameOptions() override;
52 void DisableI18nAndUseGzipForAllPaths() override; 52 void DisableI18nAndUseGzipForAllPaths() override;
53 const ui::TemplateReplacements* GetReplacements() const override;
54
55 // Add the locale to the load time data defaults. May be called repeatedly.
56 void EnsureLoadTimeDataDefaultsAdded();
53 57
54 // When DisableI18nAndUseGzipForAllPaths is enabled, exclude the given |path|. 58 // When DisableI18nAndUseGzipForAllPaths is enabled, exclude the given |path|.
55 void ExcludePathFromGzip(const std::string& path); 59 void ExcludePathFromGzip(const std::string& path);
56 60
57 protected: 61 protected:
58 ~WebUIDataSourceImpl() override; 62 ~WebUIDataSourceImpl() override;
59 63
60 // Completes a request by sending our dictionary of localized strings. 64 // Completes a request by sending our dictionary of localized strings.
61 void SendLocalizedStringsAsJSON( 65 void SendLocalizedStringsAsJSON(
62 const URLDataSource::GotDataCallback& callback); 66 const URLDataSource::GotDataCallback& callback);
(...skipping 21 matching lines...) Expand all
84 } 88 }
85 89
86 // The name of this source. 90 // The name of this source.
87 // E.g., for favicons, this could be "favicon", which results in paths for 91 // E.g., for favicons, this could be "favicon", which results in paths for
88 // specific resources like "favicon/34" getting sent to this source. 92 // specific resources like "favicon/34" getting sent to this source.
89 std::string source_name_; 93 std::string source_name_;
90 int default_resource_; 94 int default_resource_;
91 std::string json_path_; 95 std::string json_path_;
92 std::map<std::string, int> path_to_idr_map_; 96 std::map<std::string, int> path_to_idr_map_;
93 std::unordered_set<std::string> excluded_paths_; 97 std::unordered_set<std::string> excluded_paths_;
98 // The replacements are initiallized in the main thread and then used in the
99 // IO thread. The map is safe to read from multiple threads as long as no
100 // futher changes are made to it after initialization.
101 ui::TemplateReplacements replacements_;
94 // The |replacements_| is intended to replace |localized_strings_|. 102 // The |replacements_| is intended to replace |localized_strings_|.
95 // TODO(dschuyler): phase out |localized_strings_| in Q1 2016. (Or rename 103 // TODO(dschuyler): phase out |localized_strings_| in Q1 2017. (Or rename
96 // to |load_time_flags_| if the usage is reduced to storing flags only). 104 // to |load_time_flags_| if the usage is reduced to storing flags only).
97 ui::TemplateReplacements replacements_;
98 base::DictionaryValue localized_strings_; 105 base::DictionaryValue localized_strings_;
99 WebUIDataSource::HandleRequestCallback filter_callback_; 106 WebUIDataSource::HandleRequestCallback filter_callback_;
100 bool add_csp_; 107 bool add_csp_;
101 bool script_src_set_; 108 bool script_src_set_;
102 std::string script_src_; 109 std::string script_src_;
103 bool object_src_set_; 110 bool object_src_set_;
104 std::string object_src_; 111 std::string object_src_;
105 bool frame_src_set_; 112 bool frame_src_set_;
106 std::string frame_src_; 113 std::string frame_src_;
107 bool deny_xframe_options_; 114 bool deny_xframe_options_;
108 bool add_load_time_data_defaults_; 115 bool add_load_time_data_defaults_;
109 bool replace_existing_source_; 116 bool replace_existing_source_;
110 bool use_gzip_for_all_paths_; 117 bool use_gzip_for_all_paths_;
111 118
112 DISALLOW_COPY_AND_ASSIGN(WebUIDataSourceImpl); 119 DISALLOW_COPY_AND_ASSIGN(WebUIDataSourceImpl);
113 }; 120 };
114 121
115 } // namespace content 122 } // namespace content
116 123
117 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_ 124 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_DATA_SOURCE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698