summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 07:21:13 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-29 07:21:13 +0000
commitf58330c4b964edd22ef02325390975a013a3f34a (patch)
tree15061bcc0ca596409a7113cde0bffc2b49206a0c /chrome
parent82d76938133d016ac5d9cc4b56d603f96876e7f3 (diff)
downloadchromium_src-f58330c4b964edd22ef02325390975a013a3f34a.zip
chromium_src-f58330c4b964edd22ef02325390975a013a3f34a.tar.gz
chromium_src-f58330c4b964edd22ef02325390975a013a3f34a.tar.bz2
Don't show extension state in cookie tree list.
BUG=38659 TEST=Unit tests in browsing_data_local_storage_helper_unittest.cc and browsing_data_database_helper_unittest.cc Review URL: http://codereview.chromium.org/1405002 Patch from Mattias Nissler. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42935 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browsing_data_appcache_helper.cc13
-rw-r--r--chrome/browser/browsing_data_database_helper.cc9
-rw-r--r--chrome/browser/browsing_data_database_helper.h6
-rw-r--r--chrome/browser/browsing_data_database_helper_unittest.cc80
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.cc6
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.h4
-rw-r--r--chrome/browser/browsing_data_local_storage_helper_unittest.cc9
-rw-r--r--chrome/browser/cookies_tree_model.cc24
-rw-r--r--chrome/browser/cookies_tree_model.h2
-rw-r--r--chrome/chrome_tests.gypi1
10 files changed, 115 insertions, 39 deletions
diff --git a/chrome/browser/browsing_data_appcache_helper.cc b/chrome/browser/browsing_data_appcache_helper.cc
index 8fa342e..adfa2c6 100644
--- a/chrome/browser/browsing_data_appcache_helper.cc
+++ b/chrome/browser/browsing_data_appcache_helper.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/profile.h"
+#include "chrome/common/url_constants.h"
#include "webkit/appcache/appcache_database.h"
#include "webkit/appcache/appcache_storage.h"
@@ -63,6 +64,18 @@ void BrowsingDataAppCacheHelper::DeleteAppCacheGroup(
void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) {
if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
+ // Filter out appache info entries for extensions. Extension state is not
+ // considered browsing data.
+ typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin;
+ InfoByOrigin& origin_map = info_collection_->infos_by_origin;
+ for (InfoByOrigin::iterator origin = origin_map.begin();
+ origin != origin_map.end();) {
+ InfoByOrigin::iterator current = origin;
+ ++origin;
+ if (current->first.SchemeIs(chrome::kExtensionScheme))
+ origin_map.erase(current);
+ }
+
appcache_info_callback_ = NULL;
ChromeThread::PostTask(ChromeThread::UI, FROM_HERE, NewRunnableMethod(
this, &BrowsingDataAppCacheHelper::OnFetchComplete, rv));
diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc
index 9c3acf0..5b950cf 100644
--- a/chrome/browser/browsing_data_database_helper.cc
+++ b/chrome/browser/browsing_data_database_helper.cc
@@ -56,6 +56,13 @@ void BrowsingDataDatabaseHelper::FetchDatabaseInfoInFileThread() {
if (tracker_.get() && tracker_->GetAllOriginsInfo(&origins_info)) {
for (std::vector<webkit_database::OriginInfo>::const_iterator ori =
origins_info.begin(); ori != origins_info.end(); ++ori) {
+ const std::string origin_identifier(UTF16ToUTF8(ori->GetOrigin()));
+ if (StartsWithASCII(origin_identifier,
+ std::string(chrome::kExtensionScheme),
+ true)) {
+ // Extension state is not considered browsing data.
+ continue;
+ }
scoped_ptr<WebKit::WebSecurityOrigin> web_security_origin(
WebKit::WebSecurityOrigin::createFromDatabaseIdentifier(
ori->GetOrigin()));
@@ -69,7 +76,7 @@ void BrowsingDataDatabaseHelper::FetchDatabaseInfoInFileThread() {
database_info_.push_back(DatabaseInfo(
web_security_origin->host().utf8(),
UTF16ToUTF8(*db),
- UTF16ToUTF8(ori->GetOrigin()),
+ origin_identifier,
UTF16ToUTF8(ori->GetDatabaseDescription(*db)),
file_info.size,
file_info.last_modified));
diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h
index cacba8b..9f48b49 100644
--- a/chrome/browser/browsing_data_database_helper.h
+++ b/chrome/browser/browsing_data_database_helper.h
@@ -42,12 +42,6 @@ class BrowsingDataDatabaseHelper
last_modified(last_modified) {
}
- bool IsExtensionSchemeData() {
- return StartsWithASCII(origin_identifier,
- std::string(chrome::kExtensionScheme),
- true);
- }
-
bool IsFileSchemeData() {
return StartsWithASCII(origin_identifier,
std::string(chrome::kFileScheme),
diff --git a/chrome/browser/browsing_data_database_helper_unittest.cc b/chrome/browser/browsing_data_database_helper_unittest.cc
new file mode 100644
index 0000000..19c7c20
--- /dev/null
+++ b/chrome/browser/browsing_data_database_helper_unittest.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/browsing_data_database_helper.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/testing_profile.h"
+#include "chrome/test/ui_test_utils.h"
+
+static const char kTestIdentifier1[] = "http_www.google.com_0";
+
+static const char kTestIdentifierExtension[] =
+ "chrome-extension_behllobkkfkfnphdnhnkndlbkcpglgmj_0";
+
+class BrowsingDataDatabaseHelperTest : public InProcessBrowserTest {
+ public:
+ virtual void CreateDatabases() {
+ webkit_database::DatabaseTracker* db_tracker =
+ testing_profile_.GetDatabaseTracker();
+ string16 db_name = ASCIIToUTF16("db");
+ string16 description = ASCIIToUTF16("db_description");
+ int64 size;
+ int64 available;
+ string16 identifier1(UTF8ToUTF16(kTestIdentifier1));
+ db_tracker->DatabaseOpened(identifier1, db_name, description, 1, &size,
+ &available);
+ db_tracker->DatabaseClosed(identifier1, db_name);
+ FilePath db_path1 = db_tracker->GetFullDBFilePath(identifier1, db_name);
+ file_util::CreateDirectory(db_path1.DirName());
+ ASSERT_EQ(0, file_util::WriteFile(db_path1, NULL, 0));
+ string16 identifierExtension(UTF8ToUTF16(kTestIdentifierExtension));
+ db_tracker->DatabaseOpened(identifierExtension, db_name, description, 1,
+ &size, &available);
+ db_tracker->DatabaseClosed(identifierExtension, db_name);
+ FilePath db_path2 =
+ db_tracker->GetFullDBFilePath(identifierExtension, db_name);
+ file_util::CreateDirectory(db_path2.DirName());
+ ASSERT_EQ(0, file_util::WriteFile(db_path2, NULL, 0));
+ std::vector<webkit_database::OriginInfo> origins;
+ db_tracker->GetAllOriginsInfo(&origins);
+ ASSERT_EQ(2U, origins.size());
+ }
+
+ protected:
+ TestingProfile testing_profile_;
+};
+
+// Called back by BrowsingDataDatabaseHelper on the UI thread once the database
+// information has been retrieved.
+class StopTestOnCallback {
+ public:
+ explicit StopTestOnCallback(
+ BrowsingDataDatabaseHelper* database_helper)
+ : database_helper_(database_helper) {
+ DCHECK(database_helper_);
+ }
+
+ void Callback(const std::vector<BrowsingDataDatabaseHelper::DatabaseInfo>&
+ database_info_list) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ ASSERT_EQ(1UL, database_info_list.size());
+ EXPECT_EQ(std::string(kTestIdentifier1),
+ database_info_list.at(0).origin_identifier);
+ MessageLoop::current()->Quit();
+ }
+
+ private:
+ BrowsingDataDatabaseHelper* database_helper_;
+};
+
+IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, FetchData) {
+ CreateDatabases();
+ scoped_refptr<BrowsingDataDatabaseHelper> database_helper(
+ new BrowsingDataDatabaseHelper(&testing_profile_));
+ StopTestOnCallback stop_test_on_callback(database_helper);
+ database_helper->StartFetching(
+ NewCallback(&stop_test_on_callback, &StopTestOnCallback::Callback));
+ // Blocks until StopTestOnCallback::Callback is notified.
+ ui_test_utils::RunMessageLoop();
+}
diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc
index dfb2da0..b29a65a 100644
--- a/chrome/browser/browsing_data_local_storage_helper.cc
+++ b/chrome/browser/browsing_data_local_storage_helper.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/browsing_data_local_storage_helper.h"
#include "base/file_util.h"
+#include "base/string_util.h"
#include "base/message_loop.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
@@ -69,6 +70,11 @@ void BrowsingDataLocalStorageHelper::FetchLocalStorageInfoInWebKitThread() {
scoped_ptr<WebKit::WebSecurityOrigin> web_security_origin(
WebKit::WebSecurityOrigin::createFromDatabaseIdentifier(
webkit_glue::FilePathToWebString(file_path.BaseName())));
+ if (EqualsASCII(web_security_origin->protocol(),
+ chrome::kExtensionScheme)) {
+ // Extension state is not considered browsing data.
+ continue;
+ }
file_util::FileInfo file_info;
bool ret = file_util::GetFileInfo(file_path, &file_info);
if (ret) {
diff --git a/chrome/browser/browsing_data_local_storage_helper.h b/chrome/browser/browsing_data_local_storage_helper.h
index 35ca6bd..2022498 100644
--- a/chrome/browser/browsing_data_local_storage_helper.h
+++ b/chrome/browser/browsing_data_local_storage_helper.h
@@ -47,10 +47,6 @@ class BrowsingDataLocalStorageHelper
last_modified(last_modified) {
}
- bool IsExtensionSchemeData() {
- return protocol == chrome::kExtensionScheme;
- }
-
bool IsFileSchemeData() {
return protocol == chrome::kFileScheme;
}
diff --git a/chrome/browser/browsing_data_local_storage_helper_unittest.cc b/chrome/browser/browsing_data_local_storage_helper_unittest.cc
index 2f3a5a9..e98c5f1 100644
--- a/chrome/browser/browsing_data_local_storage_helper_unittest.cc
+++ b/chrome/browser/browsing_data_local_storage_helper_unittest.cc
@@ -25,13 +25,18 @@ static const FilePath::CharType kTestFile1[] =
static const FilePath::CharType kTestFileInvalid[] =
FILE_PATH_LITERAL("http_www.google.com_localstorage_0.foo");
+// This is only here to test that extension state is not listed by the helper.
+static const FilePath::CharType kTestFileExtension[] = FILE_PATH_LITERAL(
+ "chrome-extension_behllobkkfkfnphdnhnkndlbkcpglgmj_0.localstorage");
+
+
class BrowsingDataLocalStorageHelperTest : public InProcessBrowserTest {
protected:
void CreateLocalStorageFilesForTest() {
FilePath storage_path = GetLocalStoragePathForTestingProfile();
file_util::CreateDirectory(storage_path);
const FilePath::CharType* kFilesToCreate[] = {
- kTestFile0, kTestFile1, kTestFileInvalid,
+ kTestFile0, kTestFile1, kTestFileInvalid, kTestFileExtension
};
for (size_t i = 0; i < arraysize(kFilesToCreate); ++i) {
FilePath file_path = storage_path.Append(kFilesToCreate[i]);
@@ -144,5 +149,5 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) {
ASSERT_FALSE(FilePath(kTestFile0) == file_path.BaseName());
++num_files;
}
- ASSERT_EQ(2, num_files);
+ ASSERT_EQ(3, num_files);
}
diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc
index 7fd0179..46dcb4c 100644
--- a/chrome/browser/cookies_tree_model.cc
+++ b/chrome/browser/cookies_tree_model.cc
@@ -499,8 +499,6 @@ void CookiesTreeModel::PopulateDatabaseInfoWithFilter(
std::wstring origin_node_name;
if (database_info->IsFileSchemeData())
origin_node_name = UTF8ToWide(kFileOriginNodeName);
- else if (database_info->IsExtensionSchemeData())
- origin_node_name = FormExtensionNodeName(database_info->host);
else
origin_node_name = UTF8ToWide(database_info->host);
@@ -538,8 +536,6 @@ void CookiesTreeModel::PopulateLocalStorageInfoWithFilter(
std::wstring origin_node_name;
if (local_storage_info->IsFileSchemeData())
origin_node_name = UTF8ToWide(kFileOriginNodeName);
- else if (local_storage_info->IsExtensionSchemeData())
- origin_node_name = FormExtensionNodeName(local_storage_info->host);
else
origin_node_name = UTF8ToWide(local_storage_info->host);
@@ -575,23 +571,3 @@ void CookiesTreeModel::NotifyObserverEndBatch() {
TreeModelEndBatch(this));
}
}
-
-std::wstring CookiesTreeModel::FormExtensionNodeName(
- const std::string& extension_id) {
- Extension* extension =
- profile_->GetExtensionsService()->GetExtensionById(extension_id, true);
- std::wstring extension_name = extension ?
- UTF8ToWide(extension->name()) :
- l10n_util::GetString(IDS_UNKNOWN_PLUGIN_NAME);
-
- // Since the extension_name will be concatenated with a prefix, we need
- // to explicitly set the extension_name to be LTR format if there is no
- // strong RTL charater in it. Otherwise, if the prefix is an RTL word,
- // the concatenated result might be wrong. For extension named
- // "Great Extension!" the concatenated result would be something like
- // "!Great Extension :NOISNETXE", in which capital letters "NOISNETXE"
- // stand for the Hebrew word for "extension".
- base::i18n::AdjustStringForLocaleDirection(extension_name, &extension_name);
- return l10n_util::GetStringF(IDS_TASK_MANAGER_EXTENSION_PREFIX,
- extension_name);
-}
diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h
index 50f2e4a..7b68640 100644
--- a/chrome/browser/cookies_tree_model.h
+++ b/chrome/browser/cookies_tree_model.h
@@ -414,8 +414,6 @@ class CookiesTreeModel : public TreeNodeModel<CookieTreeNode> {
void PopulateDatabaseInfoWithFilter(const std::wstring& filter);
void PopulateLocalStorageInfoWithFilter(const std::wstring& filter);
- std::wstring FormExtensionNodeName(const std::string& extension_id);
-
void NotifyObserverBeginBatch();
void NotifyObserverEndBatch();
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 7ae58bf..98333db 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1204,6 +1204,7 @@
'browser/autocomplete/autocomplete_browsertest.cc',
'browser/browser_browsertest.cc',
'browser/browser_init_browsertest.cc',
+ 'browser/browsing_data_database_helper_unittest.cc',
'browser/browsing_data_local_storage_helper_unittest.cc',
'browser/crash_recovery_browsertest.cc',
'browser/dom_ui/file_browse_browsertest.cc',