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

Side by Side Diff: chrome/browser/renderer_host/blob_dispatcher_host.cc

Issue 3431032: Change ChildProcessSecurityPolicy to store a list of allowed flags for... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/renderer_host/blob_dispatcher_host.h" 5 #include "chrome/browser/renderer_host/blob_dispatcher_host.h"
6 6
7 #include "chrome/browser/child_process_security_policy.h" 7 #include "chrome/browser/child_process_security_policy.h"
8 #include "chrome/browser/chrome_blob_storage_context.h" 8 #include "chrome/browser/chrome_blob_storage_context.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // Check if the child process has been granted permission to register the files. 52 // Check if the child process has been granted permission to register the files.
53 bool BlobDispatcherHost::CheckPermission( 53 bool BlobDispatcherHost::CheckPermission(
54 webkit_blob::BlobData* blob_data) const { 54 webkit_blob::BlobData* blob_data) const {
55 ChildProcessSecurityPolicy* policy = 55 ChildProcessSecurityPolicy* policy =
56 ChildProcessSecurityPolicy::GetInstance(); 56 ChildProcessSecurityPolicy::GetInstance();
57 for (std::vector<webkit_blob::BlobData::Item>::const_iterator iter = 57 for (std::vector<webkit_blob::BlobData::Item>::const_iterator iter =
58 blob_data->items().begin(); 58 blob_data->items().begin();
59 iter != blob_data->items().end(); ++iter) { 59 iter != blob_data->items().end(); ++iter) {
60 if (iter->type() == webkit_blob::BlobData::TYPE_FILE) { 60 if (iter->type() == webkit_blob::BlobData::TYPE_FILE) {
61 if (!policy->CanUploadFile(process_id_, iter->file_path())) 61 if (!policy->CanReadFile(process_id_, iter->file_path()))
62 return false; 62 return false;
63 } 63 }
64 } 64 }
65 return true; 65 return true;
66 } 66 }
67 67
68 void BlobDispatcherHost::OnRegisterBlobUrl( 68 void BlobDispatcherHost::OnRegisterBlobUrl(
69 const GURL& url, const scoped_refptr<webkit_blob::BlobData>& blob_data) { 69 const GURL& url, const scoped_refptr<webkit_blob::BlobData>& blob_data) {
70 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 70 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
71 if (!CheckPermission(blob_data.get())) 71 if (!CheckPermission(blob_data.get()))
72 return; 72 return;
73 blob_storage_context_->controller()->RegisterBlobUrl(url, blob_data); 73 blob_storage_context_->controller()->RegisterBlobUrl(url, blob_data);
74 blob_urls_.insert(url.spec()); 74 blob_urls_.insert(url.spec());
75 } 75 }
76 76
77 void BlobDispatcherHost::OnRegisterBlobUrlFrom( 77 void BlobDispatcherHost::OnRegisterBlobUrlFrom(
78 const GURL& url, const GURL& src_url) { 78 const GURL& url, const GURL& src_url) {
79 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 79 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
80 blob_storage_context_->controller()->RegisterBlobUrlFrom(url, src_url); 80 blob_storage_context_->controller()->RegisterBlobUrlFrom(url, src_url);
81 blob_urls_.insert(src_url.spec()); 81 blob_urls_.insert(src_url.spec());
82 } 82 }
83 83
84 void BlobDispatcherHost::OnUnregisterBlobUrl(const GURL& url) { 84 void BlobDispatcherHost::OnUnregisterBlobUrl(const GURL& url) {
85 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 85 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
86 blob_storage_context_->controller()->UnregisterBlobUrl(url); 86 blob_storage_context_->controller()->UnregisterBlobUrl(url);
87 blob_urls_.erase(url.spec()); 87 blob_urls_.erase(url.spec());
88 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698