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

Side by Side Diff: ios/web/webui/web_ui_ios_data_source_impl.mm

Issue 2961893002: Reverse true/false states of load_time_data_defaults_added_. (Closed)
Patch Set: Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "ios/web/webui/web_ui_ios_data_source_impl.h" 5 #include "ios/web/webui/web_ui_ios_data_source_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 private: 60 private:
61 WebUIIOSDataSourceImpl* parent_; 61 WebUIIOSDataSourceImpl* parent_;
62 }; 62 };
63 63
64 WebUIIOSDataSourceImpl::WebUIIOSDataSourceImpl(const std::string& source_name) 64 WebUIIOSDataSourceImpl::WebUIIOSDataSourceImpl(const std::string& source_name)
65 : URLDataSourceIOSImpl(source_name, new InternalDataSource(this)), 65 : URLDataSourceIOSImpl(source_name, new InternalDataSource(this)),
66 source_name_(source_name), 66 source_name_(source_name),
67 default_resource_(-1), 67 default_resource_(-1),
68 deny_xframe_options_(true), 68 deny_xframe_options_(true),
69 load_time_data_defaults_added_(true), 69 load_time_data_defaults_added_(false),
70 replace_existing_source_(true) {} 70 replace_existing_source_(true) {}
71 71
72 WebUIIOSDataSourceImpl::~WebUIIOSDataSourceImpl() {} 72 WebUIIOSDataSourceImpl::~WebUIIOSDataSourceImpl() {}
73 73
74 void WebUIIOSDataSourceImpl::AddString(const std::string& name, 74 void WebUIIOSDataSourceImpl::AddString(const std::string& name,
75 const base::string16& value) { 75 const base::string16& value) {
76 localized_strings_.SetString(name, value); 76 localized_strings_.SetString(name, value);
77 replacements_[name] = base::UTF16ToUTF8(value); 77 replacements_[name] = base::UTF16ToUTF8(value);
78 } 78 }
79 79
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII)) 135 if (base::EndsWith(path, ".css", base::CompareCase::INSENSITIVE_ASCII))
136 return "text/css"; 136 return "text/css";
137 137
138 if (base::EndsWith(path, ".svg", base::CompareCase::INSENSITIVE_ASCII)) 138 if (base::EndsWith(path, ".svg", base::CompareCase::INSENSITIVE_ASCII))
139 return "image/svg+xml"; 139 return "image/svg+xml";
140 140
141 return "text/html"; 141 return "text/html";
142 } 142 }
143 143
144 void WebUIIOSDataSourceImpl::EnsureLoadTimeDataDefaultsAdded() { 144 void WebUIIOSDataSourceImpl::EnsureLoadTimeDataDefaultsAdded() {
145 if (!load_time_data_defaults_added_) 145 if (load_time_data_defaults_added_)
146 return; 146 return;
147 147
148 load_time_data_defaults_added_ = false; 148 load_time_data_defaults_added_ = true;
149 base::DictionaryValue defaults; 149 base::DictionaryValue defaults;
150 webui::SetLoadTimeDataDefaults(web::GetWebClient()->GetApplicationLocale(), 150 webui::SetLoadTimeDataDefaults(web::GetWebClient()->GetApplicationLocale(),
151 &defaults); 151 &defaults);
152 AddLocalizedStrings(defaults); 152 AddLocalizedStrings(defaults);
153 } 153 }
154 154
155 void WebUIIOSDataSourceImpl::StartDataRequest( 155 void WebUIIOSDataSourceImpl::StartDataRequest(
156 const std::string& path, 156 const std::string& path,
157 const URLDataSourceIOS::GotDataCallback& callback) { 157 const URLDataSourceIOS::GotDataCallback& callback) {
158 EnsureLoadTimeDataDefaultsAdded(); 158 EnsureLoadTimeDataDefaultsAdded();
(...skipping 30 matching lines...) Expand all
189 std::string replaced = ui::ReplaceTemplateExpressions( 189 std::string replaced = ui::ReplaceTemplateExpressions(
190 base::StringPiece(response->front_as<char>(), response->size()), 190 base::StringPiece(response->front_as<char>(), response->size()),
191 replacements_); 191 replacements_);
192 response = base::RefCountedString::TakeString(&replaced); 192 response = base::RefCountedString::TakeString(&replaced);
193 } 193 }
194 194
195 callback.Run(response); 195 callback.Run(response);
196 } 196 }
197 197
198 } // namespace web 198 } // namespace web
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698