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

Unified Diff: third_party/WebKit/Source/web/WebFrameSerializer.cpp

Issue 2886943003: [Offline Pages] Adding missing image/CSS detection in FrameSerializer. (Closed)
Patch Set: unittests (merged with TOT) Created 3 years, 7 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 | « third_party/WebKit/Source/web/BUILD.gn ('k') | third_party/WebKit/Source/web/WebPageMissingCSSDetector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/WebFrameSerializer.cpp
diff --git a/third_party/WebKit/Source/web/WebFrameSerializer.cpp b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
index 5ae9b75c24659cbfe022424e8fb66b0041688498..838b22f8f153cf0c8ceec788e5a3f275f3906383 100644
--- a/third_party/WebKit/Source/web/WebFrameSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
@@ -61,6 +61,7 @@
#include "platform/wtf/HashMap.h"
#include "platform/wtf/HashSet.h"
#include "platform/wtf/Noncopyable.h"
+#include "platform/wtf/PtrUtil.h"
#include "platform/wtf/Vector.h"
#include "platform/wtf/text/StringConcatenate.h"
#include "public/platform/WebString.h"
@@ -73,6 +74,9 @@
#include "public/web/WebFrameSerializerCacheControlPolicy.h"
#include "public/web/WebFrameSerializerClient.h"
#include "web/WebFrameSerializerImpl.h"
+#include "web/WebPageMissingCSSDetector.h"
+#include "web/WebPageMissingImageDetector.h"
+#include "web/WebPageProblemDetector.h"
#include "web/WebRemoteFrameImpl.h"
namespace blink {
@@ -95,6 +99,7 @@ class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate {
bool ShouldSkipResource(
FrameSerializer::ResourceHasCacheControlNoStoreHeader) override;
Vector<Attribute> GetCustomAttributes(const Element&) override;
+ void VisitNode(const Node*) override;
private:
bool ShouldIgnoreHiddenElement(const Element&);
@@ -107,11 +112,21 @@ class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate {
WebFrameSerializer::MHTMLPartsGenerationDelegate& web_delegate_;
bool popup_overlays_skipped_;
+ WebPageProblemDetectorCollection problem_detectors_;
};
MHTMLFrameSerializerDelegate::MHTMLFrameSerializerDelegate(
WebFrameSerializer::MHTMLPartsGenerationDelegate& web_delegate)
- : web_delegate_(web_delegate), popup_overlays_skipped_(false) {}
+ : web_delegate_(web_delegate), popup_overlays_skipped_(false) {
+ if (web_delegate.UsePageProblemDetectors()) {
+ std::unique_ptr<MissingImageDetector> missing_image_detector(
+ new MissingImageDetector());
dcheng 2017/05/23 05:52:41 Nit: prefer auto missing_image_detector = WTF::Mak
romax 2017/05/27 01:00:04 Done.
+ std::unique_ptr<MissingCSSDetector> missing_css_detector(
+ new MissingCSSDetector());
+ problem_detectors_.AddDetector(std::move(missing_image_detector));
+ problem_detectors_.AddDetector(std::move(missing_css_detector));
+ }
+}
MHTMLFrameSerializerDelegate::~MHTMLFrameSerializerDelegate() {
if (web_delegate_.RemovePopupOverlay()) {
@@ -280,6 +295,10 @@ Vector<Attribute> MHTMLFrameSerializerDelegate::GetCustomAttributes(
return attributes;
}
+void MHTMLFrameSerializerDelegate::VisitNode(const Node* node) {
+ problem_detectors_.VisitNode(node);
+}
+
void MHTMLFrameSerializerDelegate::GetCustomAttributesForImageElement(
const HTMLImageElement& element,
Vector<Attribute>* attributes) {
« no previous file with comments | « third_party/WebKit/Source/web/BUILD.gn ('k') | third_party/WebKit/Source/web/WebPageMissingCSSDetector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698