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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_event_details.h" 5 #include "extensions/browser/api/web_request/web_request_event_details.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/render_frame_host.h" 10 #include "content/public/browser/render_frame_host.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return result; 191 return result;
192 } 192 }
193 193
194 std::unique_ptr<base::DictionaryValue> 194 std::unique_ptr<base::DictionaryValue>
195 WebRequestEventDetails::GetAndClearDict() { 195 WebRequestEventDetails::GetAndClearDict() {
196 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); 196 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
197 dict_.Swap(result.get()); 197 dict_.Swap(result.get());
198 return result; 198 return result;
199 } 199 }
200 200
201 std::unique_ptr<WebRequestEventDetails>
202 WebRequestEventDetails::WhitelistedCopyForPublicSession() {
203 std::unique_ptr<WebRequestEventDetails> copy(new WebRequestEventDetails);
204
205 // Explicitly whitelist only safe attributes.
206 copy->render_process_id_ = render_process_id_;
207 copy->render_frame_id_ = render_frame_id_;
208
209 for (const char* safe_attr : {"method", "requestId", "timeStamp", "type",
210 "tabId", "frameId", "parentFrameId",
211 "fromCache", "error", "ip", "statusLine",
212 "statusCode"}) {
213 base::Value* val;
214 if (dict_.Get(safe_attr, &val))
215 copy->dict_.Set(safe_attr, val->CreateDeepCopy());
216 }
217
218 // URL is stripped down to the origin.
219 std::string url;
220 dict_.GetString(keys::kUrlKey, &url);
221 GURL gurl(url);
222 copy->SetString(keys::kUrlKey, gurl.GetOrigin().spec());
223
224 return copy;
225 }
226
227 WebRequestEventDetails::WebRequestEventDetails()
228 : extra_info_spec_(0), render_process_id_(0), render_frame_id_(0) {}
229
201 void WebRequestEventDetails::OnDeterminedFrameData( 230 void WebRequestEventDetails::OnDeterminedFrameData(
202 std::unique_ptr<WebRequestEventDetails> self, 231 std::unique_ptr<WebRequestEventDetails> self,
203 const DeterminedFrameDataCallback& callback, 232 const DeterminedFrameDataCallback& callback,
204 const ExtensionApiFrameIdMap::FrameData& frame_data) { 233 const ExtensionApiFrameIdMap::FrameData& frame_data) {
205 SetFrameData(frame_data); 234 SetFrameData(frame_data);
206 callback.Run(std::move(self)); 235 callback.Run(std::move(self));
207 } 236 }
208 237
209 } // namespace extensions 238 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698