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

Unified Diff: components/dom_distiller/content/browser/distillable_page_utils.cc

Issue 1248643004: Test distillability without JavaScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@early
Patch Set: fix oopsies Created 5 years, 2 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: components/dom_distiller/content/browser/distillable_page_utils.cc
diff --git a/components/dom_distiller/content/browser/distillable_page_utils.cc b/components/dom_distiller/content/browser/distillable_page_utils.cc
index 5487c62e87dc4e0eda1daecad009f9dd20463709..f5f1fd57a2a9156259d4d9a39902f3f98e4fefe6 100644
--- a/components/dom_distiller/content/browser/distillable_page_utils.cc
+++ b/components/dom_distiller/content/browser/distillable_page_utils.cc
@@ -10,7 +10,9 @@
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "base/values.h"
+#include "components/dom_distiller/content/browser/distillability_driver.h"
#include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
+#include "components/dom_distiller/content/common/distiller_messages.h"
#include "components/dom_distiller/core/distillable_page_detector.h"
#include "components/dom_distiller/core/experiments.h"
#include "components/dom_distiller/core/page_features.h"
@@ -20,6 +22,7 @@
namespace dom_distiller {
namespace {
+
void OnOGArticleJsResult(base::Callback<void(bool)> callback,
const base::Value* result) {
bool success = false;
@@ -28,12 +31,38 @@ void OnOGArticleJsResult(base::Callback<void(bool)> callback,
}
callback.Run(success);
}
+/*
+void OnExtractFeaturesNativeResult(
+ const DistillablePageDetector* detector,
+ base::Callback<void(bool)> callback,
+ bool isOGArticle,
+ const std::string& url,
+ int numElements,
+ int numAnchors,
+ int numForms,
+ const std::string& innerText,
+ const std::string& textContent,
+ const std::string& innerHTML) {
-void OnExtractFeaturesJsResult(const DistillablePageDetector* detector,
- base::Callback<void(bool)> callback,
- const base::Value* result) {
- callback.Run(detector->Classify(CalculateDerivedFeaturesFromJSON(result)));
+ GURL parsed_url(url);
+ if (!parsed_url.is_valid()) {
+ callback.Run(false);
+ return;
+ }
+
+ auto res = CalculateDerivedFeatures(
+ isOGArticle,
+ parsed_url,
+ numElements,
+ numAnchors,
+ numForms,
+ innerText,
+ textContent,
+ innerHTML
+ );
+ callback.Run(detector->Classify(res));
}
+*/
} // namespace
void IsOpenGraphArticle(content::WebContents* web_contents,
@@ -89,13 +118,15 @@ void IsDistillablePageForDetector(content::WebContents* web_contents,
base::Bind(callback, false));
return;
}
- std::string extract_features_js =
- ResourceBundle::GetSharedInstance()
- .GetRawDataResource(IDR_EXTRACT_PAGE_FEATURES_JS)
- .as_string();
- RunIsolatedJavaScript(
- main_frame, extract_features_js,
- base::Bind(OnExtractFeaturesJsResult, detector, callback));
+
+ WebContentsDistillabilityDriver::CreateForWebContents(web_contents);
+ WebContentsDistillabilityDriver *driver =
+ WebContentsDistillabilityDriver::FromWebContents(web_contents);
+ CHECK(driver);
+ /*
+ driver->ExtractFeatures(
+ base::Bind(OnExtractFeaturesNativeResult, detector, callback));
+ */
}
} // namespace dom_distiller

Powered by Google App Engine
This is Rietveld 408576698