| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (stripped_path == kTranslatedStringsFilename) { | 108 if (stripped_path == kTranslatedStringsFilename) { |
| 109 std::string translated_strings_js = GetTranslatedStrings(); | 109 std::string translated_strings_js = GetTranslatedStrings(); |
| 110 callback.Run(base::RefCountedString::TakeString(&translated_strings_js)); | 110 callback.Run(base::RefCountedString::TakeString(&translated_strings_js)); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 for (size_t i = 0; i < arraysize(kResources); ++i) { | 113 for (size_t i = 0; i < arraysize(kResources); ++i) { |
| 114 if (stripped_path == kResources[i].filename) { | 114 if (stripped_path == kResources[i].filename) { |
| 115 scoped_refptr<base::RefCountedStaticMemory> response( | 115 scoped_refptr<base::RefCountedStaticMemory> response( |
| 116 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 116 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
| 117 kResources[i].identifier)); | 117 kResources[i].identifier)); |
| 118 callback.Run(response); | 118 callback.Run(response.get()); |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 callback.Run(NULL); | 122 callback.Run(NULL); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 std::string LocalNtpSource::GetMimeType( | 125 std::string LocalNtpSource::GetMimeType( |
| 126 const std::string& path) const { | 126 const std::string& path) const { |
| 127 const std::string stripped_path = StripParameters(path); | 127 const std::string stripped_path = StripParameters(path); |
| 128 for (size_t i = 0; i < arraysize(kResources); ++i) { | 128 for (size_t i = 0; i < arraysize(kResources); ++i) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 146 } | 146 } |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 | 149 |
| 150 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { | 150 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { |
| 151 // Allow embedding of suggestion and most visited iframes. | 151 // Allow embedding of suggestion and most visited iframes. |
| 152 return base::StringPrintf("frame-src %s %s;", | 152 return base::StringPrintf("frame-src %s %s;", |
| 153 chrome::kChromeSearchSuggestionUrl, | 153 chrome::kChromeSearchSuggestionUrl, |
| 154 chrome::kChromeSearchMostVisitedUrl); | 154 chrome::kChromeSearchMostVisitedUrl); |
| 155 } | 155 } |
| OLD | NEW |