| Index: ios/chrome/browser/reading_list/reading_list_distiller_page.mm
|
| diff --git a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
|
| index 6ac1c4ad5b4047feaddfec0173351a24c6b493b1..feb04ff68a3039c35627f729ebad3bbe0546f0f0 100644
|
| --- a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
|
| +++ b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/mac/foundation_util.h"
|
| +#include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "components/favicon/ios/web_favicon_driver.h"
|
| @@ -39,6 +40,13 @@ const char* kGetIframeURLJavaScript =
|
| " }"
|
| " return document.getElementsByTagName('iframe')[0].src;"
|
| "})()";
|
| +
|
| +const char* kWikipediaWorkaround =
|
| + "(() => {"
|
| + " var s = document.createElement('style');"
|
| + " s.innerHTML='.client-js .collapsible-block { display: block }';"
|
| + " document.head.appendChild(s);"
|
| + "})()";
|
| } // namespace
|
|
|
| namespace reading_list {
|
| @@ -175,9 +183,16 @@ void ReadingListDistillerPage::DelayedOnLoadURLDone(int delayed_task_id) {
|
| if (IsGoogleCachedAMPPage()) {
|
| // Workaround for Google AMP pages.
|
| HandleGoogleCachedAMPPage();
|
| - } else {
|
| - ContinuePageDistillation();
|
| + return;
|
| + }
|
| + if (IsWikipediaPage()) {
|
| + // Workaround for Wikipedia pages.
|
| + // TODO(crbug.com/647667): remove workaround once DOM distiller handle this
|
| + // case.
|
| + HandleWikipediaPage();
|
| + return;
|
| }
|
| + ContinuePageDistillation();
|
| }
|
|
|
| void ReadingListDistillerPage::ContinuePageDistillation() {
|
| @@ -257,4 +272,26 @@ bool ReadingListDistillerPage::HandleGoogleCachedAMPPageJavaScriptResult(
|
| return true;
|
| }
|
|
|
| +bool ReadingListDistillerPage::IsWikipediaPage() {
|
| + // All wikipedia pages are in the form "https://xxx.m.wikipedia.org/..."
|
| + const GURL& url = CurrentWebState()->GetLastCommittedURL();
|
| + if (!url.is_valid() || !url.SchemeIs(url::kHttpsScheme)) {
|
| + return false;
|
| + }
|
| + return (base::EndsWith(url.host(), ".m.wikipedia.org",
|
| + base::CompareCase::SENSITIVE));
|
| +}
|
| +
|
| +void ReadingListDistillerPage::HandleWikipediaPage() {
|
| + base::WeakPtr<ReadingListDistillerPage> weak_this =
|
| + weak_ptr_factory_.GetWeakPtr();
|
| + [CurrentWebState()->GetJSInjectionReceiver()
|
| + executeJavaScript:@(kWikipediaWorkaround)
|
| + completionHandler:^(id result, NSError* error) {
|
| + if (weak_this) {
|
| + weak_this->ContinuePageDistillation();
|
| + }
|
| + }];
|
| +}
|
| +
|
| } // namespace reading_list
|
|
|