2 Copyright (C) 2014 Samsung Electronics
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.
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.
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.
20 #ifndef BROWSER_CONTEXT_EFL
21 #define BROWSER_CONTEXT_EFL
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"
42 class BrowserContextEfl
43 : public BrowserContext,
44 public visitedlink::VisitedLinkDelegate {
46 BrowserContextEfl(EWebContext*);
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(); }
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();
71 virtual ResourceContext* GetResourceContext() OVERRIDE;
73 virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE
74 { return &download_manager_delegate_; }
76 virtual BrowserPluginGuestManager* GetGuestManager() OVERRIDE
79 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE
82 virtual PushMessagingService* GetPushMessagingService() OVERRIDE
85 virtual base::FilePath GetPath() const OVERRIDE;
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_; }
94 content::NotificationControllerEfl* GetNotificationController() const;
96 class ResourceContextEfl : public ResourceContext {
98 ResourceContextEfl(BrowserContextEfl*);
99 virtual ~ResourceContextEfl();
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_; };
109 URLRequestContextGetterEfl* getter_;
110 BrowserContextEfl *browser_context_;
112 DISALLOW_COPY_AND_ASSIGN(ResourceContextEfl);
116 static void ReadCertificateAndAdd(base::FilePath* file_path);
118 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
119 ResourceContextEfl* resource_context_;
120 scoped_refptr<URLRequestContextGetterEfl> request_context_getter_;
121 EWebContext* web_context_;
122 #if defined(ENABLE_NOTIFICATIONS)
123 scoped_ptr<NotificationControllerEfl> notification_controllerefl_;
125 DownloadManagerDelegateEfl download_manager_delegate_;
126 base::ScopedTempDir temp_dir_;
127 bool temp_dir_creation_attempted_;
129 DISALLOW_COPY_AND_ASSIGN(BrowserContextEfl);