Chromium Code Reviews| 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 "components/dom_distiller/ios/favicon_web_state_dispatcher.h" | |
| 14 #include "ios/web/public/web_state/web_state_observer.h" | 13 #include "ios/web/public/web_state/web_state_observer.h" |
|
gambard
2016/12/27 13:56:57
Is this import needed?
Olivier
2016/12/27 14:52:14
Yes. (PageComplectionStatus enum).
| |
| 15 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 16 | 15 |
| 16 namespace web { | |
| 17 class BrowserState; | |
| 18 } | |
| 19 | |
| 17 namespace dom_distiller { | 20 namespace dom_distiller { |
| 18 | 21 |
| 19 class DistillerWebStateObserver; | 22 class DistillerWebStateObserver; |
| 20 | 23 |
| 21 // Loads URLs and injects JavaScript into a page, extracting the distilled page | 24 // Loads URLs and injects JavaScript into a page, extracting the distilled page |
| 22 // content. | 25 // content. |
| 23 class DistillerPageIOS : public DistillerPage { | 26 class DistillerPageIOS : public DistillerPage { |
| 24 public: | 27 public: |
| 25 explicit DistillerPageIOS(FaviconWebStateDispatcher* web_state_dispatcher); | 28 explicit DistillerPageIOS(web::BrowserState* browser_state); |
| 26 ~DistillerPageIOS() override; | 29 ~DistillerPageIOS() override; |
| 27 | 30 |
| 28 protected: | 31 protected: |
| 29 bool StringifyOutput() override; | 32 bool StringifyOutput() override; |
| 30 void DistillPageImpl(const GURL& url, const std::string& script) override; | 33 void DistillPageImpl(const GURL& url, const std::string& script) override; |
| 31 | 34 |
| 35 virtual void AttachWebState(std::unique_ptr<web::WebState> web_state); | |
|
gambard
2016/12/27 13:56:57
Comment
Olivier
2016/12/27 14:52:14
Done.
| |
| 36 virtual std::unique_ptr<web::WebState> DetachWebState(); | |
| 37 | |
| 38 // Called by |web_state_observer_| once the page has finished loading. | |
| 39 virtual void OnLoadURLDone( | |
| 40 web::PageLoadCompletionStatus load_completion_status); | |
| 41 | |
| 32 private: | 42 private: |
| 33 friend class DistillerWebStateObserver; | 43 friend class DistillerWebStateObserver; |
| 34 | |
| 35 // Called by |web_state_observer_| once the page has finished loading. | |
| 36 void OnLoadURLDone(web::PageLoadCompletionStatus load_completion_status); | |
| 37 | |
| 38 // Called once the |script_| has been evaluated on the page. | 44 // Called once the |script_| has been evaluated on the page. |
| 39 void HandleJavaScriptResult(id result); | 45 void HandleJavaScriptResult(id result); |
| 40 | 46 |
| 41 // Converts result of WKWebView script evaluation to base::Value | 47 // Converts result of WKWebView script evaluation to base::Value |
| 42 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); | 48 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); |
| 43 | 49 |
| 44 GURL url_; | 50 GURL url_; |
| 45 std::string script_; | 51 std::string script_; |
| 46 web::WebState* web_state_; | 52 web::BrowserState* browser_state_; |
| 47 FaviconWebStateDispatcher* web_state_dispatcher_; | 53 std::unique_ptr<web::WebState> web_state_; |
| 48 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; | 54 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; |
| 49 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; | 55 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; |
| 50 }; | 56 }; |
| 51 | 57 |
| 52 } // namespace dom_distiller | 58 } // namespace dom_distiller |
| 53 | 59 |
| 54 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ | 60 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ |
| OLD | NEW |