| 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 "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 12 #include "grit/browser_resources.h" | 13 #include "grit/browser_resources.h" |
| 13 #include "grit/ui_resources.h" | 14 #include "grit/ui_resources.h" |
| 14 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const struct Resource{ | 20 const struct Resource{ |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { | 97 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { |
| 97 DCHECK(StartsWithASCII(request->url().path(), "/", true)); | 98 DCHECK(StartsWithASCII(request->url().path(), "/", true)); |
| 98 std::string filename = request->url().path().substr(1); | 99 std::string filename = request->url().path().substr(1); |
| 99 for (size_t i = 0; i < arraysize(kResources); ++i) { | 100 for (size_t i = 0; i < arraysize(kResources); ++i) { |
| 100 if (filename == kResources[i].filename) | 101 if (filename == kResources[i].filename) |
| 101 return true; | 102 return true; |
| 102 } | 103 } |
| 103 } | 104 } |
| 104 return false; | 105 return false; |
| 105 } | 106 } |
| 107 |
| 108 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { |
| 109 // Allow embedding of chrome search suggestion host. |
| 110 return base::StringPrintf("frame-src %s://%s/;", |
| 111 chrome::kChromeSearchScheme, |
| 112 chrome::kChromeSearchSuggestionHost); |
| 113 } |
| OLD | NEW |