| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CONTENT_BROWSER_DISTILLER_PAGE_WEB_CONTENTS_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_PAGE_WEB_CONTENTS_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_PAGE_WEB_CONTENTS_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_PAGE_WEB_CONTENTS_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "components/dom_distiller/core/distiller_page.h" | 12 #include "components/dom_distiller/core/distiller_page.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_contents_delegate.h" | 14 #include "content/public/browser/web_contents_delegate.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace dom_distiller { | 18 namespace dom_distiller { |
| 19 | 19 |
| 20 class SourcePageHandleWebContents : public SourcePageHandle { | 20 class SourcePageHandleWebContents : public SourcePageHandle { |
| 21 public: | 21 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 32 bool owned_; | 32 bool owned_; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 class DistillerPageWebContentsFactory : public DistillerPageFactory { | 35 class DistillerPageWebContentsFactory : public DistillerPageFactory { |
| 36 public: | 36 public: |
| 37 explicit DistillerPageWebContentsFactory( | 37 explicit DistillerPageWebContentsFactory( |
| 38 content::BrowserContext* browser_context) | 38 content::BrowserContext* browser_context) |
| 39 : DistillerPageFactory(), browser_context_(browser_context) {} | 39 : DistillerPageFactory(), browser_context_(browser_context) {} |
| 40 ~DistillerPageWebContentsFactory() override {} | 40 ~DistillerPageWebContentsFactory() override {} |
| 41 | 41 |
| 42 scoped_ptr<DistillerPage> CreateDistillerPage( | 42 std::unique_ptr<DistillerPage> CreateDistillerPage( |
| 43 const gfx::Size& render_view_size) const override; | 43 const gfx::Size& render_view_size) const override; |
| 44 scoped_ptr<DistillerPage> CreateDistillerPageWithHandle( | 44 std::unique_ptr<DistillerPage> CreateDistillerPageWithHandle( |
| 45 scoped_ptr<SourcePageHandle> handle) const override; | 45 std::unique_ptr<SourcePageHandle> handle) const override; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 content::BrowserContext* browser_context_; | 48 content::BrowserContext* browser_context_; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 class DistillerPageWebContents : public DistillerPage, | 51 class DistillerPageWebContents : public DistillerPage, |
| 52 public content::WebContentsDelegate, | 52 public content::WebContentsDelegate, |
| 53 public content::WebContentsObserver { | 53 public content::WebContentsObserver { |
| 54 public: | 54 public: |
| 55 DistillerPageWebContents( | 55 DistillerPageWebContents(content::BrowserContext* browser_context, |
| 56 content::BrowserContext* browser_context, | 56 const gfx::Size& render_view_size, |
| 57 const gfx::Size& render_view_size, | 57 std::unique_ptr<SourcePageHandleWebContents> |
| 58 scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle); | 58 optional_web_contents_handle); |
| 59 ~DistillerPageWebContents() override; | 59 ~DistillerPageWebContents() override; |
| 60 | 60 |
| 61 // content::WebContentsDelegate implementation. | 61 // content::WebContentsDelegate implementation. |
| 62 gfx::Size GetSizeForNewRenderView( | 62 gfx::Size GetSizeForNewRenderView( |
| 63 content::WebContents* web_contents) const override; | 63 content::WebContents* web_contents) const override; |
| 64 | 64 |
| 65 // content::WebContentsObserver implementation. | 65 // content::WebContentsObserver implementation. |
| 66 void DocumentLoadedInFrame( | 66 void DocumentLoadedInFrame( |
| 67 content::RenderFrameHost* render_frame_host) override; | 67 content::RenderFrameHost* render_frame_host) override; |
| 68 | 68 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 void OnWebContentsDistillationDone(const GURL& page_url, | 103 void OnWebContentsDistillationDone(const GURL& page_url, |
| 104 const base::TimeTicks& javascript_start, | 104 const base::TimeTicks& javascript_start, |
| 105 const base::Value* value); | 105 const base::Value* value); |
| 106 | 106 |
| 107 // The current state of the |DistillerPage|, initially |IDLE|. | 107 // The current state of the |DistillerPage|, initially |IDLE|. |
| 108 State state_; | 108 State state_; |
| 109 | 109 |
| 110 // The JavaScript to inject to extract content. | 110 // The JavaScript to inject to extract content. |
| 111 std::string script_; | 111 std::string script_; |
| 112 | 112 |
| 113 scoped_ptr<SourcePageHandleWebContents> source_page_handle_; | 113 std::unique_ptr<SourcePageHandleWebContents> source_page_handle_; |
| 114 | 114 |
| 115 content::BrowserContext* browser_context_; | 115 content::BrowserContext* browser_context_; |
| 116 gfx::Size render_view_size_; | 116 gfx::Size render_view_size_; |
| 117 base::WeakPtrFactory<DistillerPageWebContents> weak_factory_; | 117 base::WeakPtrFactory<DistillerPageWebContents> weak_factory_; |
| 118 DISALLOW_COPY_AND_ASSIGN(DistillerPageWebContents); | 118 DISALLOW_COPY_AND_ASSIGN(DistillerPageWebContents); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 } // namespace dom_distiller | 121 } // namespace dom_distiller |
| 122 | 122 |
| 123 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_PAGE_WEB_CONTENTS_
H_ | 123 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_BROWSER_DISTILLER_PAGE_WEB_CONTENTS_
H_ |
| OLD | NEW |