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 "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 { | |
| 17 class WebControllerProvider; | |
| 18 } | |
| 19 | |
| 20 namespace web { | 16 namespace web { |
| 21 class BrowserState; | 17 class WebState; |
| 22 } | 18 } |
| 23 | 19 |
| 24 namespace dom_distiller { | 20 namespace dom_distiller { |
| 25 | 21 |
| 26 class DistillerWebStateObserver; | 22 class DistillerWebStateObserver; |
| 27 | 23 |
| 28 // 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 |
| 29 // content. | 25 // content. |
| 30 class DistillerPageIOS : public DistillerPage { | 26 class DistillerPageIOS : public DistillerPage { |
|
Olivier
2016/12/08 18:28:02
May be you can implement FaviconDriverObserver her
gambard
2016/12/12 15:04:26
Acknowledged.
| |
| 31 public: | 27 public: |
| 32 explicit DistillerPageIOS(web::BrowserState* browser_state); | 28 explicit DistillerPageIOS(web::WebState* web_state); |
| 33 ~DistillerPageIOS() override; | 29 ~DistillerPageIOS() override; |
| 30 void test(const base::Value*); | |
|
Eugene But (OOO till 7-30)
2016/12/08 15:34:53
I guess this was added for testing or something.
gambard
2016/12/12 15:04:26
Done.
| |
| 34 | 31 |
| 35 protected: | 32 protected: |
| 36 bool StringifyOutput() override; | 33 bool StringifyOutput() override; |
| 37 void DistillPageImpl(const GURL& url, const std::string& script) override; | 34 void DistillPageImpl(const GURL& url, const std::string& script) override; |
| 38 | 35 |
| 39 private: | 36 private: |
| 40 friend class DistillerWebStateObserver; | 37 friend class DistillerWebStateObserver; |
| 41 | 38 |
| 42 // Called by |web_state_observer_| once the page has finished loading. | 39 // Called by |web_state_observer_| once the page has finished loading. |
| 43 void OnLoadURLDone(web::PageLoadCompletionStatus load_completion_status); | 40 void OnLoadURLDone(web::PageLoadCompletionStatus load_completion_status); |
| 44 | 41 |
| 45 // Called once the |script_| has been evaluated on the page. | 42 // Called once the |script_| has been evaluated on the page. |
| 46 void HandleJavaScriptResult(id result); | 43 void HandleJavaScriptResult(id result); |
| 47 | 44 |
| 48 // Converts result of WKWebView script evaluation to base::Value | 45 // Converts result of WKWebView script evaluation to base::Value |
| 49 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); | 46 std::unique_ptr<base::Value> ValueResultFromScriptResult(id wk_result); |
| 50 | 47 |
| 51 web::BrowserState* browser_state_; | |
| 52 GURL url_; | 48 GURL url_; |
| 53 std::string script_; | 49 std::string script_; |
| 54 std::unique_ptr<ios::WebControllerProvider> provider_; | 50 web::WebState* web_state_; |
| 55 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; | 51 std::unique_ptr<DistillerWebStateObserver> web_state_observer_; |
| 56 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; | 52 base::WeakPtrFactory<DistillerPageIOS> weak_ptr_factory_; |
| 57 }; | 53 }; |
| 58 | 54 |
| 59 } // namespace dom_distiller | 55 } // namespace dom_distiller |
| 60 | 56 |
| 61 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ | 57 #endif // COMPONENTS_DOM_DISTILLER_IOS_DISTILLER_PAGE_IOS_H_ |
| OLD | NEW |