blob: 9c15165bbbdd06ba75b89aab1b0d6cd796f72a49 [file] [log] [blame]
[email protected]7e856dde2014-03-15 00:34:051// Copyright 2014 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.
4
5#ifndef CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_
6#define CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_
7
dchengc0e39d572016-04-19 06:15:178#include <memory>
9
avie4d7b6f2015-12-26 00:59:1810#include "base/macros.h"
Evan Stadeeb9d25f2019-10-03 16:21:1111#include "base/supports_user_data.h"
[email protected]7e856dde2014-03-15 00:34:0512#include "components/dom_distiller/core/dom_distiller_service.h"
13#include "components/dom_distiller/core/task_tracker.h"
[email protected]7e856dde2014-03-15 00:34:0514
15class Profile;
16
17namespace dom_distiller {
18
[email protected]7e856dde2014-03-15 00:34:0519// A class which helps with lazy instantiation of the DomDistillerService, using
Evan Stadeeb9d25f2019-10-03 16:21:1120// the BrowserContextKeyedServiceFactory for it. This class is owned by Profile.
[email protected]7e856dde2014-03-15 00:34:0521class LazyDomDistillerService : public DomDistillerServiceInterface,
Evan Stadeeb9d25f2019-10-03 16:21:1122 public base::SupportsUserData::Data {
[email protected]7e856dde2014-03-15 00:34:0523 public:
Evan Stadeeb9d25f2019-10-03 16:21:1124 // Creates and returns an instance for |profile|. This does not pass ownership
25 // of the returned pointer.
26 static LazyDomDistillerService* Create(Profile* profile);
27
Daniel Chenga542fca2014-10-21 09:51:2928 ~LazyDomDistillerService() override;
[email protected]7e856dde2014-03-15 00:34:0529
[email protected]7e856dde2014-03-15 00:34:0530 // DomDistillerServiceInterface implementation:
Daniel Chenga542fca2014-10-21 09:51:2931 bool HasEntry(const std::string& entry_id) override;
32 std::string GetUrlForEntry(const std::string& entry_id) override;
dcheng4af48582016-04-19 00:29:3533 std::unique_ptr<ViewerHandle> ViewEntry(
34 ViewRequestDelegate* delegate,
35 std::unique_ptr<DistillerPage> distiller_page,
36 const std::string& entry_id) override;
37 std::unique_ptr<ViewerHandle> ViewUrl(
38 ViewRequestDelegate* delegate,
39 std::unique_ptr<DistillerPage> distiller_page,
40 const GURL& url) override;
41 std::unique_ptr<DistillerPage> CreateDefaultDistillerPage(
mostynb01d8b10e2014-10-13 09:44:4442 const gfx::Size& render_view_size) override;
dcheng4af48582016-04-19 00:29:3543 std::unique_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle(
44 std::unique_ptr<SourcePageHandle> handle) override;
Daniel Chenga542fca2014-10-21 09:51:2945 DistilledPagePrefs* GetDistilledPagePrefs() override;
[email protected]7e856dde2014-03-15 00:34:0546
47 private:
Evan Stadeeb9d25f2019-10-03 16:21:1148 explicit LazyDomDistillerService(Profile* profile);
[email protected]7e856dde2014-03-15 00:34:0549
Evan Stadeeb9d25f2019-10-03 16:21:1150 // Accessor method for the backing service instance.
51 DomDistillerServiceInterface* GetImpl() const;
[email protected]7e856dde2014-03-15 00:34:0552
53 // The Profile to use when retrieving the DomDistillerService and also the
54 // profile to listen for destruction of.
55 Profile* profile_;
56
[email protected]7e856dde2014-03-15 00:34:0557 DISALLOW_COPY_AND_ASSIGN(LazyDomDistillerService);
58};
59
60} // namespace dom_distiller
61
62#endif // CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_