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 #include "chrome/browser/ui/webui/options/options_ui.h" | 5 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 if (path == kLocalizedStringsFile) { | 172 if (path == kLocalizedStringsFile) { |
| 173 // Return dynamically-generated strings from memory. | 173 // Return dynamically-generated strings from memory. |
| 174 std::string strings_js; | 174 std::string strings_js; |
| 175 webui::AppendJsonJS(localized_strings_.get(), &strings_js); | 175 webui::AppendJsonJS(localized_strings_.get(), &strings_js); |
| 176 response_bytes = base::RefCountedString::TakeString(&strings_js); | 176 response_bytes = base::RefCountedString::TakeString(&strings_js); |
| 177 } else if (path == kOptionsBundleJsFile) { | 177 } else if (path == kOptionsBundleJsFile) { |
| 178 // Return (and cache) the options javascript code. | 178 // Return (and cache) the options javascript code. |
| 179 response_bytes = ui::ResourceBundle::GetSharedInstance(). | 179 response_bytes = ui::ResourceBundle::GetSharedInstance(). |
| 180 LoadDataResourceBytes(IDR_OPTIONS_BUNDLE_JS); | 180 LoadDataResourceBytes(IDR_OPTIONS_BUNDLE_JS); |
| 181 } else { | 181 } else { |
| 182 // Return (and cache) the main options html page as the default. | 182 // Return the main options html page as the default. |
| 183 response_bytes = ui::ResourceBundle::GetSharedInstance(). | 183 std::string html_page = webui::ReplaceFontFamilyAndSize( |
| 184 LoadDataResourceBytes(IDR_OPTIONS_HTML); | 184 ui::ResourceBundle::GetSharedInstance(). |
| 185 GetRawDataResource(IDR_OPTIONS_HTML).as_string()); | |
|
Dan Beam
2014/11/22 04:27:12
this probably makes more copies than I'd like, but
| |
| 186 response_bytes = base::RefCountedString::TakeString(&html_page); | |
| 185 } | 187 } |
| 186 | 188 |
| 187 callback.Run(response_bytes.get()); | 189 callback.Run(response_bytes.get()); |
| 188 } | 190 } |
| 189 | 191 |
| 190 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { | 192 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { |
| 191 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) | 193 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) |
| 192 return "application/javascript"; | 194 return "application/javascript"; |
| 193 | 195 |
| 194 return "text/html"; | 196 return "text/html"; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 // Add only if handler's service is enabled. | 484 // Add only if handler's service is enabled. |
| 483 if (handler->IsEnabled()) { | 485 if (handler->IsEnabled()) { |
| 484 // Add handler to the list and also pass the ownership. | 486 // Add handler to the list and also pass the ownership. |
| 485 web_ui()->AddMessageHandler(handler.release()); | 487 web_ui()->AddMessageHandler(handler.release()); |
| 486 handler_raw->GetLocalizedValues(localized_strings); | 488 handler_raw->GetLocalizedValues(localized_strings); |
| 487 handlers_.push_back(handler_raw); | 489 handlers_.push_back(handler_raw); |
| 488 } | 490 } |
| 489 } | 491 } |
| 490 | 492 |
| 491 } // namespace options | 493 } // namespace options |
| OLD | NEW |