OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/local_ntp_source.h" | 5 #include "chrome/browser/search/local_ntp_source.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 const char kConfigDataFilename[] = "config.js"; | 44 const char kConfigDataFilename[] = "config.js"; |
45 const char kLocalNTPFilename[] = "local-ntp.html"; | 45 const char kLocalNTPFilename[] = "local-ntp.html"; |
46 | 46 |
47 const struct Resource{ | 47 const struct Resource{ |
48 const char* filename; | 48 const char* filename; |
49 int identifier; | 49 int identifier; |
50 const char* mime_type; | 50 const char* mime_type; |
51 } kResources[] = { | 51 } kResources[] = { |
52 { kLocalNTPFilename, IDR_LOCAL_NTP_HTML, "text/html" }, | 52 { kLocalNTPFilename, IDR_LOCAL_NTP_HTML, "text/html" }, |
53 { "local-ntp.js", IDR_LOCAL_NTP_JS, "application/javascript" }, | 53 { "local-ntp.js", IDR_LOCAL_NTP_JS, "application/javascript" }, |
54 { "local-ntp-util.js", IDR_LOCAL_NTP_UTIL_JS, "application/javascript" }, | |
Mathieu
2014/08/07 18:07:06
that's probably not correct.
huangs
2014/08/07 20:15:20
I was gonna add local-ntp-design.js, but realized
Mathieu
2014/08/07 20:50:24
Good point, they are indeed inlined at build time.
| |
55 { kConfigDataFilename, kLocalResource, "application/javascript" }, | 54 { kConfigDataFilename, kLocalResource, "application/javascript" }, |
56 { "local-ntp.css", IDR_LOCAL_NTP_CSS, "text/css" }, | 55 { "local-ntp.css", IDR_LOCAL_NTP_CSS, "text/css" }, |
57 { "images/close_2.png", IDR_CLOSE_2, "image/png" }, | 56 { "images/close_2.png", IDR_CLOSE_2, "image/png" }, |
58 { "images/close_2_hover.png", IDR_CLOSE_2_H, "image/png" }, | 57 { "images/close_2_hover.png", IDR_CLOSE_2_H, "image/png" }, |
59 { "images/close_2_active.png", IDR_CLOSE_2_P, "image/png" }, | 58 { "images/close_2_active.png", IDR_CLOSE_2_P, "image/png" }, |
60 { "images/close_2_white.png", IDR_CLOSE_2_MASK, "image/png" }, | 59 { "images/close_2_white.png", IDR_CLOSE_2_MASK, "image/png" }, |
61 { "images/google_logo.png", IDR_LOCAL_NTP_IMAGES_LOGO_PNG, "image/png" }, | 60 { "images/google_logo.png", IDR_LOCAL_NTP_IMAGES_LOGO_PNG, "image/png" }, |
62 { "images/white_google_logo.png", | 61 { "images/white_google_logo.png", |
63 IDR_LOCAL_NTP_IMAGES_WHITE_LOGO_PNG, "image/png" }, | 62 IDR_LOCAL_NTP_IMAGES_WHITE_LOGO_PNG, "image/png" }, |
64 }; | 63 }; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 void LocalNtpSource::SendResourceWithClass( | 227 void LocalNtpSource::SendResourceWithClass( |
229 int resource_id, | 228 int resource_id, |
230 const std::string& class_name, | 229 const std::string& class_name, |
231 const content::URLDataSource::GotDataCallback& callback) { | 230 const content::URLDataSource::GotDataCallback& callback) { |
232 base::StringPiece resource_data = | 231 base::StringPiece resource_data = |
233 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 232 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); |
234 std::string response(resource_data.as_string()); | 233 std::string response(resource_data.as_string()); |
235 ReplaceFirstSubstringAfterOffset(&response, 0, "{{CLASS}}", class_name); | 234 ReplaceFirstSubstringAfterOffset(&response, 0, "{{CLASS}}", class_name); |
236 callback.Run(base::RefCountedString::TakeString(&response)); | 235 callback.Run(base::RefCountedString::TakeString(&response)); |
237 } | 236 } |
OLD | NEW |