| 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_delegate.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 namespace dom_distiller { | 17 namespace dom_distiller { |
| 18 | 18 |
| 19 class SourcePageHandleWebContents : public SourcePageHandle { | 19 class SourcePageHandleWebContents : public SourcePageHandle { |
| 20 public: | 20 public: |
| 21 explicit SourcePageHandleWebContents( | 21 SourcePageHandleWebContents(content::WebContents* web_contents, bool owned); |
| 22 scoped_ptr<content::WebContents> web_contents); | |
| 23 ~SourcePageHandleWebContents() override; | 22 ~SourcePageHandleWebContents() override; |
| 24 | 23 |
| 25 scoped_ptr<content::WebContents> GetWebContents(); | 24 // Retreives the WebContents. The SourcePageHandleWebContents keeps ownership. |
| 25 content::WebContents* web_contents() { return web_contents_; } |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 // The WebContents this class owns. | 28 // The WebContents this class holds. |
| 29 scoped_ptr<content::WebContents> web_contents_; | 29 content::WebContents* web_contents_; |
| 30 // Whether this owns |web_contents_|. |
| 31 bool owned_; |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 class DistillerPageWebContentsFactory : public DistillerPageFactory { | 34 class DistillerPageWebContentsFactory : public DistillerPageFactory { |
| 33 public: | 35 public: |
| 34 explicit DistillerPageWebContentsFactory( | 36 explicit DistillerPageWebContentsFactory( |
| 35 content::BrowserContext* browser_context) | 37 content::BrowserContext* browser_context) |
| 36 : DistillerPageFactory(), browser_context_(browser_context) {} | 38 : DistillerPageFactory(), browser_context_(browser_context) {} |
| 37 ~DistillerPageWebContentsFactory() override {} | 39 ~DistillerPageWebContentsFactory() override {} |
| 38 | 40 |
| 39 scoped_ptr<DistillerPage> CreateDistillerPage( | 41 scoped_ptr<DistillerPage> CreateDistillerPage( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Called when the distillation is done or if the page load failed. | 101 // Called when the distillation is done or if the page load failed. |
| 100 void OnWebContentsDistillationDone(const GURL& page_url, | 102 void OnWebContentsDistillationDone(const GURL& page_url, |
| 101 const base::Value* value); | 103 const base::Value* value); |
| 102 | 104 |
| 103 // The current state of the |DistillerPage|, initially |IDLE|. | 105 // The current state of the |DistillerPage|, initially |IDLE|. |
| 104 State state_; | 106 State state_; |
| 105 | 107 |
| 106 // The JavaScript to inject to extract content. | 108 // The JavaScript to inject to extract content. |
| 107 std::string script_; | 109 std::string script_; |
| 108 | 110 |
| 109 scoped_ptr<content::WebContents> web_contents_; | 111 scoped_ptr<SourcePageHandleWebContents> source_page_handle_; |
| 112 |
| 110 content::BrowserContext* browser_context_; | 113 content::BrowserContext* browser_context_; |
| 111 gfx::Size render_view_size_; | 114 gfx::Size render_view_size_; |
| 112 DISALLOW_COPY_AND_ASSIGN(DistillerPageWebContents); | 115 DISALLOW_COPY_AND_ASSIGN(DistillerPageWebContents); |
| 113 }; | 116 }; |
| 114 | 117 |
| 115 } // namespace dom_distiller | 118 } // namespace dom_distiller |
| 116 | 119 |
| 117 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_ | 120 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_ |
| OLD | NEW |