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

Side by Side Diff: content/browser/download/mhtml_extra_data_impl.cc

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: CR Feedback per FGorski Created 3 years, 8 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/download/mhtml_extra_data_impl.h"
6
7 namespace {
8 const int kMHTMLExtraDataKey = 0;
Dmitry Titov 2017/03/29 18:53:06 no need to initialize this value. But adding a sho
Pete Williamson 2017/03/29 22:05:42 Comment added. The compiler really wanted me to i
9 }
10
11 namespace content {
12
13 MHTMLExtraDataImpl::MHTMLExtraDataImpl() {}
14 MHTMLExtraDataImpl::~MHTMLExtraDataImpl() {}
15
16 MHTMLExtraData* MHTMLExtraData::FromWebContents(WebContents* contents) {
17 // Get the MHTMLExtraDataImpl from the web contents.
18 MHTMLExtraDataImpl* extra_data_impl = static_cast<MHTMLExtraDataImpl*>(
19 contents->GetUserData(&kMHTMLExtraDataKey));
20
21 // If we did not have one on the web contents already, make one and put it on
22 // the web contents.
23 if (extra_data_impl == nullptr) {
24 extra_data_impl = new MHTMLExtraDataImpl();
25 contents->SetUserData(&kMHTMLExtraDataKey,
26 std::unique_ptr<MHTMLExtraData>(
27 static_cast<MHTMLExtraData*>(extra_data_impl)));
28 }
29 return static_cast<MHTMLExtraData*>(extra_data_impl);
30 }
31
32 void MHTMLExtraDataImpl::AddExtraMHTMLPart(const std::string& content_type,
33 const std::string& content_location,
34 const std::string& body) {
35 MHTMLExtraDataPart part;
36 part.content_type = content_type;
37 part.content_location = content_location;
38 part.body = body;
39
40 // Add this part to the list of parts to be saved out when the file is
41 // written.
42 parts_.push_back(part);
43 }
44
45 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698