Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_parts_impl.h" | |
| 6 | |
| 7 namespace { | |
| 8 // Only the address of this variable is used. It is used as a key to UserData. | |
| 9 const int kMHTMLExtraPartsKey = 0; | |
| 10 } | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 MHTMLExtraPartsImpl::MHTMLExtraPartsImpl() {} | |
|
David Trainor- moved to gerrit
2017/03/30 05:26:40
= default for both?
Pete Williamson
2017/03/31 00:29:48
I tried that, but I got "Complex constructor has a
Pete Williamson
2017/03/31 21:58:03
Ah, I can use = default in the .cc file, changed t
| |
| 15 MHTMLExtraPartsImpl::~MHTMLExtraPartsImpl() {} | |
|
Dmitry Titov
2017/03/29 23:26:29
need a blank line between ctor and dtor
Pete Williamson
2017/03/31 00:29:48
Done.
| |
| 16 | |
| 17 MHTMLExtraParts* MHTMLExtraParts::FromWebContents(WebContents* contents) { | |
| 18 // Get the MHTMLExtraPartsImpl from the web contents. | |
| 19 MHTMLExtraPartsImpl* extra_data_impl = static_cast<MHTMLExtraPartsImpl*>( | |
| 20 contents->GetUserData(&kMHTMLExtraPartsKey)); | |
| 21 | |
| 22 // If we did not have one on the web contents already, make one and put it on | |
| 23 // the web contents. | |
| 24 if (extra_data_impl == nullptr) { | |
| 25 extra_data_impl = new MHTMLExtraPartsImpl(); | |
| 26 contents->SetUserData(&kMHTMLExtraPartsKey, | |
| 27 std::unique_ptr<MHTMLExtraParts>( | |
| 28 static_cast<MHTMLExtraParts*>(extra_data_impl))); | |
| 29 } | |
| 30 return static_cast<MHTMLExtraParts*>(extra_data_impl); | |
| 31 } | |
| 32 | |
| 33 void MHTMLExtraPartsImpl::AddExtraMHTMLPart(const std::string& content_type, | |
| 34 const std::string& content_location, | |
| 35 const std::string& body) { | |
| 36 MHTMLExtraDataPart part; | |
| 37 part.content_type = content_type; | |
| 38 part.content_location = content_location; | |
| 39 part.body = body; | |
| 40 | |
| 41 // Add this part to the list of parts to be saved out when the file is | |
| 42 // written. | |
| 43 parts_.push_back(part); | |
| 44 } | |
| 45 | |
| 46 } // namespace content | |
| OLD | NEW |