| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/reading_list/reading_list_distiller_page.h" | 5 #include "ios/chrome/browser/reading_list/reading_list_distiller_page.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Workaround for Wikipedia pages. | 189 // Workaround for Wikipedia pages. |
| 190 // TODO(crbug.com/647667): remove workaround once DOM distiller handle this | 190 // TODO(crbug.com/647667): remove workaround once DOM distiller handle this |
| 191 // case. | 191 // case. |
| 192 HandleWikipediaPage(); | 192 HandleWikipediaPage(); |
| 193 return; | 193 return; |
| 194 } | 194 } |
| 195 ContinuePageDistillation(); | 195 ContinuePageDistillation(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void ReadingListDistillerPage::ContinuePageDistillation() { | 198 void ReadingListDistillerPage::ContinuePageDistillation() { |
| 199 if (!CurrentWebState()) { |
| 200 // Something interrupted the distillation. |
| 201 // Abort here. |
| 202 return; |
| 203 } |
| 199 // The page is ready to be distilled. | 204 // The page is ready to be distilled. |
| 200 // If the visible URL is not the original URL, notify the caller that URL | 205 // If the visible URL is not the original URL, notify the caller that URL |
| 201 // changed. | 206 // changed. |
| 202 GURL redirected_url = CurrentWebState()->GetVisibleURL(); | 207 GURL redirected_url = CurrentWebState()->GetVisibleURL(); |
| 203 if (redirected_url != original_url_ && delegate_) { | 208 if (redirected_url != original_url_ && delegate_) { |
| 204 delegate_->DistilledPageRedirectedToURL(original_url_, redirected_url); | 209 delegate_->DistilledPageRedirectedToURL(original_url_, redirected_url); |
| 205 } | 210 } |
| 206 DistillerPageIOS::OnLoadURLDone(web::PageLoadCompletionStatus::SUCCESS); | 211 DistillerPageIOS::OnLoadURLDone(web::PageLoadCompletionStatus::SUCCESS); |
| 207 } | 212 } |
| 208 | 213 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 [CurrentWebState()->GetJSInjectionReceiver() | 293 [CurrentWebState()->GetJSInjectionReceiver() |
| 289 executeJavaScript:@(kWikipediaWorkaround) | 294 executeJavaScript:@(kWikipediaWorkaround) |
| 290 completionHandler:^(id result, NSError* error) { | 295 completionHandler:^(id result, NSError* error) { |
| 291 if (weak_this) { | 296 if (weak_this) { |
| 292 weak_this->ContinuePageDistillation(); | 297 weak_this->ContinuePageDistillation(); |
| 293 } | 298 } |
| 294 }]; | 299 }]; |
| 295 } | 300 } |
| 296 | 301 |
| 297 } // namespace reading_list | 302 } // namespace reading_list |
| OLD | NEW |