Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: extensions/browser/api/web_request/web_request_api.cc

Issue 2455393002: PS - Adjusting webRequest API for use in Public Sessions (Closed)
Patch Set: Updated IsPublicSession function Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/web_request/web_request_api.cc
diff --git a/extensions/browser/api/web_request/web_request_api.cc b/extensions/browser/api/web_request/web_request_api.cc
index 829ebb512eb72d044537eb4afa30a5f800fcf704..172ace20ef103c54432e9197de29cf690213a2b3 100644
--- a/extensions/browser/api/web_request/web_request_api.cc
+++ b/extensions/browser/api/web_request/web_request_api.cc
@@ -22,6 +22,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
+#include "chromeos/login/login_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/browser/user_metrics.h"
@@ -338,6 +339,16 @@ bool ShouldHideEvent(void* browser_context,
navigation_ui_data));
}
+// Returns true if we're in a Public Session.
+bool IsPublicSession() {
+#if defined(OS_CHROMEOS)
+ if (chromeos::LoginState::IsInitialized()) {
+ return chromeos::LoginState::Get()->IsPublicSessionUser();
+ }
+#endif
+ return false;
+}
+
} // namespace
WebRequestAPI::WebRequestAPI(content::BrowserContext* context)
@@ -1440,6 +1451,17 @@ void ExtensionWebRequestEventRouter::GetMatchingListenersImpl(
extension_info_map, listener->id.extension_id, url,
frame_data.tab_id, crosses_incognito,
WebRequestPermissions::REQUIRE_HOST_PERMISSION);
+
+ // When we are in a Public Session, allow all URL's for webRequests
+ // initiated by a regular extension.
+ if (access != PermissionsData::ACCESS_ALLOWED && extension_info_map) {
+ const extensions::Extension* extension =
+ extension_info_map->extensions().GetByID(listener->id.extension_id);
+ if (IsPublicSession() && extension && extension->is_extension()) {
Devlin 2016/11/03 00:33:46 We want to do this for *all* extensions? Is it al
Ivan Šandrk 2016/11/03 14:45:12 Yes, for all regular extensions. Yes, users aren't
Devlin 2016/11/05 06:04:37 If security/privacy are on board with this, then t
Ivan Šandrk 2016/11/07 10:50:02 S&P are fine. Done.
+ access = PermissionsData::ACCESS_ALLOWED;
+ }
+ }
+
if (access != PermissionsData::ACCESS_ALLOWED) {
if (access == PermissionsData::ACCESS_WITHHELD &&
web_request_event_router_delegate_) {
@@ -2127,7 +2149,10 @@ WebRequestInternalAddEventListenerFunction::Run() {
// http://www.example.com/bar/*.
// For this reason we do only a coarse check here to warn the extension
// developer if they do something obviously wrong.
- if (extension->permissions_data()
+ // When we are in a Public Session, allow all URL's for webRequests
+ // initiated by a regular extension.
+ if (!(IsPublicSession() && extension->is_extension()) &&
+ extension->permissions_data()
->GetEffectiveHostPermissions()
.is_empty() &&
extension->permissions_data()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698