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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_
6 #define COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "components/dom_distiller/core/distiller_page.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_contents_observer.h"
20 using content::RenderViewHost;
22 namespace dom_distiller {
24 class DistillerContext;
26 class DistillerPageWebContentsFactory : public DistillerPageFactory {
28 explicit DistillerPageWebContentsFactory(
29 content::BrowserContext* browser_context)
30 : DistillerPageFactory(), browser_context_(browser_context) {}
31 virtual ~DistillerPageWebContentsFactory() {}
33 virtual scoped_ptr<DistillerPage> CreateDistillerPage(
34 const base::WeakPtr<DistillerPage::Delegate>& delegate) const OVERRIDE;
37 content::BrowserContext* browser_context_;
41 class DistillerPageWebContents : public DistillerPage,
42 public content::WebContentsObserver {
44 DistillerPageWebContents(const base::WeakPtr<Delegate>& delegate,
45 content::BrowserContext* browser_context);
46 virtual ~DistillerPageWebContents();
48 // content::WebContentsObserver implementation.
49 virtual void DocumentLoadedInFrame(int64 frame_id,
50 RenderViewHost* render_view_host) OVERRIDE;
52 virtual void DidFailLoad(int64 frame_id,
53 const GURL& validated_url,
56 const base::string16& error_description,
57 RenderViewHost* render_view_host) OVERRIDE;
60 virtual void InitImpl() OVERRIDE;
61 virtual void LoadURLImpl(const GURL& gurl) OVERRIDE;
62 virtual void ExecuteJavaScriptImpl(const std::string& script) OVERRIDE;
65 scoped_ptr<content::WebContents> web_contents_;
66 content::BrowserContext* browser_context_;
67 DISALLOW_COPY_AND_ASSIGN(DistillerPageWebContents);
70 } // namespace dom_distiller
72 #endif // COMPONENTS_DOM_DISTILLER_CONTENT_DISTILLER_PAGE_WEB_CONTENTS_H_