Add support for complete isolation of storage and permissions (cache, cookies, localStorage, access grants, etc) on a per-request-context basis (issue #1044).

- CefRequestContext instances can be configured using a new CefRequestContextSettings structure passed to CefRequestContext::CreateContext.
- Scheme registration is now per-request-context using new CefRequestContext::RegisterSchemeHandlerFactory and ClearSchemeHandlerFactories methods.
- Cookie managers are now per-request-context by default and can be retrieved using a new CefRequestContext::GetDefaultCookieManager method.
- CefURLRequest::Create now accepts an optional CefRequestContext argument for associating a URL request with a context (browser process only).
- The CefRequestContextHandler associated with a CefRequestContext will not be released until all objects related to that context have been destroyed.
- When the cache path is empty an in-memory cache ("incognito mode") will be used for storage and no data will be persisted to disk.
- Add CefSettings.user_data_path which specifies the location where user data such as spell checking dictionary files will be stored on disk.
- Add asynchronous callbacks for all CefCookieManager methods.
- Add PK_LOCAL_APP_DATA and PK_USER_DATA path keys for retrieving user directories via CefGetPath.
- cefclient: Add "New Window" test that creates a new window unrelated to existing windows. When used in combination with `--request-context-per-browser` the new window will be given a new and isolated request context.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2040 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2015-03-02 20:25:14 +00:00
parent 031f192e5a
commit ca0e381681
91 changed files with 3816 additions and 1347 deletions

View File

@ -397,15 +397,16 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::CreateInternal(
DCHECK(opener == kNullWindowHandle || browser_info->is_popup());
if (!web_contents) {
scoped_refptr<CefBrowserContext> browser_context = NULL;
if (request_context.get()) {
CefRequestContextImpl* request_context_impl =
static_cast<CefRequestContextImpl*>(request_context.get());
browser_context = request_context_impl->GetOrCreateBrowserContext();
} else {
browser_context = CefContentBrowserClient::Get()->browser_context();
}
DCHECK(browser_context);
// Get or create the request context and browser context.
CefRefPtr<CefRequestContextImpl> request_context_impl =
CefRequestContextImpl::GetForRequestContext(request_context);
DCHECK(request_context_impl.get());
scoped_refptr<CefBrowserContext> browser_context =
request_context_impl->GetBrowserContext();
DCHECK(browser_context.get());
if (!request_context.get())
request_context = request_context_impl.get();
content::WebContents::CreateParams create_params(
browser_context.get());
@ -424,7 +425,7 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::CreateInternal(
CefRefPtr<CefBrowserHostImpl> browser =
new CefBrowserHostImpl(window_info, settings, client, web_contents,
browser_info, opener);
browser_info, opener, request_context);
if (!browser->IsWindowless() && !browser->PlatformCreateWindow())
return NULL;
@ -2236,6 +2237,8 @@ void CefBrowserHostImpl::WebContentsCreated(
const base::string16& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
DCHECK(new_contents);
scoped_ptr<PendingPopupInfo> pending_popup_info;
{
base::AutoLock lock_scope(pending_popup_info_lock_);
@ -2261,11 +2264,19 @@ void CefBrowserHostImpl::WebContentsCreated(
DCHECK(!info->is_popup());
}
scoped_refptr<CefBrowserContext> browser_context =
static_cast<CefBrowserContext*>(new_contents->GetBrowserContext());
DCHECK(browser_context.get());
CefRefPtr<CefRequestContext> request_context =
CefRequestContextImpl::GetForBrowserContext(browser_context).get();
DCHECK(request_context.get());
CefRefPtr<CefBrowserHostImpl> browser =
CefBrowserHostImpl::CreateInternal(pending_popup_info->window_info,
pending_popup_info->settings,
pending_popup_info->client,
new_contents, info, opener, NULL);
new_contents, info, opener,
request_context);
}
void CefBrowserHostImpl::DidNavigateMainFramePostCommit(
@ -2725,13 +2736,15 @@ CefBrowserHostImpl::CefBrowserHostImpl(
CefRefPtr<CefClient> client,
content::WebContents* web_contents,
scoped_refptr<CefBrowserInfo> browser_info,
CefWindowHandle opener)
CefWindowHandle opener,
CefRefPtr<CefRequestContext> request_context)
: content::WebContentsObserver(web_contents),
window_info_(window_info),
settings_(settings),
client_(client),
browser_info_(browser_info),
opener_(opener),
request_context_(request_context),
is_loading_(false),
can_go_back_(false),
can_go_forward_(false),
@ -2753,16 +2766,14 @@ CefBrowserHostImpl::CefBrowserHostImpl(
window_x11_ = NULL;
#endif
DCHECK(request_context_.get());
DCHECK(!browser_info_->browser().get());
browser_info_->set_browser(this);
web_contents_.reset(web_contents);
web_contents->SetDelegate(this);
scoped_refptr<CefBrowserContext> browser_context =
static_cast<CefBrowserContext*>(web_contents->GetBrowserContext());
request_context_ = new CefRequestContextImpl(browser_context);
registrar_.reset(new content::NotificationRegistrar);
registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
content::Source<content::WebContents>(web_contents));