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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_mhtml_archiver.cc

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" 5 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 : web_contents_(nullptr), 46 : web_contents_(nullptr),
47 weak_ptr_factory_(this) { 47 weak_ptr_factory_(this) {
48 } 48 }
49 49
50 OfflinePageMHTMLArchiver::~OfflinePageMHTMLArchiver() { 50 OfflinePageMHTMLArchiver::~OfflinePageMHTMLArchiver() {
51 } 51 }
52 52
53 void OfflinePageMHTMLArchiver::CreateArchive( 53 void OfflinePageMHTMLArchiver::CreateArchive(
54 const base::FilePath& archives_dir, 54 const base::FilePath& archives_dir,
55 const CreateArchiveParams& create_archive_params, 55 const CreateArchiveParams& create_archive_params,
56 const std::vector<std::string>& signal_data,
56 const CreateArchiveCallback& callback) { 57 const CreateArchiveCallback& callback) {
57 DCHECK(callback_.is_null()); 58 DCHECK(callback_.is_null());
58 DCHECK(!callback.is_null()); 59 DCHECK(!callback.is_null());
59 callback_ = callback; 60 callback_ = callback;
61 signal_data_ = signal_data;
fgorski 2017/02/07 22:06:07 If I understand correctly this will be a copy. Can
Dmitry Titov 2017/02/14 20:39:58 I think this is also equivalent to passing a std::
60 62
61 if (HasConnectionSecurityError()) { 63 if (HasConnectionSecurityError()) {
62 ReportFailure(ArchiverResult::ERROR_SECURITY_CERTIFICATE); 64 ReportFailure(ArchiverResult::ERROR_SECURITY_CERTIFICATE);
63 return; 65 return;
64 } 66 }
65 67
66 GenerateMHTML(archives_dir, create_archive_params); 68 GenerateMHTML(archives_dir, create_archive_params);
67 } 69 }
68 70
69 void OfflinePageMHTMLArchiver::GenerateMHTML( 71 void OfflinePageMHTMLArchiver::GenerateMHTML(
(...skipping 20 matching lines...) Expand all
90 // TODO(fgorski): Figure out if the actual URL can be different at 92 // TODO(fgorski): Figure out if the actual URL can be different at
91 // the end of MHTML generation. Perhaps we should pull it out after the MHTML 93 // the end of MHTML generation. Perhaps we should pull it out after the MHTML
92 // is generated. 94 // is generated.
93 GURL url(web_contents_->GetLastCommittedURL()); 95 GURL url(web_contents_->GetLastCommittedURL());
94 base::string16 title(web_contents_->GetTitle()); 96 base::string16 title(web_contents_->GetTitle());
95 base::FilePath file_path( 97 base::FilePath file_path(
96 archives_dir.Append(base::GenerateGUID()).AddExtension(kMHTMLExtension)); 98 archives_dir.Append(base::GenerateGUID()).AddExtension(kMHTMLExtension));
97 content::MHTMLGenerationParams params(file_path); 99 content::MHTMLGenerationParams params(file_path);
98 params.use_binary_encoding = true; 100 params.use_binary_encoding = true;
99 params.remove_popup_overlay = create_archive_params.remove_popup_overlay; 101 params.remove_popup_overlay = create_archive_params.remove_popup_overlay;
102 params.extra_data = signal_data_;
fgorski 2017/02/07 22:06:07 Here as well.
100 103
101 web_contents_->GenerateMHTML( 104 web_contents_->GenerateMHTML(
102 params, 105 params,
103 base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone, 106 base::Bind(&OfflinePageMHTMLArchiver::OnGenerateMHTMLDone,
104 weak_ptr_factory_.GetWeakPtr(), url, file_path, title)); 107 weak_ptr_factory_.GetWeakPtr(), url, file_path, title));
105 } 108 }
106 109
107 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone( 110 void OfflinePageMHTMLArchiver::OnGenerateMHTMLDone(
108 const GURL& url, 111 const GURL& url,
109 const base::FilePath& file_path, 112 const base::FilePath& file_path,
(...skipping 24 matching lines...) Expand all
134 } 137 }
135 138
136 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) { 139 void OfflinePageMHTMLArchiver::ReportFailure(ArchiverResult result) {
137 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED); 140 DCHECK(result != ArchiverResult::SUCCESSFULLY_CREATED);
138 base::ThreadTaskRunnerHandle::Get()->PostTask( 141 base::ThreadTaskRunnerHandle::Get()->PostTask(
139 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(), 142 FROM_HERE, base::Bind(callback_, this, result, GURL(), base::FilePath(),
140 base::string16(), 0)); 143 base::string16(), 0));
141 } 144 }
142 145
143 } // namespace offline_pages 146 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698