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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const char* mime_type; | 52 const char* mime_type; |
53 } kResources[] = { | 53 } kResources[] = { |
54 { kLocalNTPFilename, IDR_LOCAL_NTP_HTML, "text/html" }, | 54 { kLocalNTPFilename, IDR_LOCAL_NTP_HTML, "text/html" }, |
55 { "local-ntp.js", IDR_LOCAL_NTP_JS, "application/javascript" }, | 55 { "local-ntp.js", IDR_LOCAL_NTP_JS, "application/javascript" }, |
56 { kConfigDataFilename, kLocalResource, "application/javascript" }, | 56 { kConfigDataFilename, kLocalResource, "application/javascript" }, |
57 { "local-ntp.css", IDR_LOCAL_NTP_CSS, "text/css" }, | 57 { "local-ntp.css", IDR_LOCAL_NTP_CSS, "text/css" }, |
58 { "images/close_2.png", IDR_CLOSE_2, "image/png" }, | 58 { "images/close_2.png", IDR_CLOSE_2, "image/png" }, |
59 { "images/close_2_hover.png", IDR_CLOSE_2_H, "image/png" }, | 59 { "images/close_2_hover.png", IDR_CLOSE_2_H, "image/png" }, |
60 { "images/close_2_active.png", IDR_CLOSE_2_P, "image/png" }, | 60 { "images/close_2_active.png", IDR_CLOSE_2_P, "image/png" }, |
61 { "images/close_2_white.png", IDR_CLOSE_2_MASK, "image/png" }, | 61 { "images/close_2_white.png", IDR_CLOSE_2_MASK, "image/png" }, |
| 62 { "images/close_3_mask.png", IDR_CLOSE_3_MASK, "image/png" }, |
62 { "images/google_logo.png", IDR_LOCAL_NTP_IMAGES_LOGO_PNG, "image/png" }, | 63 { "images/google_logo.png", IDR_LOCAL_NTP_IMAGES_LOGO_PNG, "image/png" }, |
63 { "images/white_google_logo.png", | 64 { "images/ntp_default_favicon.png", IDR_NTP_DEFAULT_FAVICON, "image/png" }, |
64 IDR_LOCAL_NTP_IMAGES_WHITE_LOGO_PNG, "image/png" }, | |
65 }; | 65 }; |
66 | 66 |
67 // Strips any query parameters from the specified path. | 67 // Strips any query parameters from the specified path. |
68 std::string StripParameters(const std::string& path) { | 68 std::string StripParameters(const std::string& path) { |
69 return path.substr(0, path.find("?")); | 69 return path.substr(0, path.find("?")); |
70 } | 70 } |
71 | 71 |
72 bool DefaultSearchProviderIsGoogle(Profile* profile) { | 72 bool DefaultSearchProviderIsGoogle(Profile* profile) { |
73 if (!profile) | 73 if (!profile) |
74 return false; | 74 return false; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 void LocalNtpSource::SendResourceWithClass( | 246 void LocalNtpSource::SendResourceWithClass( |
247 int resource_id, | 247 int resource_id, |
248 const std::string& class_name, | 248 const std::string& class_name, |
249 const content::URLDataSource::GotDataCallback& callback) { | 249 const content::URLDataSource::GotDataCallback& callback) { |
250 base::StringPiece resource_data = | 250 base::StringPiece resource_data = |
251 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); | 251 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id); |
252 std::string response(resource_data.as_string()); | 252 std::string response(resource_data.as_string()); |
253 ReplaceFirstSubstringAfterOffset(&response, 0, "{{CLASS}}", class_name); | 253 ReplaceFirstSubstringAfterOffset(&response, 0, "{{CLASS}}", class_name); |
254 callback.Run(base::RefCountedString::TakeString(&response)); | 254 callback.Run(base::RefCountedString::TakeString(&response)); |
255 } | 255 } |
OLD | NEW |