OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/url_request_util.h" | 5 #include "extensions/browser/url_request_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "content/public/browser/resource_request_info.h" | 9 #include "content/public/browser/resource_request_info.h" |
10 #include "content/public/common/browser_side_navigation_policy.h" | 10 #include "content/public/common/browser_side_navigation_policy.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // checks. | 60 // checks. |
61 if (!extension) { | 61 if (!extension) { |
62 *allowed = true; | 62 *allowed = true; |
63 return true; | 63 return true; |
64 } | 64 } |
65 | 65 |
66 // Disallow loading of packaged resources for hosted apps. We don't allow | 66 // Disallow loading of packaged resources for hosted apps. We don't allow |
67 // hybrid hosted/packaged apps. The one exception is access to icons, since | 67 // hybrid hosted/packaged apps. The one exception is access to icons, since |
68 // some extensions want to be able to do things like create their own | 68 // some extensions want to be able to do things like create their own |
69 // launchers. | 69 // launchers. |
70 std::string resource_root_relative_path = | 70 base::StringPiece resource_root_relative_path = |
71 request->url().path().empty() ? std::string() | 71 request->url().path_piece().empty() |
72 : request->url().path().substr(1); | 72 ? base::StringPiece() |
| 73 : request->url().path_piece().substr(1); |
73 if (extension->is_hosted_app() && | 74 if (extension->is_hosted_app() && |
74 !IconsInfo::GetIcons(extension) | 75 !IconsInfo::GetIcons(extension) |
75 .ContainsPath(resource_root_relative_path)) { | 76 .ContainsPath(resource_root_relative_path)) { |
76 LOG(ERROR) << "Denying load of " << request->url().spec() << " from " | 77 LOG(ERROR) << "Denying load of " << request->url().spec() << " from " |
77 << "hosted app."; | 78 << "hosted app."; |
78 *allowed = false; | 79 *allowed = false; |
79 return true; | 80 return true; |
80 } | 81 } |
81 | 82 |
82 DCHECK_EQ(extension->url(), request->url().GetWithEmptyPath()); | 83 DCHECK_EQ(extension->url(), request->url().GetWithEmptyPath()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 if (is_guest && !ui::PageTransitionIsWebTriggerable(page_transition)) { | 164 if (is_guest && !ui::PageTransitionIsWebTriggerable(page_transition)) { |
164 *allowed = false; | 165 *allowed = false; |
165 return true; | 166 return true; |
166 } | 167 } |
167 | 168 |
168 return false; | 169 return false; |
169 } | 170 } |
170 | 171 |
171 } // namespace url_request_util | 172 } // namespace url_request_util |
172 } // namespace extensions | 173 } // namespace extensions |
OLD | NEW |