Switch to new internal chromium branch dev/m38_2114 .
[platform/framework/web/chromium-efl.git] / tizen_src / impl / browser_context_efl.h
1 /*
2    Copyright (C) 2014 Samsung Electronics
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Library General Public
6     License as published by the Free Software Foundation; either
7     version 2 of the License, or (at your option) any later version.
8
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Library General Public License for more details.
13
14     You should have received a copy of the GNU Library General Public License
15     along with this library; see the file COPYING.LIB.  If not, write to
16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17     Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef BROWSER_CONTEXT_EFL
21 #define BROWSER_CONTEXT_EFL
22
23 #include <vector>
24
25 #include "base/memory/scoped_ptr.h"
26 #include "base/files/scoped_temp_dir.h"
27 #include "components/visitedlink/browser/visitedlink_delegate.h"
28 #include "components/visitedlink/browser/visitedlink_master.h"
29 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/storage_partition.h"
32 #include "content/public/browser/resource_context.h"
33 #include "url_request_context_getter_efl.h"
34 #include "browser/notification/notification_controller_efl.h"
35 #include "browser/download_manager_delegate_efl.h"
36 #include "net/url_request/url_request_context.h"
37
38 class EWebContext;
39
40 namespace content {
41
42 class BrowserContextEfl
43   : public BrowserContext,
44     public visitedlink::VisitedLinkDelegate {
45  public:
46   BrowserContextEfl(EWebContext*);
47   ~BrowserContextEfl();
48
49   virtual bool IsOffTheRecord() const OVERRIDE { return false; }
50   virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
51   URLRequestContextGetterEfl* GetRequestContextEfl()
52   { return request_context_getter_.get(); }
53   virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(int) OVERRIDE
54   { return GetRequestContext(); }
55   virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE
56   { return GetRequestContext(); }
57   virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int) OVERRIDE
58   { return GetRequestContext(); }
59   virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
60       const base::FilePath&, bool) OVERRIDE
61   { return GetRequestContext(); }
62
63   // These methods map to Add methods in visitedlink::VisitedLinkMaster.
64   void AddVisitedURLs(const std::vector<GURL>& urls);
65   // visitedlink::VisitedLinkDelegate implementation.
66   virtual void RebuildTable(
67       const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE;
68   // Reset visitedlink master and initialize it.
69   void InitVisitedLinkMaster();
70
71   virtual ResourceContext* GetResourceContext() OVERRIDE;
72
73   virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE
74   { return &download_manager_delegate_; }
75
76   virtual BrowserPluginGuestManager* GetGuestManager() OVERRIDE
77   { return 0; }
78
79   virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE
80   { return 0; }
81
82   virtual PushMessagingService* GetPushMessagingService() OVERRIDE
83   { return 0; }
84
85   virtual base::FilePath GetPath() const OVERRIDE;
86
87   net::URLRequestContextGetter* CreateRequestContext(
88       content::ProtocolHandlerMap* protocol_handlers,
89       URLRequestInterceptorScopedVector request_interceptors);
90   void SetCertificate(const char* certificate_file);
91   EWebContext* WebContext() const
92   { return web_context_; }
93
94   content::NotificationControllerEfl* GetNotificationController() const;
95
96   class ResourceContextEfl : public ResourceContext {
97    public:
98     ResourceContextEfl(BrowserContextEfl*);
99     virtual ~ResourceContextEfl();
100
101     virtual net::HostResolver* GetHostResolver() OVERRIDE;
102     virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
103     virtual bool AllowMicAccess(const GURL& origin) OVERRIDE;
104     virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE;
105     void set_url_request_context_getter(URLRequestContextGetterEfl* getter);
106     BrowserContextEfl* getBrowserContext() { return browser_context_; };
107
108    private:
109     URLRequestContextGetterEfl* getter_;
110     BrowserContextEfl *browser_context_;
111
112     DISALLOW_COPY_AND_ASSIGN(ResourceContextEfl);
113   };
114
115  private:
116   static void ReadCertificateAndAdd(base::FilePath* file_path);
117   virtual SSLHostStateDelegate* GetSSLHostStateDelegate() OVERRIDE;
118
119   scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
120   ResourceContextEfl* resource_context_;
121   scoped_refptr<URLRequestContextGetterEfl> request_context_getter_;
122   EWebContext* web_context_;
123 #if defined(ENABLE_NOTIFICATIONS)
124   scoped_ptr<NotificationControllerEfl> notification_controllerefl_;
125 #endif
126   DownloadManagerDelegateEfl download_manager_delegate_;
127   base::ScopedTempDir temp_dir_;
128   bool temp_dir_creation_attempted_;
129
130   DISALLOW_COPY_AND_ASSIGN(BrowserContextEfl);
131 };
132
133 }
134
135 #endif