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

Side by Side Diff: extensions/browser/api/web_request/web_request_event_details.cc

Issue 2899743002: Remove raw base::DictionaryValue::Set in //extensions (Closed)
Patch Set: Addressed nit Created 3 years, 6 months 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 <utility>
8
7 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ptr_util.h"
8 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
9 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/render_frame_host.h" 13 #include "content/public/browser/render_frame_host.h"
11 #include "content/public/browser/resource_request_info.h" 14 #include "content/public/browser/resource_request_info.h"
12 #include "content/public/browser/websocket_handshake_request_info.h" 15 #include "content/public/browser/websocket_handshake_request_info.h"
13 #include "content/public/common/child_process_host.h" 16 #include "content/public/common/child_process_host.h"
14 #include "extensions/browser/api/web_request/upload_data_presenter.h" 17 #include "extensions/browser/api/web_request/upload_data_presenter.h"
15 #include "extensions/browser/api/web_request/web_request_api_constants.h" 18 #include "extensions/browser/api/web_request/web_request_api_constants.h"
16 #include "extensions/browser/api/web_request/web_request_api_helpers.h" 19 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
17 #include "extensions/browser/api/web_request/web_request_resource_type.h" 20 #include "extensions/browser/api/web_request/web_request_resource_type.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 request_headers_.reset(headers); 122 request_headers_.reset(headers);
120 } 123 }
121 124
122 void WebRequestEventDetails::SetAuthInfo( 125 void WebRequestEventDetails::SetAuthInfo(
123 const net::AuthChallengeInfo& auth_info) { 126 const net::AuthChallengeInfo& auth_info) {
124 dict_.SetBoolean(keys::kIsProxyKey, auth_info.is_proxy); 127 dict_.SetBoolean(keys::kIsProxyKey, auth_info.is_proxy);
125 if (!auth_info.scheme.empty()) 128 if (!auth_info.scheme.empty())
126 dict_.SetString(keys::kSchemeKey, auth_info.scheme); 129 dict_.SetString(keys::kSchemeKey, auth_info.scheme);
127 if (!auth_info.realm.empty()) 130 if (!auth_info.realm.empty())
128 dict_.SetString(keys::kRealmKey, auth_info.realm); 131 dict_.SetString(keys::kRealmKey, auth_info.realm);
129 base::DictionaryValue* challenger = new base::DictionaryValue(); 132 auto challenger = base::MakeUnique<base::DictionaryValue>();
130 challenger->SetString(keys::kHostKey, auth_info.challenger.host()); 133 challenger->SetString(keys::kHostKey, auth_info.challenger.host());
131 challenger->SetInteger(keys::kPortKey, auth_info.challenger.port()); 134 challenger->SetInteger(keys::kPortKey, auth_info.challenger.port());
132 dict_.Set(keys::kChallengerKey, challenger); 135 dict_.Set(keys::kChallengerKey, std::move(challenger));
133 } 136 }
134 137
135 void WebRequestEventDetails::SetResponseHeaders( 138 void WebRequestEventDetails::SetResponseHeaders(
136 const net::URLRequest* request, 139 const net::URLRequest* request,
137 const net::HttpResponseHeaders* response_headers) { 140 const net::HttpResponseHeaders* response_headers) {
138 if (!response_headers) { 141 if (!response_headers) {
139 // Not all URLRequestJobs specify response headers. E.g. URLRequestFTPJob, 142 // Not all URLRequestJobs specify response headers. E.g. URLRequestFTPJob,
140 // URLRequestFileJob and some redirects. 143 // URLRequestFileJob and some redirects.
141 dict_.SetInteger(keys::kStatusCodeKey, request->GetResponseCode()); 144 dict_.SetInteger(keys::kStatusCodeKey, request->GetResponseCode());
142 dict_.SetString(keys::kStatusLineKey, ""); 145 dict_.SetString(keys::kStatusLineKey, "");
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 std::unique_ptr<WebRequestEventDetails> self(this); 189 std::unique_ptr<WebRequestEventDetails> self(this);
187 ExtensionApiFrameIdMap::Get()->GetFrameDataOnIO( 190 ExtensionApiFrameIdMap::Get()->GetFrameDataOnIO(
188 render_process_id_, render_frame_id_, 191 render_process_id_, render_frame_id_,
189 base::Bind(&WebRequestEventDetails::OnDeterminedFrameData, 192 base::Bind(&WebRequestEventDetails::OnDeterminedFrameData,
190 base::Unretained(this), base::Passed(&self), callback)); 193 base::Unretained(this), base::Passed(&self), callback));
191 } 194 }
192 195
193 std::unique_ptr<base::DictionaryValue> WebRequestEventDetails::GetFilteredDict( 196 std::unique_ptr<base::DictionaryValue> WebRequestEventDetails::GetFilteredDict(
194 int extra_info_spec) const { 197 int extra_info_spec) const {
195 std::unique_ptr<base::DictionaryValue> result = dict_.CreateDeepCopy(); 198 std::unique_ptr<base::DictionaryValue> result = dict_.CreateDeepCopy();
196 if ((extra_info_spec & ExtraInfoSpec::REQUEST_BODY) && request_body_) 199 if ((extra_info_spec & ExtraInfoSpec::REQUEST_BODY) && request_body_) {
197 result->Set(keys::kRequestBodyKey, request_body_->CreateDeepCopy()); 200 result->Set(keys::kRequestBodyKey,
198 if ((extra_info_spec & ExtraInfoSpec::REQUEST_HEADERS) && request_headers_) 201 base::MakeUnique<base::Value>(*request_body_));
199 result->Set(keys::kRequestHeadersKey, request_headers_->CreateDeepCopy()); 202 }
200 if ((extra_info_spec & ExtraInfoSpec::RESPONSE_HEADERS) && response_headers_) 203 if ((extra_info_spec & ExtraInfoSpec::REQUEST_HEADERS) && request_headers_) {
201 result->Set(keys::kResponseHeadersKey, response_headers_->CreateDeepCopy()); 204 result->Set(keys::kRequestHeadersKey,
205 base::MakeUnique<base::Value>(*request_headers_));
206 }
207 if ((extra_info_spec & ExtraInfoSpec::RESPONSE_HEADERS) &&
208 response_headers_) {
209 result->Set(keys::kResponseHeadersKey,
210 base::MakeUnique<base::Value>(*response_headers_));
211 }
202 return result; 212 return result;
203 } 213 }
204 214
205 std::unique_ptr<base::DictionaryValue> 215 std::unique_ptr<base::DictionaryValue>
206 WebRequestEventDetails::GetAndClearDict() { 216 WebRequestEventDetails::GetAndClearDict() {
207 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); 217 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
208 dict_.Swap(result.get()); 218 dict_.Swap(result.get());
209 return result; 219 return result;
210 } 220 }
211 221
(...skipping 29 matching lines...) Expand all
241 251
242 void WebRequestEventDetails::OnDeterminedFrameData( 252 void WebRequestEventDetails::OnDeterminedFrameData(
243 std::unique_ptr<WebRequestEventDetails> self, 253 std::unique_ptr<WebRequestEventDetails> self,
244 const DeterminedFrameDataCallback& callback, 254 const DeterminedFrameDataCallback& callback,
245 const ExtensionApiFrameIdMap::FrameData& frame_data) { 255 const ExtensionApiFrameIdMap::FrameData& frame_data) {
246 SetFrameData(frame_data); 256 SetFrameData(frame_data);
247 callback.Run(std::move(self)); 257 callback.Run(std::move(self));
248 } 258 }
249 259
250 } // namespace extensions 260 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/web_request/web_request_api_helpers.cc ('k') | extensions/browser/app_window/app_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698