Chromium Code Reviews| 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 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DISTILLER_PAGE_H_ | 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DISTILLER_PAGE_H_ |
| 6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DISTILLER_PAGE_H_ | 6 #define IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DISTILLER_PAGE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 // An DistillerPageIOS that will retain WebState to allow favicon download and | 23 // An DistillerPageIOS that will retain WebState to allow favicon download and |
| 24 // and add a 2 seconds delay between loading and distillation. | 24 // and add a 2 seconds delay between loading and distillation. |
| 25 class ReadingListDistillerPage : public dom_distiller::DistillerPageIOS { | 25 class ReadingListDistillerPage : public dom_distiller::DistillerPageIOS { |
| 26 public: | 26 public: |
| 27 explicit ReadingListDistillerPage( | 27 explicit ReadingListDistillerPage( |
| 28 web::BrowserState* browser_state, | 28 web::BrowserState* browser_state, |
| 29 FaviconWebStateDispatcher* web_state_dispatcher); | 29 FaviconWebStateDispatcher* web_state_dispatcher); |
| 30 ~ReadingListDistillerPage() override; | 30 ~ReadingListDistillerPage() override; |
| 31 | 31 |
| 32 // Sets a callback that will be called just before distillation happen with | |
| 33 // the URL of the page that will effectively be distilled. | |
| 34 typedef base::Callback<void(const GURL&, const GURL&)> RedirectionCallback; | |
| 35 void SetRedirectionCallback(RedirectionCallback redirection_callback); | |
|
jif
2017/01/20 10:23:19
pass the RedirectionCallback by reference
Olivier
2017/01/20 10:47:07
https://cs.chromium.org/chromium/src/docs/callback
| |
| 36 | |
| 32 protected: | 37 protected: |
| 33 void DistillPageImpl(const GURL& url, const std::string& script) override; | 38 void DistillPageImpl(const GURL& url, const std::string& script) override; |
| 34 void OnDistillationDone(const GURL& page_url, | 39 void OnDistillationDone(const GURL& page_url, |
| 35 const base::Value* value) override; | 40 const base::Value* value) override; |
| 36 void OnLoadURLDone( | 41 void OnLoadURLDone( |
| 37 web::PageLoadCompletionStatus load_completion_status) override; | 42 web::PageLoadCompletionStatus load_completion_status) override; |
| 38 | 43 |
| 39 private: | 44 private: |
| 40 // Returns wether there is the loading has no error and if the distillation | 45 // Returns wether there is the loading has no error and if the distillation |
| 41 // can continue. | 46 // can continue. |
| 42 bool IsLoadingSuccess(web::PageLoadCompletionStatus load_completion_status); | 47 bool IsLoadingSuccess(web::PageLoadCompletionStatus load_completion_status); |
| 43 // Work around the fact that articles opened from Google Search page and | 48 // Work around the fact that articles opened from Google Search page and |
| 44 // Google News are presented in an iframe. This method detects if the current | 49 // Google News are presented in an iframe. This method detects if the current |
| 45 // page is a Google AMP and navigate to the iframe in that case. | 50 // page is a Google AMP and navigate to the iframe in that case. |
| 46 // Returns whether the current page is a Google AMP page. | 51 // Returns whether the current page is a Google AMP page. |
| 47 // IsGoogleCachedAMPPage will determine if the current page is a Google AMP | 52 // IsGoogleCachedAMPPage will determine if the current page is a Google AMP |
| 48 // page. | 53 // page. |
| 49 bool IsGoogleCachedAMPPage(); | 54 bool IsGoogleCachedAMPPage(); |
| 50 // HandleGoogleCachedAMPPage will navigate to the iframe containing the actual | 55 // HandleGoogleCachedAMPPage will navigate to the iframe containing the actual |
| 51 // article page. | 56 // article page. |
| 52 void HandleGoogleCachedAMPPage(); | 57 void HandleGoogleCachedAMPPage(); |
| 53 // Handles the JavaScript response. If the URL of the iframe is returned, | 58 // Handles the JavaScript response. If the URL of the iframe is returned, |
| 54 // triggers a navigation to it. Stop distillation of the page there as the new | 59 // triggers a navigation to it. Stop distillation of the page there as the new |
| 55 // load will trigger a new distillation. | 60 // load will trigger a new distillation. |
| 56 bool HandleGoogleCachedAMPPageJavaScriptResult(id result, NSError* error); | 61 bool HandleGoogleCachedAMPPageJavaScriptResult(id result, id error); |
| 57 | 62 |
| 58 // Waits a delay then calls DelayedOnLoadURLDone. | 63 // Waits a delay then calls DelayedOnLoadURLDone. |
| 59 void WaitForPageLoadCompletion(); | 64 void WaitForPageLoadCompletion(); |
| 60 | 65 |
| 61 // Continues distillation by calling superclass |OnLoadURLDone|. | 66 // Continues distillation by calling superclass |OnLoadURLDone|. |
| 62 void DelayedOnLoadURLDone(); | 67 void DelayedOnLoadURLDone(); |
| 63 | 68 |
| 69 RedirectionCallback redirection_callback_; | |
| 70 GURL original_url_; | |
| 71 GURL redirected_url_; | |
| 72 | |
| 64 FaviconWebStateDispatcher* web_state_dispatcher_; | 73 FaviconWebStateDispatcher* web_state_dispatcher_; |
| 65 base::WeakPtrFactory<ReadingListDistillerPage> weak_ptr_factory_; | 74 base::WeakPtrFactory<ReadingListDistillerPage> weak_ptr_factory_; |
| 66 }; | 75 }; |
| 67 | 76 |
| 68 } // namespace reading_list | 77 } // namespace reading_list |
| 69 | 78 |
| 70 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DISTILLER_PAGE_H_ | 79 #endif // IOS_CHROME_BROWSER_READING_LIST_READING_LIST_DISTILLER_PAGE_H_ |
| OLD | NEW |