Commit 7c5ff9a7 authored by dgrogan@chromium.org's avatar dgrogan@chromium.org

IndexedDB: chrome-side changes for permission check from shared worker

https://bugs.webkit.org/show_bug.cgi?id=79954 is the webkit side.

BUG=116344
TEST=


Review URL: http://codereview.chromium.org/9557009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124618 0039d316-1c4b-4281-b951-d872f2087c98
parent c1b44778
...@@ -937,6 +937,28 @@ bool ChromeContentBrowserClient::AllowWorkerFileSystem( ...@@ -937,6 +937,28 @@ bool ChromeContentBrowserClient::AllowWorkerFileSystem(
return allow; return allow;
} }
bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
const GURL& url,
const string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
CookieSettings* cookie_settings = io_data->GetCookieSettings();
bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
// Record access to IndexedDB for potential display in UI.
std::vector<std::pair<int, int> >::const_iterator i;
for (i = render_views.begin(); i != render_views.end(); ++i) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&TabSpecificContentSettings::IndexedDBAccessed,
i->first, i->second, url, name, !allow));
}
return allow;
}
net::URLRequestContext* net::URLRequestContext*
ChromeContentBrowserClient::OverrideRequestContextForURL( ChromeContentBrowserClient::OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) { const GURL& url, content::ResourceContext* context) {
......
...@@ -78,6 +78,11 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { ...@@ -78,6 +78,11 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
const GURL& url, const GURL& url,
content::ResourceContext* context, content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE; const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual bool AllowWorkerIndexedDB(
const GURL& url,
const string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual net::URLRequestContext* OverrideRequestContextForURL( virtual net::URLRequestContext* OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) OVERRIDE; const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE; virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
......
...@@ -154,6 +154,14 @@ bool MockContentBrowserClient::AllowWorkerFileSystem( ...@@ -154,6 +154,14 @@ bool MockContentBrowserClient::AllowWorkerFileSystem(
return true; return true;
} }
bool MockContentBrowserClient::AllowWorkerIndexedDB(
const GURL& url,
const string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) {
return true;
}
QuotaPermissionContext* QuotaPermissionContext*
MockContentBrowserClient::CreateQuotaPermissionContext() { MockContentBrowserClient::CreateQuotaPermissionContext() {
return NULL; return NULL;
......
...@@ -80,6 +80,11 @@ class MockContentBrowserClient : public ContentBrowserClient { ...@@ -80,6 +80,11 @@ class MockContentBrowserClient : public ContentBrowserClient {
const GURL& url, const GURL& url,
content::ResourceContext* context, content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE; const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual bool AllowWorkerIndexedDB(
const GURL& url,
const string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual net::URLRequestContext* OverrideRequestContextForURL( virtual net::URLRequestContext* OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) OVERRIDE; const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE; virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
......
...@@ -334,6 +334,7 @@ bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { ...@@ -334,6 +334,7 @@ bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) {
OnWorkerContextClosed) OnWorkerContextClosed)
IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase)
IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem)
IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX() IPC_END_MESSAGE_MAP_EX()
...@@ -397,6 +398,14 @@ void WorkerProcessHost::OnAllowFileSystem(int worker_route_id, ...@@ -397,6 +398,14 @@ void WorkerProcessHost::OnAllowFileSystem(int worker_route_id,
url, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); url, resource_context_, GetRenderViewIDsForWorker(worker_route_id));
} }
void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id,
const GURL& url,
const string16& name,
bool* result) {
*result = content::GetContentClient()->browser()->AllowWorkerIndexedDB(
url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id));
}
void WorkerProcessHost::RelayMessage( void WorkerProcessHost::RelayMessage(
const IPC::Message& message, const IPC::Message& message,
WorkerMessageFilter* filter, WorkerMessageFilter* filter,
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -173,6 +173,10 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, ...@@ -173,6 +173,10 @@ class WorkerProcessHost : public content::BrowserChildProcessHostDelegate,
void OnAllowFileSystem(int worker_route_id, void OnAllowFileSystem(int worker_route_id,
const GURL& url, const GURL& url,
bool* result); bool* result);
void OnAllowIndexedDB(int worker_route_id,
const GURL& url,
const string16& name,
bool* result);
// Relays a message to the given endpoint. Takes care of parsing the message // Relays a message to the given endpoint. Takes care of parsing the message
// if it contains a message port and sending it a valid route id. // if it contains a message port and sending it a valid route id.
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -135,6 +135,13 @@ IPC_SYNC_MESSAGE_CONTROL2_1(WorkerProcessHostMsg_AllowFileSystem, ...@@ -135,6 +135,13 @@ IPC_SYNC_MESSAGE_CONTROL2_1(WorkerProcessHostMsg_AllowFileSystem,
GURL /* origin url */, GURL /* origin url */,
bool /* result */) bool /* result */)
// Sent by the worker process to check whether access to IndexedDB is allowed.
IPC_SYNC_MESSAGE_CONTROL3_1(WorkerProcessHostMsg_AllowIndexedDB,
int /* worker_route_id */,
GURL /* origin url */,
string16 /* database name */,
bool /* result */)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Worker messages // Worker messages
// These are messages sent from the renderer process to the worker process. // These are messages sent from the renderer process to the worker process.
......
...@@ -207,6 +207,15 @@ class ContentBrowserClient { ...@@ -207,6 +207,15 @@ class ContentBrowserClient {
content::ResourceContext* context, content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) = 0; const std::vector<std::pair<int, int> >& render_views) = 0;
// Allow the embedder to control if access to IndexedDB by a shared worker
// is allowed.
// This is called on the IO thread.
virtual bool AllowWorkerIndexedDB(
const GURL& url,
const string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) = 0;
// Allows the embedder to override the request context based on the URL for // Allows the embedder to override the request context based on the URL for
// certain operations, like cookie access. Returns NULL to indicate the // certain operations, like cookie access. Returns NULL to indicate the
// regular request context should be used. // regular request context should be used.
......
...@@ -179,6 +179,14 @@ bool ShellContentBrowserClient::AllowWorkerFileSystem( ...@@ -179,6 +179,14 @@ bool ShellContentBrowserClient::AllowWorkerFileSystem(
return true; return true;
} }
bool ShellContentBrowserClient::AllowWorkerIndexedDB(
const GURL& url,
const string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) {
return true;
}
QuotaPermissionContext* QuotaPermissionContext*
ShellContentBrowserClient::CreateQuotaPermissionContext() { ShellContentBrowserClient::CreateQuotaPermissionContext() {
return NULL; return NULL;
......
...@@ -85,6 +85,11 @@ class ShellContentBrowserClient : public ContentBrowserClient { ...@@ -85,6 +85,11 @@ class ShellContentBrowserClient : public ContentBrowserClient {
const GURL& url, const GURL& url,
content::ResourceContext* context, content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE; const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual bool AllowWorkerIndexedDB(
const GURL& url,
const string16& name,
content::ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
virtual net::URLRequestContext* OverrideRequestContextForURL( virtual net::URLRequestContext* OverrideRequestContextForURL(
const GURL& url, content::ResourceContext* context) OVERRIDE; const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE; virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
......
...@@ -168,6 +168,13 @@ void WebSharedWorkerClientProxy::openFileSystem( ...@@ -168,6 +168,13 @@ void WebSharedWorkerClientProxy::openFileSystem(
size, create, new WebFileSystemCallbackDispatcher(callbacks)); size, create, new WebFileSystemCallbackDispatcher(callbacks));
} }
bool WebSharedWorkerClientProxy::allowIndexedDB(const WebKit::WebString& name) {
bool result = false;
Send(new WorkerProcessHostMsg_AllowIndexedDB(
route_id_, stub_->url().GetOrigin(), name, &result));
return result;
}
void WebSharedWorkerClientProxy::dispatchDevToolsMessage( void WebSharedWorkerClientProxy::dispatchDevToolsMessage(
const WebString& message) { const WebString& message) {
if (devtools_agent_) if (devtools_agent_)
......
...@@ -77,6 +77,7 @@ class WebSharedWorkerClientProxy : public WebKit::WebSharedWorkerClient { ...@@ -77,6 +77,7 @@ class WebSharedWorkerClientProxy : public WebKit::WebSharedWorkerClient {
long long size, long long size,
bool create, bool create,
WebKit::WebFileSystemCallbacks* callbacks); WebKit::WebFileSystemCallbacks* callbacks);
virtual bool allowIndexedDB(const WebKit::WebString&);
virtual void dispatchDevToolsMessage(const WebKit::WebString&); virtual void dispatchDevToolsMessage(const WebKit::WebString&);
virtual void saveDevToolsAgentState(const WebKit::WebString&); virtual void saveDevToolsAgentState(const WebKit::WebString&);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment