OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/extensions/resource_request_policy.h" | 5 #include "chrome/renderer/extensions/resource_request_policy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" | 9 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 if (!extension) { | 47 if (!extension) { |
48 // Allow the load in the case of a non-existent extension. We'll just get a | 48 // Allow the load in the case of a non-existent extension. We'll just get a |
49 // 404 from the browser process. | 49 // 404 from the browser process. |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
53 // Disallow loading of packaged resources for hosted apps. We don't allow | 53 // Disallow loading of packaged resources for hosted apps. We don't allow |
54 // hybrid hosted/packaged apps. The one exception is access to icons, since | 54 // hybrid hosted/packaged apps. The one exception is access to icons, since |
55 // some extensions want to be able to do things like create their own | 55 // some extensions want to be able to do things like create their own |
56 // launchers. | 56 // launchers. |
57 std::string resource_root_relative_path = | 57 base::StringPiece resource_root_relative_path = |
58 resource_url.path().empty() ? std::string() | 58 resource_url.path_piece().empty() ? base::StringPiece() |
59 : resource_url.path().substr(1); | 59 : resource_url.path_piece().substr(1); |
60 if (extension->is_hosted_app() && | 60 if (extension->is_hosted_app() && |
61 !IconsInfo::GetIcons(extension) | 61 !IconsInfo::GetIcons(extension) |
62 .ContainsPath(resource_root_relative_path)) { | 62 .ContainsPath(resource_root_relative_path)) { |
63 LOG(ERROR) << "Denying load of " << resource_url.spec() << " from " | 63 LOG(ERROR) << "Denying load of " << resource_url.spec() << " from " |
64 << "hosted app."; | 64 << "hosted app."; |
65 return false; | 65 return false; |
66 } | 66 } |
67 | 67 |
68 // Disallow loading of extension resources which are not explicitly listed | 68 // Disallow loading of extension resources which are not explicitly listed |
69 // as web or WebView accessible if the manifest version is 2 or greater. | 69 // as web or WebView accessible if the manifest version is 2 or greater. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 blink::WebConsoleMessage(blink::WebConsoleMessage::LevelError, | 108 blink::WebConsoleMessage(blink::WebConsoleMessage::LevelError, |
109 blink::WebString::fromUTF8(message))); | 109 blink::WebString::fromUTF8(message))); |
110 return false; | 110 return false; |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 } // namespace extensions | 117 } // namespace extensions |
OLD | NEW |