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_omnibox_popup_source.h" | 5 #include "chrome/browser/search/local_omnibox_popup_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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const std::string& path) const { | 69 const std::string& path) const { |
70 if (path == kHtmlFilename) | 70 if (path == kHtmlFilename) |
71 return "text/html"; | 71 return "text/html"; |
72 if (path == kJSFilename) | 72 if (path == kJSFilename) |
73 return "application/javascript"; | 73 return "application/javascript"; |
74 if (path == kCssFilename) | 74 if (path == kCssFilename) |
75 return "text/css"; | 75 return "text/css"; |
76 if (path == kPageIconFilename || path == kPageIcon2xFilename || | 76 if (path == kPageIconFilename || path == kPageIcon2xFilename || |
77 path == kSearchIconFilename || path == kSearchIcon2xFilename) | 77 path == kSearchIconFilename || path == kSearchIcon2xFilename) |
78 return "image/png"; | 78 return "image/png"; |
79 return ""; | 79 return std::string(); |
80 } | 80 } |
81 | 81 |
82 bool LocalOmniboxPopupSource::ShouldServiceRequest( | 82 bool LocalOmniboxPopupSource::ShouldServiceRequest( |
83 const net::URLRequest* request) const { | 83 const net::URLRequest* request) const { |
84 DCHECK(request->url().host() == chrome::kChromeSearchLocalOmniboxPopupHost); | 84 DCHECK(request->url().host() == chrome::kChromeSearchLocalOmniboxPopupHost); |
85 | 85 |
86 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { | 86 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { |
87 DCHECK(StartsWithASCII(request->url().path(), "/", true)); | 87 DCHECK(StartsWithASCII(request->url().path(), "/", true)); |
88 std::string filename = request->url().path().substr(1); | 88 std::string filename = request->url().path().substr(1); |
89 return filename == kHtmlFilename || filename == kJSFilename || | 89 return filename == kHtmlFilename || filename == kJSFilename || |
90 filename == kCssFilename || filename == kPageIconFilename || | 90 filename == kCssFilename || filename == kPageIconFilename || |
91 filename == kPageIcon2xFilename || filename == kSearchIconFilename || | 91 filename == kPageIcon2xFilename || filename == kSearchIconFilename || |
92 filename == kSearchIcon2xFilename; | 92 filename == kSearchIcon2xFilename; |
93 } | 93 } |
94 return false; | 94 return false; |
95 } | 95 } |
96 | 96 |
97 std::string LocalOmniboxPopupSource::GetContentSecurityPolicyFrameSrc() const { | 97 std::string LocalOmniboxPopupSource::GetContentSecurityPolicyFrameSrc() const { |
98 // Allow embedding of chrome search suggestion host. | 98 // Allow embedding of chrome search suggestion host. |
99 return base::StringPrintf("frame-src %s://%s/;", | 99 return base::StringPrintf("frame-src %s://%s/;", |
100 chrome::kChromeSearchScheme, | 100 chrome::kChromeSearchScheme, |
101 chrome::kChromeSearchSuggestionHost); | 101 chrome::kChromeSearchSuggestionHost); |
102 } | 102 } |
OLD | NEW |