| 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_DISTILLER_PAGE_WEB_CONTENTS_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "components/dom_distiller/core/distiller_page.h" | 11 #include "components/dom_distiller/core/distiller_page.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_delegate.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 namespace dom_distiller { | 17 namespace dom_distiller { |
| 17 | 18 |
| 18 class SourcePageHandleWebContents : public SourcePageHandle { | 19 class SourcePageHandleWebContents : public SourcePageHandle { |
| 19 public: | 20 public: |
| 20 explicit SourcePageHandleWebContents( | 21 explicit SourcePageHandleWebContents( |
| 21 scoped_ptr<content::WebContents> web_contents); | 22 scoped_ptr<content::WebContents> web_contents); |
| 22 virtual ~SourcePageHandleWebContents(); | 23 virtual ~SourcePageHandleWebContents(); |
| 23 | 24 |
| 24 scoped_ptr<content::WebContents> GetWebContents(); | 25 scoped_ptr<content::WebContents> GetWebContents(); |
| 25 | 26 |
| 26 private: | 27 private: |
| 27 // The WebContents this class owns. | 28 // The WebContents this class owns. |
| 28 scoped_ptr<content::WebContents> web_contents_; | 29 scoped_ptr<content::WebContents> web_contents_; |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 class DistillerPageWebContentsFactory : public DistillerPageFactory { | 32 class DistillerPageWebContentsFactory : public DistillerPageFactory { |
| 32 public: | 33 public: |
| 33 explicit DistillerPageWebContentsFactory( | 34 explicit DistillerPageWebContentsFactory( |
| 34 content::BrowserContext* browser_context) | 35 content::BrowserContext* browser_context) |
| 35 : DistillerPageFactory(), browser_context_(browser_context) {} | 36 : DistillerPageFactory(), browser_context_(browser_context) {} |
| 36 virtual ~DistillerPageWebContentsFactory() {} | 37 virtual ~DistillerPageWebContentsFactory() {} |
| 37 | 38 |
| 38 virtual scoped_ptr<DistillerPage> CreateDistillerPage() const OVERRIDE; | 39 virtual scoped_ptr<DistillerPage> CreateDistillerPage( |
| 40 const gfx::Size& render_view_size) const OVERRIDE; |
| 39 virtual scoped_ptr<DistillerPage> CreateDistillerPageWithHandle( | 41 virtual scoped_ptr<DistillerPage> CreateDistillerPageWithHandle( |
| 40 scoped_ptr<SourcePageHandle> handle) const OVERRIDE; | 42 scoped_ptr<SourcePageHandle> handle) const OVERRIDE; |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 content::BrowserContext* browser_context_; | 45 content::BrowserContext* browser_context_; |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 class DistillerPageWebContents : public DistillerPage, | 48 class DistillerPageWebContents : public DistillerPage, |
| 49 public content::WebContentsDelegate, |
| 47 public content::WebContentsObserver { | 50 public content::WebContentsObserver { |
| 48 public: | 51 public: |
| 49 DistillerPageWebContents( | 52 DistillerPageWebContents( |
| 50 content::BrowserContext* browser_context, | 53 content::BrowserContext* browser_context, |
| 54 const gfx::Size& render_view_size, |
| 51 scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle); | 55 scoped_ptr<SourcePageHandleWebContents> optional_web_contents_handle); |
| 52 virtual ~DistillerPageWebContents(); | 56 virtual ~DistillerPageWebContents(); |
| 53 | 57 |
| 58 // content::WebContentsDelegate implementation. |
| 59 virtual gfx::Size GetSizeForNewRenderView( |
| 60 content::WebContents* web_contents) const OVERRIDE; |
| 61 |
| 54 // content::WebContentsObserver implementation. | 62 // content::WebContentsObserver implementation. |
| 55 virtual void DocumentLoadedInFrame( | 63 virtual void DocumentLoadedInFrame( |
| 56 content::RenderFrameHost* render_frame_host) OVERRIDE; | 64 content::RenderFrameHost* render_frame_host) OVERRIDE; |
| 57 | 65 |
| 58 virtual void DidFailLoad(content::RenderFrameHost* render_frame_host, | 66 virtual void DidFailLoad(content::RenderFrameHost* render_frame_host, |
| 59 const GURL& validated_url, | 67 const GURL& validated_url, |
| 60 int error_code, | 68 int error_code, |
| 61 const base::string16& error_description) OVERRIDE; | 69 const base::string16& error_description) OVERRIDE; |
| 62 | 70 |
| 63 protected: | 71 protected: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 92 const base::Value* value); | 100 const base::Value* value); |
| 93 | 101 |
| 94 // The current state of the |DistillerPage|, initially |IDLE|. | 102 // The current state of the |DistillerPage|, initially |IDLE|. |
| 95 State state_; | 103 State state_; |
| 96 | 104 |
| 97 // The JavaScript to inject to extract content. | 105 // The JavaScript to inject to extract content. |
| 98 std::string script_; | 106 std::string script_; |
| 99 | 107 |
| 100 scoped_ptr<content::WebContents> web_contents_; | 108 scoped_ptr<content::WebContents> web_contents_; |
| 101 content::BrowserContext* browser_context_; | 109 content::BrowserContext* browser_context_; |
| 110 gfx::Size render_view_size_; |
| 102 DISALLOW_COPY_AND_ASSIGN(DistillerPageWebContents); | 111 DISALLOW_COPY_AND_ASSIGN(DistillerPageWebContents); |
| 103 }; | 112 }; |
| 104 | 113 |
| 105 } // namespace dom_distiller | 114 } // namespace dom_distiller |
| 106 | 115 |
| 107 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_ | 116 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_ |
| OLD | NEW |