[WRTjs] Refactor popup
[platform/framework/web/chromium-efl.git] / wrt / src / browser / wrt_browser_context.h
1 // Copyright 2019 Samsung Electronics. 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 BROWSER_WRT_BROWSER_CONTEXT_H_
6 #define BROWSER_WRT_BROWSER_CONTEXT_H_
7
8 #include <string>
9
10 #include "components/visitedlink/browser/visitedlink_delegate.h"
11 #include "electron/shell/browser/electron_browser_context.h"
12 #include "extensions/buildflags/buildflags.h"
13
14 #if BUILDFLAG(IS_TIZEN_TV)
15 #include "tizen_src/ewk/efl_integration/browser/web_cache_efl/web_cache_manager_efl.h"
16 #endif
17
18 namespace visitedlink {
19 class VisitedLinkWriter;
20 }
21
22 namespace wrt {
23
24 class WRTSpecialStoragePolicy;
25
26 class WRTBrowserContext : public electron::ElectronBrowserContext,
27                           public visitedlink::VisitedLinkDelegate {
28  public:
29   static WRTBrowserContext* GetInstance();
30
31   WRTBrowserContext(const electron::PartitionOrPath partition_location,
32                     bool in_memory,
33                     base::Value::Dict options);
34   virtual ~WRTBrowserContext() override;
35
36   WRTBrowserContext(const WRTBrowserContext&) = delete;
37   WRTBrowserContext& operator=(const WRTBrowserContext&) = delete;
38
39   // These methods map to Add methods in visitedlink::VisitedLinkWriter.
40   void AddVisitedURLs(const std::vector<GURL>& urls);
41
42   void DeleteCookies();
43
44   WRTSpecialStoragePolicy* GetWRTSpecialStoragePolicy();
45
46 #if BUILDFLAG(IS_TIZEN_TV)
47   void ClearWebCache();
48 #endif
49
50  private:
51   // visitedlink::VisitedLinkDelegate implementation.
52   void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
53   // Reset visitedlink writer and initialize it.
54   void InitVisitedLinkWriter();
55   storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
56   content::BackgroundSyncController* GetBackgroundSyncController() override;
57
58   std::unique_ptr<visitedlink::VisitedLinkWriter> visitedlink_writer_;
59   scoped_refptr<WRTSpecialStoragePolicy> wrt_special_storage_policy_;
60   std::unique_ptr<content::BackgroundSyncController>
61       background_sync_controller_;
62 #if BUILDFLAG(IS_TIZEN_TV)
63   WebCacheManagerEfl web_cache_manager_;
64 #endif
65 };
66
67 }  // namespace wrt
68
69 #endif  // BROWSER_WRT_BROWSER_CONTEXT_H_