OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chrome_web_ui_data_source.h" | 5 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name, | 27 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name, |
28 int ids) { | 28 int ids) { |
29 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids)); | 29 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids)); |
30 } | 30 } |
31 | 31 |
32 std::string ChromeWebUIDataSource::GetMimeType(const std::string& path) const { | 32 std::string ChromeWebUIDataSource::GetMimeType(const std::string& path) const { |
33 if (EndsWith(path, ".js", false)) | 33 if (EndsWith(path, ".js", false)) |
34 return "application/javascript"; | 34 return "application/javascript"; |
35 | 35 |
| 36 if (EndsWith(path, ".pdf", false)) |
| 37 return "application/pdf"; |
| 38 |
36 return "text/html"; | 39 return "text/html"; |
37 } | 40 } |
38 | 41 |
39 void ChromeWebUIDataSource::StartDataRequest(const std::string& path, | 42 void ChromeWebUIDataSource::StartDataRequest(const std::string& path, |
40 bool is_incognito, | 43 bool is_incognito, |
41 int request_id) { | 44 int request_id) { |
42 if (path == json_path_) { | 45 if (path == json_path_) { |
43 SendLocalizedStringsAsJSON(request_id); | 46 SendLocalizedStringsAsJSON(request_id); |
44 } else { | 47 } else { |
45 int resource_id = default_resource_; | 48 int resource_id = default_resource_; |
(...skipping 11 matching lines...) Expand all Loading... |
57 SetFontAndTextDirection(&localized_strings_); | 60 SetFontAndTextDirection(&localized_strings_); |
58 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data); | 61 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data); |
59 SendResponse(request_id, base::RefCountedString::TakeString(&template_data)); | 62 SendResponse(request_id, base::RefCountedString::TakeString(&template_data)); |
60 } | 63 } |
61 | 64 |
62 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { | 65 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { |
63 scoped_refptr<RefCountedStaticMemory> response( | 66 scoped_refptr<RefCountedStaticMemory> response( |
64 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); | 67 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); |
65 SendResponse(request_id, response); | 68 SendResponse(request_id, response); |
66 } | 69 } |
OLD | NEW |