summaryrefslogtreecommitdiffstats
path: root/webkit/database
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 02:09:42 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 02:09:42 +0000
commit654512b4c7e02401af2ce207d678c683841eedb6 (patch)
treed856c557204c2ebbc94a5f4c7d8106b1ab5ffc41 /webkit/database
parent07598d6736b8d612b1f68eaf2066ab15776293da (diff)
downloadchromium_src-654512b4c7e02401af2ce207d678c683841eedb6.zip
chromium_src-654512b4c7e02401af2ce207d678c683841eedb6.tar.gz
chromium_src-654512b4c7e02401af2ce207d678c683841eedb6.tar.bz2
Protect local storage created by extension apps.
BUG=49228 TEST=ExtensionsServiceTest.InstallAppsAndCheckStorageProtection TEST=DatabaseTrackerTest.* Review URL: http://codereview.chromium.org/3256003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/database')
-rw-r--r--webkit/database/database_tracker.cc8
-rw-r--r--webkit/database/database_tracker.h8
-rw-r--r--webkit/database/database_tracker_unittest.cc9
3 files changed, 19 insertions, 6 deletions
diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc
index a37c2a0..8a8a21d 100644
--- a/webkit/database/database_tracker.cc
+++ b/webkit/database/database_tracker.cc
@@ -4,6 +4,7 @@
#include "webkit/database/database_tracker.h"
+#include <algorithm>
#include <vector>
#include "app/sql/connection.h"
@@ -520,6 +521,7 @@ int DatabaseTracker::DeleteDatabase(const string16& origin_identifier,
int DatabaseTracker::DeleteDataModifiedSince(
const base::Time& cutoff,
+ const std::vector<string16>& protected_origins,
net::CompletionCallback* callback) {
if (!LazyInit())
return net::ERR_FAILED;
@@ -536,6 +538,12 @@ int DatabaseTracker::DeleteDataModifiedSince(
ori != origins.end(); ++ori) {
if (StartsWith(*ori, ASCIIToUTF16(kExtensionOriginIdentifierPrefix), true))
continue;
+
+ std::vector<string16>::const_iterator find_iter =
+ std::find(protected_origins.begin(), protected_origins.end(), *ori);
+ if (find_iter != protected_origins.end())
+ continue;
+
std::vector<DatabaseDetails> details;
if (!databases_table_->GetAllDatabaseDetailsForOrigin(*ori, &details))
rv = net::ERR_FAILED;
diff --git a/webkit/database/database_tracker.h b/webkit/database/database_tracker.h
index e4c8183..4976a91 100644
--- a/webkit/database/database_tracker.h
+++ b/webkit/database/database_tracker.h
@@ -145,10 +145,12 @@ class DatabaseTracker
net::CompletionCallback* callback);
// Delete any databases that have been touched since the cutoff date that's
- // supplied. Returns net::OK on success, net::FAILED if not all databases
- // could be deleted, and net::ERR_IO_PENDING and |callback| is invoked upon
- // completion, if non-NULL.
+ // supplied, omitting any that match IDs within |protected_origins|.
+ // Returns net::OK on success, net::FAILED if not all databases could be
+ // deleted, and net::ERR_IO_PENDING and |callback| is invoked upon completion,
+ // if non-NULL.
int DeleteDataModifiedSince(const base::Time& cutoff,
+ const std::vector<string16>& protected_origins,
net::CompletionCallback* callback);
// Delete all databases that belong to the given origin. Returns net::OK on
diff --git a/webkit/database/database_tracker_unittest.cc b/webkit/database/database_tracker_unittest.cc
index bc255dd..2afdf5e 100644
--- a/webkit/database/database_tracker_unittest.cc
+++ b/webkit/database/database_tracker_unittest.cc
@@ -156,10 +156,13 @@ class DatabaseTracker_TestHelper_Test {
EXPECT_TRUE(file_util::SetLastModifiedTime(
tracker->GetFullDBFilePath(kOrigin2, kDB3), three_days_ago));
- // Delete databases modified since yesterday.
+ // Delete databases modified since yesterday. db2 is whitelisted.
base::Time yesterday = base::Time::Now();
yesterday -= base::TimeDelta::FromDays(1);
- result = tracker->DeleteDataModifiedSince(yesterday, &callback);
+ std::vector<string16> protected_origins;
+ protected_origins.push_back(kOrigin2);
+ result = tracker->DeleteDataModifiedSince(
+ yesterday, protected_origins, &callback);
EXPECT_EQ(net::ERR_IO_PENDING, result);
ASSERT_FALSE(callback.have_result());
EXPECT_TRUE(observer.DidReceiveNewNotification());
@@ -169,7 +172,7 @@ class DatabaseTracker_TestHelper_Test {
EXPECT_EQ(net::OK, result);
EXPECT_FALSE(file_util::PathExists(tracker->DatabaseDirectory().Append(
FilePath::FromWStringHack(UTF16ToWide(kOrigin1)))));
- EXPECT_FALSE(
+ EXPECT_TRUE(
file_util::PathExists(tracker->GetFullDBFilePath(kOrigin2, kDB2)));
EXPECT_TRUE(
file_util::PathExists(tracker->GetFullDBFilePath(kOrigin2, kDB3)));