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

Unified Diff: content/renderer/dom_serializer_browsertest.cc

Issue 1502563004: Save-Page-As-Complete-Html: Each frame links to a distinct local file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no-url-deduping-for-frame-and-adding-save-item-id
Patch Set: Rebasing... Created 4 years, 11 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
« no previous file with comments | « content/common/frame_messages.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/dom_serializer_browsertest.cc
diff --git a/content/renderer/dom_serializer_browsertest.cc b/content/renderer/dom_serializer_browsertest.cc
index 526725466aab86f1f8109e5b9873ce1e387cdcd5..bf7258661c93367f3e91d5754be5b59aaf36d881 100644
--- a/content/renderer/dom_serializer_browsertest.cc
+++ b/content/renderer/dom_serializer_browsertest.cc
@@ -158,6 +158,30 @@ class DomSerializerTests : public ContentBrowserTest,
runner->Run();
}
+ class SingleLinkRewritingDelegate
+ : public WebFrameSerializer::LinkRewritingDelegate {
+ public:
+ SingleLinkRewritingDelegate(const WebURL& url, const WebString& localPath)
+ : url_(url), local_path_(localPath) {}
+
+ bool rewriteFrameSource(WebFrame* frame,
+ WebString* rewritten_link) override {
+ return false;
+ }
+
+ bool rewriteLink(const WebURL& url, WebString* rewritten_link) override {
+ if (url != url_)
+ return false;
+
+ *rewritten_link = local_path_;
+ return true;
+ }
+
+ private:
+ const WebURL url_;
+ const WebString local_path_;
+ };
+
// Serialize DOM belonging to a frame with the specified |frame_url|.
void SerializeDomForURL(const GURL& frame_url) {
// Find corresponding WebFrame according to frame_url.
@@ -165,12 +189,10 @@ class DomSerializerTests : public ContentBrowserTest,
ASSERT_TRUE(web_frame != NULL);
WebString file_path =
base::FilePath(FILE_PATH_LITERAL("c:\\dummy.htm")).AsUTF16Unsafe();
- std::vector<std::pair<WebURL, WebString>> url_to_local_path;
- url_to_local_path.push_back(std::make_pair(WebURL(frame_url), file_path));
+ SingleLinkRewritingDelegate delegate(frame_url, file_path);
// Start serializing DOM.
- bool result = WebFrameSerializer::serialize(
- web_frame->toWebLocalFrame(),
- static_cast<WebFrameSerializerClient*>(this), url_to_local_path);
+ bool result = WebFrameSerializer::serialize(web_frame->toWebLocalFrame(),
+ this, &delegate);
ASSERT_TRUE(result);
}
« no previous file with comments | « content/common/frame_messages.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698