Commit 91fcd3b6 authored by Daniel Murphy's avatar Daniel Murphy

Revert "[IndexedDB] Remove child policy permissions for blobs from IndexedDB"

This reverts commit 71d64a4f.

Reason for revert: This seems to be causing attachment errors in gmail - I'm guessing that we still report these as files somehow?

Bug: 1033165

Original change's description:
> [IndexedDB] Remove child policy permissions for blobs from IndexedDB
> 
> Now that blobs from IndexedDB are backed & read by the IndexedDB system,
> they are no longer sent to the renderer as files. This means no content
> policy changes or grants are necessary.
> 
> Tracking document:
> https://docs.google.com/document/d/18suNOOzuEJbqgRJF0MB2VqdTyYqS4cvI2PGaCpyPXSw/edit?ts=5de6dc30&pli=1#heading=h.tw2iw2qfgduj
> 
> Bug: 1015212
> Change-Id: If3d2fd80b3254f19a56ab16ed7fc39cf5f0cf684
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1955813
> Reviewed-by: Ken Rockot <rockot@google.com>
> Reviewed-by: enne <enne@chromium.org>
> Commit-Queue: Daniel Murphy <dmurph@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#722617}

TBR=dmurph@chromium.org,rockot@google.com,enne@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1015212
Change-Id: If5307dfa39ab1a74e62dec21dd55dd71d81a52ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1963206Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#724039}
parent 9864780e
......@@ -32,6 +32,7 @@
#include "components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_factory.h"
#include "components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_iterator.h"
#include "components/services/storage/indexed_db/transactional_leveldb/transactional_leveldb_transaction.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/indexed_db/indexed_db_active_blob_registry.h"
#include "content/browser/indexed_db/indexed_db_blob_info.h"
#include "content/browser/indexed_db/indexed_db_context_impl.h"
......@@ -595,6 +596,12 @@ IndexedDBBackingStore::IndexedDBBackingStore(
IndexedDBBackingStore::~IndexedDBBackingStore() {
DCHECK_CALLED_ON_VALID_SEQUENCE(idb_sequence_checker_);
if (!blob_path_.empty() && !child_process_ids_granted_.empty()) {
ChildProcessSecurityPolicyImpl* policy =
ChildProcessSecurityPolicyImpl::GetInstance();
for (const auto& pid : child_process_ids_granted_)
policy->RevokeAllPermissionsForFile(pid, blob_path_);
}
}
IndexedDBBackingStore::RecordIdentifier::RecordIdentifier(
......@@ -948,6 +955,16 @@ bool IndexedDBBackingStore::RecordCorruptionInfo(const FilePath& path_base,
output_js.c_str());
}
void IndexedDBBackingStore::GrantChildProcessPermissions(int child_process_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(idb_sequence_checker_);
if (!child_process_ids_granted_.count(child_process_id)) {
child_process_ids_granted_.insert(child_process_id);
ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
child_process_id, blob_path_);
}
}
Status IndexedDBBackingStore::DeleteDatabase(
const base::string16& name,
TransactionalLevelDBTransaction* transaction) {
......
......@@ -335,6 +335,8 @@ class CONTENT_EXPORT IndexedDBBackingStore {
return active_blob_registry_.get();
}
void GrantChildProcessPermissions(int child_process_id);
// Compact is public for testing.
virtual void Compact();
virtual leveldb::Status DeleteDatabase(
......
......@@ -1619,6 +1619,8 @@ std::unique_ptr<IndexedDBConnection> IndexedDBDatabase::CreateConnection(
scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
IndexedDBExecutionContextConnectionTracker::Handle
execution_context_connection_handle) {
const int render_process_id =
execution_context_connection_handle.render_process_id();
std::unique_ptr<IndexedDBConnection> connection =
std::make_unique<IndexedDBConnection>(
std::move(execution_context_connection_handle),
......@@ -1630,6 +1632,7 @@ std::unique_ptr<IndexedDBConnection> IndexedDBDatabase::CreateConnection(
weak_factory_.GetWeakPtr()),
database_callbacks);
connections_.insert(connection.get());
backing_store_->GrantChildProcessPermissions(render_process_id);
return connection;
}
......
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