| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 ~DistillerPageIOS() override; | 30 ~DistillerPageIOS() override; |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 bool StringifyOutput() override; | 33 bool StringifyOutput() override; |
| 34 void DistillPageImpl(const GURL& url, const std::string& script) override; | 34 void DistillPageImpl(const GURL& url, const std::string& script) override; |
| 35 | 35 |
| 36 // Sets the WebState that will be used for the distillation. Do not call | 36 // Sets the WebState that will be used for the distillation. Do not call |
| 37 // between |DistillPageImpl| and |OnDistillationDone|. | 37 // between |DistillPageImpl| and |OnDistillationDone|. |
| 38 virtual void AttachWebState(std::unique_ptr<web::WebState> web_state); | 38 virtual void AttachWebState(std::unique_ptr<web::WebState> web_state); |
| 39 | 39 |
| 40 // Returns the WebState handling the current distillation. |
| 41 web::WebState* CurrentWebState(); |
| 42 |
| 40 // Release the WebState used for distillation. Do not call between | 43 // Release the WebState used for distillation. Do not call between |
| 41 // |DistillPageImpl| and |OnDistillationDone|. | 44 // |DistillPageImpl| and |OnDistillationDone|. |
| 42 virtual std::unique_ptr<web::WebState> DetachWebState(); | 45 virtual std::unique_ptr<web::WebState> DetachWebState(); |
| 43 | 46 |
| 44 // Called by |web_state_observer_| once the page has finished loading. | 47 // Called by |web_state_observer_| once the page has finished loading. |
| 45 virtual void OnLoadURLDone( | 48 virtual void OnLoadURLDone( |
| 46 web::PageLoadCompletionStatus load_completion_status); | 49 web::PageLoadCompletionStatus load_completion_status); |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 friend class DistillerWebStateObserver; | 52 friend class DistillerWebStateObserver; |
| 50 // Called once the |script_| has been evaluated on the page. | 53 // Called once the |script_| has been evaluated on the page. |
| 51 void HandleJavaScriptResult(id result); | 54 void HandleJavaScriptResult(id result); |
| 52 | 55 |
| 53 // Converts result of WKWebView script evaluation to base::Value | 56 // Converts result of WKWebView script evaluation to base::Value |
| 54 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); | 57 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); |
| 55 | 58 |
| 56 GURL url_; | 59 GURL url_; |
| 57 std::string script_; | 60 std::string script_; |
| 58 web::BrowserState* browser_state_; | 61 web::BrowserState* browser_state_; |
| 59 std::unique_ptr<web::WebState> web_state_; | 62 std::unique_ptr<web::WebState> web_state_; |
| 60 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; | 63 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; |
| 61 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; | 64 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; |
| 62 }; | 65 }; |
| 63 | 66 |
| 64 } // namespace dom_distiller | 67 } // namespace dom_distiller |
| 65 | 68 |
| 66 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ | 69 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ |
| OLD | NEW |