Chromium Code Reviews| 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 "extensions/browser/api/web_request/web_request_permissions.h" | 5 #include "extensions/browser/api/web_request/web_request_permissions.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chromeos/login/login_state.h" | |
| 9 #include "content/public/browser/resource_request_info.h" | 10 #include "content/public/browser/resource_request_info.h" |
| 10 #include "extensions/browser/extension_navigation_ui_data.h" | 11 #include "extensions/browser/extension_navigation_ui_data.h" |
| 11 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" | 12 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
| 12 #include "extensions/browser/info_map.h" | 13 #include "extensions/browser/info_map.h" |
| 13 #include "extensions/common/constants.h" | 14 #include "extensions/common/constants.h" |
| 14 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 15 #include "extensions/common/extension_urls.h" | 16 #include "extensions/common/extension_urls.h" |
| 16 #include "extensions/common/permissions/permissions_data.h" | 17 #include "extensions/common/permissions/permissions_data.h" |
| 17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 HostPermissionsCheck host_permissions_check) { | 119 HostPermissionsCheck host_permissions_check) { |
| 119 // extension_info_map can be NULL in testing. | 120 // extension_info_map can be NULL in testing. |
| 120 if (!extension_info_map) | 121 if (!extension_info_map) |
| 121 return PermissionsData::ACCESS_ALLOWED; | 122 return PermissionsData::ACCESS_ALLOWED; |
| 122 | 123 |
| 123 const extensions::Extension* extension = | 124 const extensions::Extension* extension = |
| 124 extension_info_map->extensions().GetByID(extension_id); | 125 extension_info_map->extensions().GetByID(extension_id); |
| 125 if (!extension) | 126 if (!extension) |
| 126 return PermissionsData::ACCESS_DENIED; | 127 return PermissionsData::ACCESS_DENIED; |
| 127 | 128 |
| 129 // When we are in a Public Session, allow all URL's for webRequests initiated | |
| 130 // by a regular extension. | |
| 131 #if defined(OS_CHROMEOS) | |
| 132 if (chromeos::LoginState::IsInitialized() && | |
| 133 chromeos::LoginState::Get()->IsPublicSessionUser() && | |
| 134 extension->is_extension()) { | |
| 135 CHECK(extensions::Manifest::IsPolicyLocation(extension->location())); | |
|
Andrew T Wilson (Slow)
2016/11/09 08:36:00
Document what this check is verifying (i.e. if som
Ivan Šandrk
2016/11/09 12:12:13
Done.
| |
| 136 return PermissionsData::ACCESS_ALLOWED; | |
| 137 } | |
| 138 #endif | |
| 139 | |
| 128 // Check if this event crosses incognito boundaries when it shouldn't. | 140 // Check if this event crosses incognito boundaries when it shouldn't. |
| 129 if (crosses_incognito && !extension_info_map->CanCrossIncognito(extension)) | 141 if (crosses_incognito && !extension_info_map->CanCrossIncognito(extension)) |
| 130 return PermissionsData::ACCESS_DENIED; | 142 return PermissionsData::ACCESS_DENIED; |
| 131 | 143 |
| 132 PermissionsData::AccessType access = PermissionsData::ACCESS_DENIED; | 144 PermissionsData::AccessType access = PermissionsData::ACCESS_DENIED; |
| 133 switch (host_permissions_check) { | 145 switch (host_permissions_check) { |
| 134 case DO_NOT_CHECK_HOST: | 146 case DO_NOT_CHECK_HOST: |
| 135 access = PermissionsData::ACCESS_ALLOWED; | 147 access = PermissionsData::ACCESS_ALLOWED; |
| 136 break; | 148 break; |
| 137 case REQUIRE_HOST_PERMISSION: | 149 case REQUIRE_HOST_PERMISSION: |
| 138 // about: URLs are not covered in host permissions, but are allowed | 150 // about: URLs are not covered in host permissions, but are allowed |
| 139 // anyway. | 151 // anyway. |
| 140 if (url.SchemeIs(url::kAboutScheme) || | 152 if (url.SchemeIs(url::kAboutScheme) || |
| 141 url::IsSameOriginWith(url, extension->url())) { | 153 url::IsSameOriginWith(url, extension->url())) { |
| 142 access = PermissionsData::ACCESS_ALLOWED; | 154 access = PermissionsData::ACCESS_ALLOWED; |
| 143 break; | 155 break; |
| 144 } | 156 } |
| 145 access = extension->permissions_data()->GetPageAccess(extension, url, | 157 access = extension->permissions_data()->GetPageAccess(extension, url, |
| 146 tab_id, nullptr); | 158 tab_id, nullptr); |
| 147 break; | 159 break; |
| 148 case REQUIRE_ALL_URLS: | 160 case REQUIRE_ALL_URLS: |
| 149 if (extension->permissions_data()->HasEffectiveAccessToAllHosts()) | 161 if (extension->permissions_data()->HasEffectiveAccessToAllHosts()) |
| 150 access = PermissionsData::ACCESS_ALLOWED; | 162 access = PermissionsData::ACCESS_ALLOWED; |
| 151 // else ACCESS_DENIED | 163 // else ACCESS_DENIED |
| 152 break; | 164 break; |
| 153 } | 165 } |
| 154 | 166 |
| 155 return access; | 167 return access; |
| 156 } | 168 } |
| OLD | NEW |