summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 10:02:26 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 10:02:26 +0000
commitec3d1456bdbfd7d7806e51dd1e59088f691495ec (patch)
tree7f85308cde8eab9ffebcb4910894c184060ba15f /chrome
parent4236df757e45014700da962b9a20d46f61b4440f (diff)
downloadchromium_src-ec3d1456bdbfd7d7806e51dd1e59088f691495ec.zip
chromium_src-ec3d1456bdbfd7d7806e51dd1e59088f691495ec.tar.gz
chromium_src-ec3d1456bdbfd7d7806e51dd1e59088f691495ec.tar.bz2
Actually delete databases in CookiesTreeModel.
BUG=34633 TEST=delete a database while it's opened in the renderer Review URL: http://codereview.chromium.org/600104 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39346 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browsing_data_database_helper.cc15
-rw-r--r--chrome/browser/browsing_data_database_helper.h3
-rw-r--r--chrome/browser/cookies_tree_model.cc19
-rw-r--r--chrome/browser/cookies_tree_model_unittest.cc3
-rw-r--r--chrome/browser/views/options/cookies_view.cc10
5 files changed, 27 insertions, 23 deletions
diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc
index addbf93..47489a5 100644
--- a/chrome/browser/browsing_data_database_helper.cc
+++ b/chrome/browser/browsing_data_database_helper.cc
@@ -8,17 +8,16 @@
#include "base/message_loop.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/profile.h"
+#include "net/base/net_errors.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
-#include "webkit/database/database_tracker.h"
#include "webkit/glue/webkit_glue.h"
BrowsingDataDatabaseHelper::BrowsingDataDatabaseHelper(Profile* profile)
- : profile_(profile),
+ : tracker_(profile->GetDatabaseTracker()),
completion_callback_(NULL),
is_fetching_(false) {
- DCHECK(profile_);
}
BrowsingDataDatabaseHelper::~BrowsingDataDatabaseHelper() {
@@ -52,9 +51,7 @@ void BrowsingDataDatabaseHelper::DeleteDatabase(const std::string& origin,
void BrowsingDataDatabaseHelper::FetchDatabaseInfoInFileThread() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
std::vector<webkit_database::OriginInfo> origins_info;
- scoped_refptr<webkit_database::DatabaseTracker> tracker =
- profile_->GetDatabaseTracker();
- if (tracker.get() && tracker->GetAllOriginsInfo(&origins_info)) {
+ if (tracker_.get() && tracker_->GetAllOriginsInfo(&origins_info)) {
for (std::vector<webkit_database::OriginInfo>::const_iterator ori =
origins_info.begin(); ori != origins_info.end(); ++ori) {
scoped_ptr<WebKit::WebSecurityOrigin> web_security_origin(
@@ -64,7 +61,7 @@ void BrowsingDataDatabaseHelper::FetchDatabaseInfoInFileThread() {
ori->GetAllDatabaseNames(&databases);
for (std::vector<string16>::const_iterator db = databases.begin();
db != databases.end(); ++db) {
- FilePath file_path = tracker->GetFullDBFilePath(ori->GetOrigin(), *db);
+ FilePath file_path = tracker_->GetFullDBFilePath(ori->GetOrigin(), *db);
file_util::FileInfo file_info;
if (file_util::GetFileInfo(file_path, &file_info)) {
database_info_.push_back(DatabaseInfo(
@@ -98,5 +95,7 @@ void BrowsingDataDatabaseHelper::DeleteDatabaseInFileThread(
const std::string& origin,
const std::string& name) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
- // TODO(jochen): delete the given database.
+ if (!tracker_.get())
+ return;
+ tracker_->DeleteDatabase(UTF8ToUTF16(origin), UTF8ToUTF16(name), NULL);
}
diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h
index 0b2440c..d126a54 100644
--- a/chrome/browser/browsing_data_database_helper.h
+++ b/chrome/browser/browsing_data_database_helper.h
@@ -10,6 +10,7 @@
#include "base/scoped_ptr.h"
#include "base/task.h"
+#include "webkit/database/database_tracker.h"
class Profile;
@@ -82,7 +83,7 @@ class BrowsingDataDatabaseHelper
void DeleteDatabaseInFileThread(const std::string& origin,
const std::string& name);
- Profile* profile_;
+ scoped_refptr<webkit_database::DatabaseTracker> tracker_;
// This only mutates on the UI thread.
scoped_ptr<Callback1<const std::vector<DatabaseInfo>& >::Type >
diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc
index b6b56b8..0238c12 100644
--- a/chrome/browser/cookies_tree_model.cc
+++ b/chrome/browser/cookies_tree_model.cc
@@ -129,7 +129,9 @@ class OriginNodeComparator {
CookieTreeDatabaseNode::CookieTreeDatabaseNode(
BrowsingDataDatabaseHelper::DatabaseInfo* database_info)
- : CookieTreeNode(UTF8ToWide(database_info->database_name)),
+ : CookieTreeNode(UTF8ToWide(database_info->database_name.empty() ?
+ database_info->origin_identifier :
+ database_info->database_name)),
database_info_(database_info) {
}
@@ -143,7 +145,10 @@ void CookieTreeDatabaseNode::DeleteStoredObjects() {
CookieTreeLocalStorageNode::CookieTreeLocalStorageNode(
BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info)
- : CookieTreeNode(UTF8ToWide(local_storage_info->origin)),
+ : CookieTreeNode(UTF8ToWide(
+ local_storage_info->origin.empty() ?
+ local_storage_info->database_identifier :
+ local_storage_info->origin)),
local_storage_info_(local_storage_info) {
}
@@ -213,9 +218,9 @@ CookieTreeLocalStoragesNode*
CookieTreeLocalStoragesNode* retval = new CookieTreeLocalStoragesNode;
int index = 0;
if (cookies_child_)
- index++;
+ ++index;
if (databases_child_)
- index++;
+ ++index;
GetModel()->Add(this, index, retval);
local_storages_child_ = retval;
return retval;
@@ -442,7 +447,8 @@ void CookiesTreeModel::PopulateDatabaseInfoWithFilter(
for (DatabaseInfoList::iterator database_info = database_info_list_.begin();
database_info != database_info_list_.end();
++database_info) {
- std::string origin = database_info->host;
+ std::string origin = database_info->host.empty() ?
+ database_info->origin_identifier : database_info->host;
if (!filter.size() ||
(UTF8ToWide(origin).find(filter) != std::wstring::npos)) {
CookieTreeOriginNode* origin_node = root->GetOrCreateOriginNode(
@@ -469,7 +475,8 @@ void CookiesTreeModel::PopulateLocalStorageInfoWithFilter(
local_storage_info_list_.begin();
local_storage_info != local_storage_info_list_.end();
++local_storage_info) {
- std::string origin = local_storage_info->host;
+ std::string origin = local_storage_info->host.empty() ?
+ local_storage_info->database_identifier : local_storage_info->host;
if (!filter.size() ||
(UTF8ToWide(origin).find(filter) != std::wstring::npos)) {
CookieTreeOriginNode* origin_node = root->GetOrCreateOriginNode(
diff --git a/chrome/browser/cookies_tree_model_unittest.cc b/chrome/browser/cookies_tree_model_unittest.cc
index 48d280b..925a141 100644
--- a/chrome/browser/cookies_tree_model_unittest.cc
+++ b/chrome/browser/cookies_tree_model_unittest.cc
@@ -217,7 +217,8 @@ TEST_F(CookiesTreeModelTest, Remove) {
EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
- EXPECT_EQ("origin1,origin2", GetDisplayedLocalStorages(cookies_model.get()));
+ EXPECT_EQ("origin1,origin2",
+ GetDisplayedLocalStorages(cookies_model.get()));
EXPECT_EQ(16, cookies_model->GetRoot()->GetTotalNodeCount());
}
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index e952d51..51833b2 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -348,11 +348,7 @@ void CookiesView::UpdateRemoveButtonsState() {
}
void CookiesView::UpdateVisibleDetailedInfo(views::View* view) {
- view->SetVisible(true);
- if (view != cookie_info_view_)
- cookie_info_view_->SetVisible(false);
- if (view != database_info_view_)
- database_info_view_->SetVisible(false);
- if (view != local_storage_info_view_)
- local_storage_info_view_->SetVisible(false);
+ cookie_info_view_->SetVisible(view == cookie_info_view_);
+ database_info_view_->SetVisible(view == database_info_view_);
+ local_storage_info_view_->SetVisible(view == local_storage_info_view_);
}