8eb0a9627c96833426f07c6a3db63a747e553173
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Copyright 2014 Samsung Electronics. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 #ifndef _URL_REQUEST_CONTEXT_GETTER_EFL_H_
7 #define _URL_REQUEST_CONTEXT_GETTER_EFL_H_
8
9 #include "base/memory/weak_ptr.h"
10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/content_browser_client.h"
13 #include "net/base/network_delegate.h"
14 #include "net/url_request/url_request_context_getter.h"
15 #include "net/url_request/url_request_context_storage.h"
16 #include "net/proxy/proxy_config_service.h"
17 #include "net/url_request/url_request_job_factory_impl.h"
18 #include "public/ewk_context.h"
19 #include "public/ewk_cookie_manager_internal.h"
20 #include "url_request_interceptor_efl.h"
21
22 namespace net {
23 class HostResolver;
24 class NetLog;
25 }
26
27 namespace content {
28
29 class URLRequestContextGetterEfl : public net::URLRequestContextGetter {
30  public:
31   URLRequestContextGetterEfl(std::unique_ptr<net::NetworkDelegate> network_delegate = std::unique_ptr<net::NetworkDelegate>(),
32       bool ignore_certificate_errors = false,
33       const base::FilePath& base_path = base::FilePath(),
34 #if defined(OS_TIZEN_TV_PRODUCT)
35       //  Zero means that the cache will determine the value to use.
36       int cache_max_bytes = 0,
37 #endif
38       const scoped_refptr<base::SingleThreadTaskRunner> &io_task_runner = BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
39       const scoped_refptr<base::SingleThreadTaskRunner> &file_task_runner = BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
40       ProtocolHandlerMap* protocol_handlers = NULL,
41       URLRequestInterceptorScopedVector request_interceptors = URLRequestInterceptorScopedVector(),
42       net::NetLog* net_log = NULL);
43
44   // net::URLRequestContextGetter implementation.
45   net::URLRequestContext* GetURLRequestContext() override;
46   scoped_refptr<base::SingleThreadTaskRunner>
47       GetNetworkTaskRunner() const override;
48
49   net::HostResolver* host_resolver();
50
51   void SetCookieStoragePath(const base::FilePath& path,
52                             bool persist_session_cookies,
53                             Ewk_Cookie_Persistent_Storage file_storage);
54
55   base::WeakPtr<URLRequestContextGetterEfl> GetWeakPtr() {
56     return weak_ptr_factory_.GetWeakPtr();
57   }
58
59   void SetInterceptRequestCallback(
60       Ewk_Context* ewk_context,
61       Ewk_Context_Intercept_Request_Callback callback,
62       void* user_data);
63
64 #if defined(OS_TIZEN_TV_PRODUCT)
65   void UpdateWebAppDiskCachePath(const std::string& app_id);
66 #endif
67
68  protected:
69   ~URLRequestContextGetterEfl() override;
70
71  private:
72   void CreateSQLitePersistentCookieStore(
73       const base::FilePath& path,
74       bool persist_session_cookies);
75   void CreatePersistentCookieStore(
76       const base::FilePath& path,
77       bool persist_session_cookies);
78
79   bool ignore_certificate_errors_;
80   base::FilePath base_path_;
81 #if defined(OS_TIZEN_TV_PRODUCT)
82   int cache_max_bytes_;
83 #endif
84   const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner_;
85   const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner_;
86   net::NetLog* net_log_;
87
88   base::FilePath cookie_store_path_;
89   std::unique_ptr<net::CookieStore> cookie_store_;
90
91   std::unique_ptr<net::ProxyConfigService> proxy_config_service_;
92   std::unique_ptr<net::NetworkDelegate> network_delegate_;
93   std::unique_ptr<net::URLRequestContextStorage> storage_;
94   std::unique_ptr<net::URLRequestContext> url_request_context_;
95   ProtocolHandlerMap protocol_handlers_;
96   URLRequestInterceptorScopedVector request_interceptors_;
97   URLRequestInterceptorEFL* request_interceptor_efl_;
98   URLRequestInterceptorEFL::InterceptRequestCallbackWithData
99       intercept_request_callback_with_data_;
100   base::WeakPtrFactory<URLRequestContextGetterEfl> weak_ptr_factory_;
101
102   DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetterEfl);
103 };
104
105 }; // namespace content
106
107 #endif  // _URL_REQUEST_CONTEXT_GETTER_EFL_H_