| OLD | NEW |
| 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 Loading... |
| 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 void WebRequestEventDetails::FilterForPublicSession() { |
| 202 request_body_ = nullptr; |
| 203 request_headers_ = nullptr; |
| 204 response_headers_ = nullptr; |
| 205 |
| 206 extra_info_spec_ = 0; |
| 207 |
| 208 static const char* const kSafeAttributes[] = { |
| 209 "method", "requestId", "timeStamp", "type", "tabId", "frameId", |
| 210 "parentFrameId", "fromCache", "error", "ip", "statusLine", "statusCode" |
| 211 }; |
| 212 |
| 213 auto copy = GetAndClearDict(); |
| 214 |
| 215 for (const char* safe_attr : kSafeAttributes) { |
| 216 std::unique_ptr<base::Value> val; |
| 217 if (copy->Remove(safe_attr, &val)) |
| 218 dict_.Set(safe_attr, std::move(val)); |
| 219 } |
| 220 |
| 221 // URL is stripped down to the origin. |
| 222 std::string url; |
| 223 copy->GetString(keys::kUrlKey, &url); |
| 224 GURL gurl(url); |
| 225 dict_.SetString(keys::kUrlKey, gurl.GetOrigin().spec()); |
| 226 } |
| 227 |
| 228 WebRequestEventDetails::WebRequestEventDetails() |
| 229 : extra_info_spec_(0), render_process_id_(0), render_frame_id_(0) {} |
| 230 |
| 201 void WebRequestEventDetails::OnDeterminedFrameData( | 231 void WebRequestEventDetails::OnDeterminedFrameData( |
| 202 std::unique_ptr<WebRequestEventDetails> self, | 232 std::unique_ptr<WebRequestEventDetails> self, |
| 203 const DeterminedFrameDataCallback& callback, | 233 const DeterminedFrameDataCallback& callback, |
| 204 const ExtensionApiFrameIdMap::FrameData& frame_data) { | 234 const ExtensionApiFrameIdMap::FrameData& frame_data) { |
| 205 SetFrameData(frame_data); | 235 SetFrameData(frame_data); |
| 206 callback.Run(std::move(self)); | 236 callback.Run(std::move(self)); |
| 207 } | 237 } |
| 208 | 238 |
| 209 } // namespace extensions | 239 } // namespace extensions |
| OLD | NEW |