Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1254)

Unified Diff: chrome/browser/worker_host/worker_process_host.cc

Issue 441022: Changed shared worker code so incognito windows do not have access to non-incognito shared workers. (Closed)
Patch Set: Removed superfluous valgrind change. Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/worker_host/worker_process_host.cc
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index 0f6786bdf7052db8364a24af0c902e78543ffbea..f9064f40c5cae3ac0cd19a2d10d9df883f62316c 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -338,13 +338,15 @@ void WorkerProcessHost::UpdateTitle() {
}
void WorkerProcessHost::OnLookupSharedWorker(const GURL& url,
- const string16& name,
- unsigned long long document_id,
- int* route_id,
- bool* url_mismatch) {
+ const string16& name,
+ unsigned long long document_id,
+ int* route_id,
+ bool* url_mismatch) {
int new_route_id = WorkerService::GetInstance()->next_worker_route_id();
+ // TODO(atwilson): Add code to merge document sets for nested shared workers.
bool worker_found = WorkerService::GetInstance()->LookupSharedWorker(
- url, name, document_id, this, new_route_id, url_mismatch);
+ url, name, instances_.front().is_off_the_record(), document_id, this,
+ new_route_id, url_mismatch);
*route_id = worker_found ? new_route_id : MSG_ROUTING_NONE;
}
@@ -356,8 +358,10 @@ void WorkerProcessHost::OnCreateWorker(const GURL& url,
DCHECK(instances_.size() == 1); // Only called when one process per worker.
*route_id = WorkerService::GetInstance()->next_worker_route_id();
WorkerService::GetInstance()->CreateWorker(
- url, is_shared, name, instances_.front().renderer_id(),
+ url, is_shared, instances_.front().is_off_the_record(), name,
+ instances_.front().renderer_id(),
instances_.front().render_view_route_id(), this, *route_id);
+ // TODO(atwilson): Add code to merge document sets for nested shared workers.
}
void WorkerProcessHost::OnCancelCreateDedicatedWorker(int route_id) {
@@ -390,12 +394,14 @@ void WorkerProcessHost::DocumentDetached(IPC::Message::Sender* parent,
WorkerProcessHost::WorkerInstance::WorkerInstance(const GURL& url,
bool is_shared,
+ bool is_off_the_record,
const string16& name,
int renderer_id,
int render_view_route_id,
int worker_route_id)
: url_(url),
shared_(is_shared),
+ off_the_record_(is_off_the_record),
closed_(false),
name_(name),
renderer_id_(renderer_id),
@@ -409,11 +415,16 @@ WorkerProcessHost::WorkerInstance::WorkerInstance(const GURL& url,
// -or-
// b) the names are both empty, and the urls are equal
bool WorkerProcessHost::WorkerInstance::Matches(
- const GURL& match_url, const string16& match_name) const {
+ const GURL& match_url, const string16& match_name,
+ bool off_the_record) const {
// Only match open shared workers.
if (!shared_ || closed_)
return false;
+ // Incognito workers don't match non-incognito workers.
+ if (off_the_record_ != off_the_record)
+ return false;
+
if (url_.GetOrigin() != match_url.GetOrigin())
return false;

Powered by Google App Engine
This is Rietveld 408576698