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

Unified Diff: ios/web/webui/web_ui_ios_data_source_impl.h

Issue 2954263003: Reland: Add support for $i18n{} localized strings to ios/web. (Closed)
Patch Set: Add missing chrome://flags webUI template keys. Created 3 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/public/web_ui_ios_data_source.h ('k') | ios/web/webui/web_ui_ios_data_source_impl.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/webui/web_ui_ios_data_source_impl.h
diff --git a/ios/web/webui/web_ui_ios_data_source_impl.h b/ios/web/webui/web_ui_ios_data_source_impl.h
index db93781104bc2753c8e698c5b0147a2e0607bed9..1adf5872e8920506e3e98233f68ad5513e5c5158 100644
--- a/ios/web/webui/web_ui_ios_data_source_impl.h
+++ b/ios/web/webui/web_ui_ios_data_source_impl.h
@@ -16,6 +16,7 @@
#include "ios/web/public/web_ui_ios_data_source.h"
#include "ios/web/webui/url_data_manager_ios.h"
#include "ios/web/webui/url_data_source_ios_impl.h"
+#include "ui/base/template_expressions.h"
namespace web {
@@ -26,6 +27,8 @@ class WebUIIOSDataSourceImpl : public URLDataSourceIOSImpl,
void AddString(const std::string& name, const base::string16& value) override;
void AddString(const std::string& name, const std::string& value) override;
void AddLocalizedString(const std::string& name, int ids) override;
+ void AddLocalizedStrings(
+ const base::DictionaryValue& localized_strings) override;
void AddBoolean(const std::string& name, bool value) override;
void SetJsonPath(const std::string& path) override;
void AddResourcePath(const std::string& path, int resource_id) override;
@@ -39,8 +42,10 @@ class WebUIIOSDataSourceImpl : public URLDataSourceIOSImpl,
void SendLocalizedStringsAsJSON(
const URLDataSourceIOS::GotDataCallback& callback);
- // Completes a request by sending the file specified by |idr|.
- void SendFromResourceBundle(const URLDataSourceIOS::GotDataCallback& callback,
+ // Completes a request to |path| by sending the file specified by |idr| as the
+ // response.
+ void SendFromResourceBundle(const std::string& path,
+ const URLDataSourceIOS::GotDataCallback& callback,
int idr);
private:
@@ -51,6 +56,9 @@ class WebUIIOSDataSourceImpl : public URLDataSourceIOSImpl,
explicit WebUIIOSDataSourceImpl(const std::string& source_name);
+ // Adds the locale to the load time data defaults. May be called repeatedly.
+ void EnsureLoadTimeDataDefaultsAdded();
+
// Methods that match URLDataSource which are called by
// InternalDataSource.
std::string GetSource() const;
@@ -65,8 +73,14 @@ class WebUIIOSDataSourceImpl : public URLDataSourceIOSImpl,
int default_resource_;
std::string json_path_;
std::map<std::string, int> path_to_idr_map_;
+ // The replacements are initiallized in the main thread and then used in the
+ // IO thread. The map is safe to read from multiple threads as long as no
+ // futher changes are made to it after initialization.
+ ui::TemplateReplacements replacements_;
+ // The |replacements_| is intended to replace |localized_strings_|.
base::DictionaryValue localized_strings_;
bool deny_xframe_options_;
+ bool load_time_data_defaults_added_;
bool replace_existing_source_;
DISALLOW_COPY_AND_ASSIGN(WebUIIOSDataSourceImpl);
« no previous file with comments | « ios/web/public/web_ui_ios_data_source.h ('k') | ios/web/webui/web_ui_ios_data_source_impl.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698