| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Allow the load in the case of a non-existent extension. We'll just get a | 44 // Allow the load in the case of a non-existent extension. We'll just get a |
| 45 // 404 from the browser process. | 45 // 404 from the browser process. |
| 46 return true; | 46 return true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Disallow loading of packaged resources for hosted apps. We don't allow | 49 // Disallow loading of packaged resources for hosted apps. We don't allow |
| 50 // hybrid hosted/packaged apps. The one exception is access to icons, since | 50 // hybrid hosted/packaged apps. The one exception is access to icons, since |
| 51 // some extensions want to be able to do things like create their own | 51 // some extensions want to be able to do things like create their own |
| 52 // launchers. | 52 // launchers. |
| 53 std::string resource_root_relative_path = | 53 std::string resource_root_relative_path = |
| 54 resource_url.path().empty() ? "" : resource_url.path().substr(1); | 54 resource_url.path().empty() ? std::string() |
| 55 : resource_url.path().substr(1); |
| 55 if (extension->is_hosted_app() && | 56 if (extension->is_hosted_app() && |
| 56 !IconsInfo::GetIcons(extension) | 57 !IconsInfo::GetIcons(extension) |
| 57 .ContainsPath(resource_root_relative_path)) { | 58 .ContainsPath(resource_root_relative_path)) { |
| 58 LOG(ERROR) << "Denying load of " << resource_url.spec() << " from " | 59 LOG(ERROR) << "Denying load of " << resource_url.spec() << " from " |
| 59 << "hosted app."; | 60 << "hosted app."; |
| 60 return false; | 61 return false; |
| 61 } | 62 } |
| 62 | 63 |
| 63 // Disallow loading of extension resources which are not explicitly listed | 64 // Disallow loading of extension resources which are not explicitly listed |
| 64 // as web accessible if the manifest version is 2 or greater. | 65 // as web accessible if the manifest version is 2 or greater. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return false; | 123 return false; |
| 123 } | 124 } |
| 124 | 125 |
| 125 return true; | 126 return true; |
| 126 } | 127 } |
| 127 | 128 |
| 128 ResourceRequestPolicy::ResourceRequestPolicy() { | 129 ResourceRequestPolicy::ResourceRequestPolicy() { |
| 129 } | 130 } |
| 130 | 131 |
| 131 } // namespace extensions | 132 } // namespace extensions |
| OLD | NEW |