| 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 web::WebState* CurrentWebState(); |
| 41 |
| 40 // Release the WebState used for distillation. Do not call between | 42 // Release the WebState used for distillation. Do not call between |
| 41 // |DistillPageImpl| and |OnDistillationDone|. | 43 // |DistillPageImpl| and |OnDistillationDone|. |
| 42 virtual std::unique_ptr<web::WebState> DetachWebState(); | 44 virtual std::unique_ptr<web::WebState> DetachWebState(); |
| 43 | 45 |
| 44 // Called by |web_state_observer_| once the page has finished loading. | 46 // Called by |web_state_observer_| once the page has finished loading. |
| 45 virtual void OnLoadURLDone( | 47 virtual void OnLoadURLDone( |
| 46 web::PageLoadCompletionStatus load_completion_status); | 48 web::PageLoadCompletionStatus load_completion_status); |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 friend class DistillerWebStateObserver; | 51 friend class DistillerWebStateObserver; |
| 50 // Called once the |script_| has been evaluated on the page. | 52 // Called once the |script_| has been evaluated on the page. |
| 51 void HandleJavaScriptResult(id result); | 53 void HandleJavaScriptResult(id result); |
| 52 | 54 |
| 53 // Converts result of WKWebView script evaluation to base::Value | 55 // Converts result of WKWebView script evaluation to base::Value |
| 54 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); | 56 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); |
| 55 | 57 |
| 56 GURL url_; | 58 GURL url_; |
| 57 std::string script_; | 59 std::string script_; |
| 58 web::BrowserState* browser_state_; | 60 web::BrowserState* browser_state_; |
| 59 std::unique_ptr<web::WebState> web_state_; | 61 std::unique_ptr<web::WebState> web_state_; |
| 60 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; | 62 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; |
| 61 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; | 63 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 } // namespace dom_distiller | 66 } // namespace dom_distiller |
| 65 | 67 |
| 66 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ | 68 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ |
| OLD | NEW |