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 |