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

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: Fixed unittest error 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..111ffafe0ed94ba152dacb380991fc521b62bb53 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,35 @@ WebRequestEventDetails::GetAndClearDict() {
return result;
}
+std::unique_ptr<WebRequestEventDetails>
+WebRequestEventDetails::WhitelistedCopyForPublicSession() {
+ std::unique_ptr<WebRequestEventDetails> copy(new WebRequestEventDetails);
+
+ // Explicitly whitelist only safe attributes.
+ copy->render_process_id_ = render_process_id_;
+ copy->render_frame_id_ = render_frame_id_;
+
+ for (const char* safe_attr : {"method", "requestId", "timeStamp", "type",
+ "tabId", "frameId", "parentFrameId",
+ "fromCache", "error", "ip", "statusLine",
+ "statusCode"}) {
+ base::Value* val;
+ if (dict_.Get(safe_attr, &val))
+ copy->dict_.Set(safe_attr, val->CreateDeepCopy());
+ }
+
+ // URL is stripped down to the origin.
+ std::string url;
+ dict_.GetString(keys::kUrlKey, &url);
+ GURL gurl(url);
+ copy->SetString(keys::kUrlKey, gurl.GetOrigin().spec());
+
+ return copy;
+}
+
+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