| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 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; |
| 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::StashMHTMLPartForAdditionToPage( |
| 33 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 |