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

Unified Diff: chrome/browser/android/offline_pages/prerendering_offliner.cc

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Don't forget the new .h file Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/prerendering_offliner.cc
diff --git a/chrome/browser/android/offline_pages/prerendering_offliner.cc b/chrome/browser/android/offline_pages/prerendering_offliner.cc
index a6564ad078d662af7b164c009e039d8dd89aa383..7fb38c3c01b398e0dab3ef4641d74b151b6023c2 100644
--- a/chrome/browser/android/offline_pages/prerendering_offliner.cc
+++ b/chrome/browser/android/offline_pages/prerendering_offliner.cc
@@ -15,6 +15,7 @@
#include "components/offline_pages/core/client_namespace_constants.h"
#include "components/offline_pages/core/downloads/download_ui_adapter.h"
#include "components/offline_pages/core/offline_page_model.h"
+#include "content/browser/download/mhtml_extra_data.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
@@ -83,6 +84,22 @@ void PrerenderingOffliner::OnLoadPageDone(
else if (save_page_params.url != request.url())
save_page_params.original_url = request.url();
+ // Write the signal data into a single string.
+ const char kContentTypeLine[] = "Content-Type: application/json\r\n";
Dmitry Titov 2017/03/16 02:28:20 this line would normally be at the beginning of th
Pete Williamson 2017/03/17 23:28:32 Done.
+ std::string signal_string(kContentTypeLine);
+ const std::vector<std::string>& signals = loader_->GetSignalData();
+
+ // TODO(petewil): Convert this to JSON.
+ for (std::string signal : signals) {
Dmitry Titov 2017/03/16 02:28:20 I'd move this whole block into a separate function
Pete Williamson 2017/03/17 23:28:32 Done.
+ signal_string += signal;
+ signal_string += "\r\n";
+ }
+
+ // Attach the signal data to the web contents.
+ web_contents->SetUserData(content::kMHTMLExtraDataKey,
+ std::unique_ptr<base::SupportsUserData::Data>(
+ new content::MHTMLExtraData(signal_string)));
+
SavePage(save_page_params, std::move(archiver),
base::Bind(&PrerenderingOffliner::OnSavePageDone,
weak_ptr_factory_.GetWeakPtr(), request));

Powered by Google App Engine
This is Rietveld 408576698