2013-09-03 18:43:31 +02:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "include/cef_request_context.h"
|
2015-02-14 00:17:08 +01:00
|
|
|
#include "libcef/browser/browser_context.h"
|
2013-09-03 18:43:31 +02:00
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
// Implementation of the CefRequestContext interface. All methods are thread-
|
|
|
|
// safe unless otherwise indicated.
|
2013-09-03 18:43:31 +02:00
|
|
|
class CefRequestContextImpl : public CefRequestContext {
|
|
|
|
public:
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefRequestContextImpl() override;
|
2013-09-03 18:43:31 +02:00
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
// Returns a CefRequestContextImpl for the specified |request_context|.
|
|
|
|
// Will return the global context if |request_context| is NULL.
|
|
|
|
static CefRefPtr<CefRequestContextImpl> GetForRequestContext(
|
|
|
|
CefRefPtr<CefRequestContext> request_context);
|
|
|
|
|
|
|
|
// Returns a CefRequestContextImpl for the specified |browser_context|.
|
|
|
|
// |browser_context| must be non-NULL.
|
|
|
|
static CefRefPtr<CefRequestContextImpl> GetForBrowserContext(
|
|
|
|
scoped_refptr<CefBrowserContext> browser_context);
|
|
|
|
|
|
|
|
// Returns the browser context object. Can only be called on the UI thread.
|
|
|
|
scoped_refptr<CefBrowserContext> GetBrowserContext();
|
|
|
|
|
|
|
|
// Executes |callback| either synchronously or asynchronously with the browser
|
|
|
|
// context object when it's available. If |task_runner| is NULL the callback
|
|
|
|
// will be executed on the originating thread. The resulting context object
|
|
|
|
// can only be accessed on the UI thread.
|
|
|
|
typedef base::Callback<void(scoped_refptr<CefBrowserContext>)>
|
|
|
|
BrowserContextCallback;
|
|
|
|
void GetBrowserContext(
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
|
|
|
const BrowserContextCallback& callback);
|
|
|
|
|
|
|
|
// Executes |callback| either synchronously or asynchronously with the request
|
|
|
|
// context object when it's available. If |task_runner| is NULL the callback
|
|
|
|
// will be executed on the originating thread. The resulting context object
|
|
|
|
// can only be accessed on the IO thread.
|
|
|
|
typedef base::Callback<void(scoped_refptr<CefURLRequestContextGetterImpl>)>
|
|
|
|
RequestContextCallback;
|
|
|
|
void GetRequestContextImpl(
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
|
|
|
const RequestContextCallback& callback);
|
2013-09-03 18:43:31 +02:00
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool IsSame(CefRefPtr<CefRequestContext> other) override;
|
2015-03-02 21:25:14 +01:00
|
|
|
bool IsSharingWith(CefRefPtr<CefRequestContext> other) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
bool IsGlobal() override;
|
|
|
|
CefRefPtr<CefRequestContextHandler> GetHandler() override;
|
2015-03-02 21:25:14 +01:00
|
|
|
CefString GetCachePath() override;
|
|
|
|
CefRefPtr<CefCookieManager> GetDefaultCookieManager(
|
|
|
|
CefRefPtr<CefCompletionCallback> callback) override;
|
|
|
|
bool RegisterSchemeHandlerFactory(
|
|
|
|
const CefString& scheme_name,
|
|
|
|
const CefString& domain_name,
|
|
|
|
CefRefPtr<CefSchemeHandlerFactory> factory) override;
|
|
|
|
bool ClearSchemeHandlerFactories() override;
|
2015-09-25 13:59:30 +02:00
|
|
|
void PurgePluginListCache(bool reload_pages) override;
|
2015-10-03 01:03:16 +02:00
|
|
|
bool HasPreference(const CefString& name) override;
|
|
|
|
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
|
|
|
|
CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
|
|
|
bool include_defaults) override;
|
|
|
|
bool CanSetPreference(const CefString& name) override;
|
|
|
|
bool SetPreference(const CefString& name,
|
|
|
|
CefRefPtr<CefValue> value,
|
|
|
|
CefString& error) override;
|
2015-03-02 21:25:14 +01:00
|
|
|
|
|
|
|
const CefRequestContextSettings& settings() const { return settings_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class CefRequestContext;
|
|
|
|
|
|
|
|
explicit CefRequestContextImpl(
|
|
|
|
scoped_refptr<CefBrowserContext> browser_context);
|
|
|
|
CefRequestContextImpl(const CefRequestContextSettings& settings,
|
|
|
|
CefRefPtr<CefRequestContextHandler> handler);
|
|
|
|
CefRequestContextImpl(CefRefPtr<CefRequestContextImpl> other,
|
|
|
|
CefRefPtr<CefRequestContextHandler> handler);
|
|
|
|
|
2015-10-03 01:03:16 +02:00
|
|
|
// Make sure the browser context exists. Only called on the UI thread.
|
|
|
|
void EnsureBrowserContext();
|
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
void GetBrowserContextOnUIThread(
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
|
|
|
const BrowserContextCallback& callback);
|
|
|
|
void GetRequestContextImplOnIOThread(
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
|
|
|
const RequestContextCallback& callback,
|
|
|
|
scoped_refptr<CefBrowserContext> browser_context);
|
|
|
|
|
|
|
|
void RegisterSchemeHandlerFactoryInternal(
|
|
|
|
const CefString& scheme_name,
|
|
|
|
const CefString& domain_name,
|
|
|
|
CefRefPtr<CefSchemeHandlerFactory> factory,
|
2015-09-25 13:59:30 +02:00
|
|
|
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
|
2015-03-02 21:25:14 +01:00
|
|
|
void ClearSchemeHandlerFactoriesInternal(
|
2015-09-25 13:59:30 +02:00
|
|
|
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
|
|
|
|
void PurgePluginListCacheInternal(
|
|
|
|
bool reload_pages,
|
|
|
|
scoped_refptr<CefBrowserContext> browser_context);
|
2013-09-03 18:43:31 +02:00
|
|
|
|
2015-02-14 00:17:08 +01:00
|
|
|
scoped_refptr<CefBrowserContext> browser_context_;
|
2015-03-02 21:25:14 +01:00
|
|
|
CefRequestContextSettings settings_;
|
|
|
|
CefRefPtr<CefRequestContextImpl> other_;
|
2013-09-03 18:43:31 +02:00
|
|
|
CefRefPtr<CefRequestContextHandler> handler_;
|
|
|
|
|
|
|
|
// Used to uniquely identify CefRequestContext objects before an associated
|
|
|
|
// CefBrowserContext has been created.
|
|
|
|
int unique_id_;
|
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
// Owned by the CefBrowserContext.
|
|
|
|
CefURLRequestContextGetterImpl* request_context_impl_;
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(CefRequestContextImpl);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefRequestContextImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|