- add sources.
[platform/framework/web/crosswalk.git] / src / components / dom_distiller / core / dom_distiller_service.h
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.
4
5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_
6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "components/dom_distiller/core/article_entry.h"
12 #include "components/dom_distiller/core/distiller.h"
13 #include "url/gurl.h"
14
15 namespace syncer {
16 class SyncableService;
17 }
18
19 namespace dom_distiller {
20
21 class DistillerFactory;
22 class DomDistillerStoreInterface;
23 class ViewerContext;
24
25 // A handle to a request to view a DOM distiller entry or URL. The request will
26 // be cancelled when the handle is destroyed.
27 class ViewerHandle {
28  public:
29   ViewerHandle();
30   ~ViewerHandle();
31
32  private:
33   DISALLOW_COPY_AND_ASSIGN(ViewerHandle);
34 };
35
36 // Provide a view of the article list and ways of interacting with it.
37 class DomDistillerService {
38  public:
39   DomDistillerService(scoped_ptr<DomDistillerStoreInterface> store,
40                       scoped_ptr<DistillerFactory> distiller_factory);
41   ~DomDistillerService();
42
43   syncer::SyncableService* GetSyncableService() const;
44
45   // Distill the article at |url| and add the resulting entry to the DOM
46   // distiller list.
47   void AddToList(const GURL& url);
48
49   // Gets the full list of entries.
50   std::vector<ArticleEntry> GetEntries() const;
51
52   // Request to view an article by entry id. Returns a null pointer if no entry
53   // with |entry_id| exists.
54   scoped_ptr<ViewerHandle> ViewEntry(ViewerContext* context,
55                                      const std::string& entry_id);
56
57   // Request to view an article by url.
58   scoped_ptr<ViewerHandle> ViewUrl(ViewerContext* context, const GURL& url);
59
60  private:
61   scoped_ptr<DomDistillerStoreInterface> store_;
62   scoped_ptr<DistillerFactory> distiller_factory_;
63
64   DISALLOW_COPY_AND_ASSIGN(DomDistillerService);
65 };
66
67 }  // namespace dom_distiller
68
69 #endif  // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_