Chromium Code Reviews| 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 "extensions/browser/guest_view/web_view/web_view_renderer_state.h" | 10 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 int owner_process_id; | 33 int owner_process_id; |
| 34 WebViewRendererState::GetInstance()->GetOwnerInfo( | 34 WebViewRendererState::GetInstance()->GetOwnerInfo( |
| 35 info->GetChildID(), &owner_process_id, &owner_extension_id); | 35 info->GetChildID(), &owner_process_id, &owner_extension_id); |
| 36 const Extension* owner_extension = | 36 const Extension* owner_extension = |
| 37 extension_info_map->extensions().GetByID(owner_extension_id); | 37 extension_info_map->extensions().GetByID(owner_extension_id); |
| 38 std::string partition_id; | 38 std::string partition_id; |
| 39 bool is_guest = WebViewRendererState::GetInstance()->GetPartitionID( | 39 bool is_guest = WebViewRendererState::GetInstance()->GetPartitionID( |
| 40 info->GetChildID(), &partition_id); | 40 info->GetChildID(), &partition_id); |
| 41 std::string resource_path = request->url().path(); | 41 std::string resource_path = request->url().path(); |
| 42 | 42 |
| 43 // |owner_extension == extension| needs to be checked because extension | 43 if (is_guest) { |
| 44 // resources should only be accessible to WebViews owned by that extension. | 44 // Extension resources should only be accessible to WebViews owned by that |
| 45 if (is_guest && owner_extension == extension && | 45 // extension. |
| 46 WebviewInfo::IsResourceWebviewAccessible(extension, partition_id, | 46 if (owner_extension != extension) |
| 47 resource_path)) { | 47 return false; |
|
nasko
2016/08/17 16:31:44
Why this rewrite in this patch? I think the goal i
robwu
2016/08/18 08:09:58
Without this change, the following test would fail
| |
| 48 *allowed = true; | 48 *allowed = WebviewInfo::IsResourceWebviewAccessible(extension, partition_id, |
| 49 resource_path); | |
| 49 return true; | 50 return true; |
| 50 } | 51 } |
| 51 | 52 |
| 52 if (!ui::PageTransitionIsWebTriggerable(info->GetPageTransition())) { | |
|
nasko
2016/08/17 16:31:44
As per my response in the bug, I think this should
robwu
2016/08/18 08:09:58
I restored this check and moved it to the end out
| |
| 53 *allowed = false; | |
| 54 return true; | |
| 55 } | |
| 56 | |
| 57 // The following checks require that we have an actual extension object. If we | 53 // The following checks require that we have an actual extension object. If we |
| 58 // don't have it, allow the request handling to continue with the rest of the | 54 // don't have it, allow the request handling to continue with the rest of the |
| 59 // checks. | 55 // checks. |
| 60 if (!extension) { | 56 if (!extension) { |
| 61 *allowed = true; | 57 *allowed = true; |
| 62 return true; | 58 return true; |
| 63 } | 59 } |
| 64 | 60 |
| 65 // Disallow loading of packaged resources for hosted apps. We don't allow | 61 // Disallow loading of packaged resources for hosted apps. We don't allow |
| 66 // hybrid hosted/packaged apps. The one exception is access to icons, since | 62 // hybrid hosted/packaged apps. The one exception is access to icons, since |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 const content::ResourceRequestInfo* info = | 122 const content::ResourceRequestInfo* info = |
| 127 content::ResourceRequestInfo::ForRequest(request); | 123 content::ResourceRequestInfo::ForRequest(request); |
| 128 // |info| can be NULL sometimes: http://crbug.com/370070. | 124 // |info| can be NULL sometimes: http://crbug.com/370070. |
| 129 if (!info) | 125 if (!info) |
| 130 return false; | 126 return false; |
| 131 return WebViewRendererState::GetInstance()->IsGuest(info->GetChildID()); | 127 return WebViewRendererState::GetInstance()->IsGuest(info->GetChildID()); |
| 132 } | 128 } |
| 133 | 129 |
| 134 } // namespace url_request_util | 130 } // namespace url_request_util |
| 135 } // namespace extensions | 131 } // namespace extensions |
| OLD | NEW |