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

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

Issue 2455393002: PS - Adjusting webRequest API for use in Public Sessions (Closed)
Patch Set: webRequest and webRequestBlocking are safe permissions now 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
Index: extensions/browser/api/web_request/web_request_event_details.cc
diff --git a/extensions/browser/api/web_request/web_request_event_details.cc b/extensions/browser/api/web_request/web_request_event_details.cc
index a0ba5ba505c207df9d5f599d06ff0b3465d11123..d7a3e10c82713c857339ceb6b1323cfbc1f87b62 100644
--- a/extensions/browser/api/web_request/web_request_event_details.cc
+++ b/extensions/browser/api/web_request/web_request_event_details.cc
@@ -198,6 +198,36 @@ WebRequestEventDetails::GetAndClearDict() {
return result;
}
+void WebRequestEventDetails::FilterForPublicSession() {
+ request_body_ = nullptr;
+ request_headers_ = nullptr;
+ response_headers_ = nullptr;
+
+ extra_info_spec_ = 0;
+
+ static const char* const kSafeAttributes[] = {
+ "method", "requestId", "timeStamp", "type", "tabId", "frameId",
+ "parentFrameId", "fromCache", "error", "ip", "statusLine", "statusCode"
+ };
+
+ auto copy = GetAndClearDict();
+
+ for (const char* safe_attr : kSafeAttributes) {
+ std::unique_ptr<base::Value> val;
+ if (copy->Remove(safe_attr, &val))
+ dict_.Set(safe_attr, std::move(val));
+ }
+
+ // URL is stripped down to the origin.
+ std::string url;
+ copy->GetString(keys::kUrlKey, &url);
+ GURL gurl(url);
+ dict_.SetString(keys::kUrlKey, gurl.GetOrigin().spec());
+}
+
+WebRequestEventDetails::WebRequestEventDetails()
+ : extra_info_spec_(0), render_process_id_(0), render_frame_id_(0) {}
+
void WebRequestEventDetails::OnDeterminedFrameData(
std::unique_ptr<WebRequestEventDetails> self,
const DeterminedFrameDataCallback& callback,

Powered by Google App Engine
This is Rietveld 408576698