| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ | 6 #define COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "components/dom_distiller/core/distiller_page.h" | 12 #include "components/dom_distiller/core/distiller_page.h" |
| 13 #include "ios/web/public/web_state/web_state_observer.h" | 13 #include "ios/web/public/web_state/web_state_observer.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace ios { | 16 namespace ios { |
| 17 class WebControllerProvider; | 17 class WebControllerProvider; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace web { | 20 namespace web { |
| 21 class BrowserState; | 21 class BrowserState; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace dom_distiller { | 24 namespace dom_distiller { |
| 25 | 25 |
| 26 class DistillerFaviconIOS; |
| 26 class DistillerWebStateObserver; | 27 class DistillerWebStateObserver; |
| 27 | 28 |
| 28 // Loads URLs and injects JavaScript into a page, extracting the distilled page | 29 // Loads URLs and injects JavaScript into a page, extracting the distilled page |
| 29 // content. | 30 // content. |
| 30 class DistillerPageIOS : public DistillerPage { | 31 class DistillerPageIOS : public DistillerPage { |
| 31 public: | 32 public: |
| 32 explicit DistillerPageIOS(web::BrowserState* browser_state); | 33 explicit DistillerPageIOS(web::BrowserState* browser_state, |
| 34 DistillerFaviconIOS* distiller_favicon); |
| 33 ~DistillerPageIOS() override; | 35 ~DistillerPageIOS() override; |
| 34 | 36 |
| 35 protected: | 37 protected: |
| 36 bool StringifyOutput() override; | 38 bool StringifyOutput() override; |
| 37 void DistillPageImpl(const GURL& url, const std::string& script) override; | 39 void DistillPageImpl(const GURL& url, const std::string& script) override; |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 friend class DistillerWebStateObserver; | 42 friend class DistillerWebStateObserver; |
| 41 | 43 |
| 42 // Called by |web_state_observer_| once the page has finished loading. | 44 // Called by |web_state_observer_| once the page has finished loading. |
| 43 void OnLoadURLDone(web::PageLoadCompletionStatus load_completion_status); | 45 void OnLoadURLDone(web::PageLoadCompletionStatus load_completion_status); |
| 44 | 46 |
| 45 // Called once the |script_| has been evaluated on the page. | 47 // Called once the |script_| has been evaluated on the page. |
| 46 void HandleJavaScriptResult(id result); | 48 void HandleJavaScriptResult(id result); |
| 47 | 49 |
| 48 // Converts result of WKWebView script evaluation to base::Value | 50 // Converts result of WKWebView script evaluation to base::Value |
| 49 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); | 51 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); |
| 50 | 52 |
| 51 web::BrowserState* browser_state_; | 53 // web::BrowserState* browser_state_; |
| 52 GURL url_; | 54 GURL url_; |
| 53 std::string script_; | 55 std::string script_; |
| 54 std::unique_ptr<ios::WebControllerProvider> provider_; | 56 std::unique_ptr<ios::WebControllerProvider> provider_; |
| 55 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; | 57 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; |
| 58 DistillerFaviconIOS* distiller_favicon_; |
| 56 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; | 59 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 } // namespace dom_distiller | 62 } // namespace dom_distiller |
| 60 | 63 |
| 61 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ | 64 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ |
| OLD | NEW |