diff options
-rw-r--r-- | chrome/browser/browsing_data_database_helper.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browsing_data_database_helper.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_details_unittest.mm | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookies_window_controller_unittest.mm | 12 | ||||
-rw-r--r-- | chrome/browser/cookies_tree_model.cc | 81 | ||||
-rw-r--r-- | chrome/browser/cookies_tree_model.h | 23 | ||||
-rw-r--r-- | chrome/browser/cookies_tree_model_unittest.cc | 112 | ||||
-rw-r--r-- | chrome/browser/gtk/options/cookies_view_unittest.cc | 202 | ||||
-rw-r--r-- | chrome/browser/mock_browsing_data_database_helper.cc | 6 | ||||
-rw-r--r-- | chrome/browser/mock_browsing_data_local_storage_helper.cc | 4 |
10 files changed, 273 insertions, 174 deletions
diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc index 09db4c8..11e5e6b 100644 --- a/chrome/browser/browsing_data_database_helper.cc +++ b/chrome/browser/browsing_data_database_helper.cc @@ -77,6 +77,7 @@ void BrowsingDataDatabaseHelper::FetchDatabaseInfoInFileThread() { UTF16ToUTF8(*db), origin_identifier, UTF16ToUTF8(ori->GetDatabaseDescription(*db)), + web_security_origin.toString().utf8(), file_info.size, file_info.last_modified)); } @@ -137,6 +138,7 @@ void CannedBrowsingDataDatabaseHelper::AddDatabase( name, origin_identifier, description, + web_security_origin.toString().utf8(), 0, base::Time())); } diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h index 4fd852be..6020e9d 100644 --- a/chrome/browser/browsing_data_database_helper.h +++ b/chrome/browser/browsing_data_database_helper.h @@ -33,12 +33,14 @@ class BrowsingDataDatabaseHelper const std::string& database_name, const std::string& origin_identifier, const std::string& description, + const std::string& origin, int64 size, base::Time last_modified) : host(host), database_name(database_name), origin_identifier(origin_identifier), description(description), + origin(origin), size(size), last_modified(last_modified) { } @@ -53,6 +55,7 @@ class BrowsingDataDatabaseHelper std::string database_name; std::string origin_identifier; std::string description; + std::string origin; int64 size; base::Time last_modified; }; diff --git a/chrome/browser/cocoa/cookie_details_unittest.mm b/chrome/browser/cocoa/cookie_details_unittest.mm index ed6f6d0..9883a6a 100644 --- a/chrome/browser/cocoa/cookie_details_unittest.mm +++ b/chrome/browser/cocoa/cookie_details_unittest.mm @@ -59,7 +59,7 @@ TEST_F(CookiesDetailsTest, CreateForTreeDatabase) { int64 size = 1234; base::Time last_modified = base::Time::Now(); BrowsingDataDatabaseHelper::DatabaseInfo info(host, database_name, - origin_identifier, description, size, last_modified); + origin_identifier, description, host, size, last_modified); details.reset([[CocoaCookieDetails alloc] initWithDatabase:&info]); EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeDatabase); diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm index b02031f..48f4a0e 100644 --- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm +++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm @@ -706,11 +706,11 @@ TEST_F(CookiesWindowControllerTest, CreateLocalStorageNodes) { EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); - // Local Storage --> origin1. + // Local Storage --> http://host1:1/. node = [[node children] lastObject]; - EXPECT_TRUE([@"origin1" isEqualToString:[node title]]); + EXPECT_TRUE([@"http://host1:1/" isEqualToString:[node title]]); EXPECT_EQ(kCocoaCookieDetailsTypeTreeLocalStorage, [node nodeType]); - EXPECT_TRUE([@"origin1" isEqualToString:[[node details] domain]]); + EXPECT_TRUE([@"http://host1:1/" isEqualToString:[[node details] domain]]); EXPECT_TRUE([[node details] lastModified]); EXPECT_TRUE([[node details] fileSize]); @@ -728,11 +728,11 @@ TEST_F(CookiesWindowControllerTest, CreateLocalStorageNodes) { EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); - // Local Storage --> origin2. + // Local Storage --> http://host2:2/. node = [[node children] lastObject]; - EXPECT_TRUE([@"origin2" isEqualToString:[node title]]); + EXPECT_TRUE([@"http://host2:2/" isEqualToString:[node title]]); EXPECT_EQ(kCocoaCookieDetailsTypeTreeLocalStorage, [node nodeType]); - EXPECT_TRUE([@"origin2" isEqualToString:[[node details] domain]]); + EXPECT_TRUE([@"http://host2:2/" isEqualToString:[[node details] domain]]); EXPECT_TRUE([[node details] lastModified]); EXPECT_TRUE([[node details] fileSize]); } diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index fad1e47..4f24adf 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -174,28 +174,25 @@ void CookieTreeLocalStorageNode::DeleteStoredObjects() { /////////////////////////////////////////////////////////////////////////////// // CookieTreeRootNode, public: -CookieTreeOriginNode* CookieTreeRootNode::GetOrCreateOriginNode( - const std::wstring& origin) { - // Strip the leading dot if it exists. - std::wstring rewritten_origin = origin; - if (origin.length() >= 1 && origin[0] == '.') - rewritten_origin = origin.substr(1); - CookieTreeOriginNode rewritten_origin_node(rewritten_origin); +CookieTreeOriginNode* CookieTreeRootNode::GetOrCreateOriginNode( + const GURL& url) { + CookieTreeOriginNode origin_node(url); // First see if there is an existing match. std::vector<CookieTreeNode*>::iterator origin_node_iterator = lower_bound(children().begin(), children().end(), - &rewritten_origin_node, + &origin_node, OriginNodeComparator()); - if (origin_node_iterator != children().end() && rewritten_origin == + if (origin_node_iterator != children().end() && + CookieTreeOriginNode::TitleForUrl(url) == (*origin_node_iterator)->GetTitle()) return static_cast<CookieTreeOriginNode*>(*origin_node_iterator); // Node doesn't exist, create a new one and insert it into the (ordered) // children. - CookieTreeOriginNode* retval = new CookieTreeOriginNode(rewritten_origin); + CookieTreeOriginNode* retval = new CookieTreeOriginNode(url); DCHECK(model_); model_->Add(this, (origin_node_iterator - children().begin()), retval); return retval; @@ -204,6 +201,21 @@ CookieTreeOriginNode* CookieTreeRootNode::GetOrCreateOriginNode( /////////////////////////////////////////////////////////////////////////////// // CookieTreeOriginNode, public: +// static +std::wstring CookieTreeOriginNode::TitleForUrl( + const GURL& url) { + return UTF8ToWide(url.SchemeIsFile() ? kFileOriginNodeName : url.host()); +} + +CookieTreeOriginNode::CookieTreeOriginNode(const GURL& url) + : CookieTreeNode(TitleForUrl(url)), + cookies_child_(NULL), + databases_child_(NULL), + local_storages_child_(NULL), + appcaches_child_(NULL), + url_(url) {} + + CookieTreeCookiesNode* CookieTreeOriginNode::GetOrCreateCookiesNode() { if (cookies_child_) return cookies_child_; @@ -238,11 +250,16 @@ CookieTreeAppCachesNode* CookieTreeOriginNode::GetOrCreateAppCachesNode() { } void CookieTreeOriginNode::CreateContentException( - HostContentSettingsMap* content_settings, ContentSetting setting) { - std::wstring title(GetTitle()); - content_settings->AddExceptionForURL(GURL(WideToUTF16(title)), + HostContentSettingsMap* content_settings, ContentSetting setting) const { + if (CanCreateContentException()) { + content_settings->AddExceptionForURL(url_, CONTENT_SETTINGS_TYPE_COOKIES, setting); + } +} + +bool CookieTreeOriginNode::CanCreateContentException() const { + return !url_.SchemeIsFile(); } /////////////////////////////////////////////////////////////////////////////// @@ -384,11 +401,17 @@ void CookiesTreeModel::LoadCookiesWithFilter(const std::wstring& filter) { CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); for (CookieList::iterator it = all_cookies_.begin(); it != all_cookies_.end(); ++it) { - std::wstring origin_node_name = UTF8ToWide(it->first); + std::string origin_host = it->first; + if (origin_host.length() > 1 && origin_host[0] == '.') + origin_host = it->first.substr(1); + // We treat secure cookies just the same as normal ones. + GURL origin(std::string(chrome::kHttpScheme) + + chrome::kStandardSchemeSeparator + origin_host + "/"); if (!filter.size() || - (origin_node_name.find(filter) != std::wstring::npos)) { + (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != + std::string::npos)) { CookieTreeOriginNode* origin_node = - root->GetOrCreateOriginNode(origin_node_name); + root->GetOrCreateOriginNode(origin); CookieTreeCookiesNode* cookies_node = origin_node->GetOrCreateCookiesNode(); CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(&*it); @@ -469,7 +492,7 @@ void CookiesTreeModel::PopulateAppCacheInfoWithFilter( if (filter.empty() || (origin_node_name.find(filter) != std::wstring::npos)) { CookieTreeOriginNode* origin_node = - root->GetOrCreateOriginNode(origin_node_name); + root->GetOrCreateOriginNode(origin->first); CookieTreeAppCachesNode* appcaches_node = origin_node->GetOrCreateAppCachesNode(); @@ -499,17 +522,13 @@ void CookiesTreeModel::PopulateDatabaseInfoWithFilter( for (DatabaseInfoList::iterator database_info = database_info_list_.begin(); database_info != database_info_list_.end(); ++database_info) { - // Determine which 'origin' node to place each 'info' in. - std::wstring origin_node_name; - if (database_info->IsFileSchemeData()) - origin_node_name = UTF8ToWide(kFileOriginNodeName); - else - origin_node_name = UTF8ToWide(database_info->host); + GURL origin(database_info->origin); if (!filter.size() || - (origin_node_name.find(filter) != std::wstring::npos)) { + (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != + std::wstring::npos)) { CookieTreeOriginNode* origin_node = - root->GetOrCreateOriginNode(origin_node_name); + root->GetOrCreateOriginNode(origin); CookieTreeDatabasesNode* databases_node = origin_node->GetOrCreateDatabasesNode(); databases_node->AddDatabaseNode( @@ -536,17 +555,13 @@ void CookiesTreeModel::PopulateLocalStorageInfoWithFilter( local_storage_info_list_.begin(); local_storage_info != local_storage_info_list_.end(); ++local_storage_info) { - // Determine which 'origin' node to place each 'info' in. - std::wstring origin_node_name; - if (local_storage_info->IsFileSchemeData()) - origin_node_name = UTF8ToWide(kFileOriginNodeName); - else - origin_node_name = UTF8ToWide(local_storage_info->host); + GURL origin(local_storage_info->origin); if (!filter.size() || - (origin_node_name.find(filter) != std::wstring::npos)) { + (CookieTreeOriginNode::TitleForUrl(origin).find(filter) != + std::wstring::npos)) { CookieTreeOriginNode* origin_node = - root->GetOrCreateOriginNode(origin_node_name); + root->GetOrCreateOriginNode(origin); CookieTreeLocalStoragesNode* local_storages_node = origin_node->GetOrCreateLocalStoragesNode(); local_storages_node->AddLocalStorageNode( diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h index 9019884..7e6675a 100644 --- a/chrome/browser/cookies_tree_model.h +++ b/chrome/browser/cookies_tree_model.h @@ -112,7 +112,7 @@ class CookieTreeRootNode : public CookieTreeNode { explicit CookieTreeRootNode(CookiesTreeModel* model) : model_(model) {} virtual ~CookieTreeRootNode() {} - CookieTreeOriginNode* GetOrCreateOriginNode(const std::wstring& origin); + CookieTreeOriginNode* GetOrCreateOriginNode(const GURL& url); // CookieTreeNode methods: virtual CookiesTreeModel* GetModel() const { return model_; } @@ -130,12 +130,10 @@ class CookieTreeRootNode : public CookieTreeNode { // CookieTreeOriginNode ------------------------------------------------------- class CookieTreeOriginNode : public CookieTreeNode { public: - explicit CookieTreeOriginNode(const std::wstring& origin) - : CookieTreeNode(origin), - cookies_child_(NULL), - databases_child_(NULL), - local_storages_child_(NULL), - appcaches_child_(NULL) {} + // Returns the origin node's title to use for a given URL. + static std::wstring TitleForUrl(const GURL& url); + + explicit CookieTreeOriginNode(const GURL& url); virtual ~CookieTreeOriginNode() {} // CookieTreeNode methods: @@ -149,8 +147,14 @@ class CookieTreeOriginNode : public CookieTreeNode { CookieTreeDatabasesNode* GetOrCreateDatabasesNode(); CookieTreeLocalStoragesNode* GetOrCreateLocalStoragesNode(); CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); + + // Creates an content exception for this origin of type + // CONTENT_SETTINGS_TYPE_COOKIES. void CreateContentException(HostContentSettingsMap* content_settings, - ContentSetting setting); + ContentSetting setting) const; + + // True if a content exception can be created for this origin. + bool CanCreateContentException() const; private: // Pointers to the cookies, databases, local storage and appcache nodes. @@ -163,6 +167,9 @@ class CookieTreeOriginNode : public CookieTreeNode { CookieTreeLocalStoragesNode* local_storages_child_; CookieTreeAppCachesNode* appcaches_child_; + // The URL for which this node was initially created. + GURL url_; + DISALLOW_COPY_AND_ASSIGN(CookieTreeOriginNode); }; diff --git a/chrome/browser/cookies_tree_model_unittest.cc b/chrome/browser/cookies_tree_model_unittest.cc index 02a04c2..ff0f777 100644 --- a/chrome/browser/cookies_tree_model_unittest.cc +++ b/chrome/browser/cookies_tree_model_unittest.cc @@ -7,6 +7,7 @@ #include <string> #include "app/l10n_util.h" +#include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/mock_browsing_data_appcache_helper.h" #include "chrome/browser/mock_browsing_data_database_helper.h" #include "chrome/browser/mock_browsing_data_local_storage_helper.h" @@ -18,9 +19,33 @@ namespace { +class StubSettingsObserver : public NotificationObserver { + public: + StubSettingsObserver() : counter(0) { + registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, + NotificationService::AllSources()); + } + + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + ++counter; + Details<HostContentSettingsMap::ContentSettingsDetails> + settings_details(details); + last_pattern = settings_details.ptr()->pattern(); + } + + HostContentSettingsMap::Pattern last_pattern; + int counter; + + private: + NotificationRegistrar registrar_; +}; + class CookiesTreeModelTest : public testing::Test { public: - CookiesTreeModelTest() : io_thread_(ChromeThread::IO, &message_loop_) { + CookiesTreeModelTest() : ui_thread_(ChromeThread::UI, &message_loop_), + io_thread_(ChromeThread::IO, &message_loop_) { } virtual ~CookiesTreeModelTest() { @@ -55,10 +80,12 @@ class CookiesTreeModelTest : public testing::Test { // 22 because there's the root, then foo1 -> cookies -> a, // foo2 -> cookies -> b, foo3 -> cookies -> c, // dbhost1 -> database -> db1, dbhost2 -> database -> db2, - // host1 -> localstorage -> origin1, host2 -> localstorage -> origin2. + // host1 -> localstorage -> http://host1:1/, + // host2 -> localstorage -> http://host2:2/. EXPECT_EQ(22, cookies_model->GetRoot()->GetTotalNodeCount()); EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); - EXPECT_EQ("origin1,origin2", GetDisplayedLocalStorages(cookies_model)); + EXPECT_EQ("http://host1:1/,http://host2:2/", + GetDisplayedLocalStorages(cookies_model)); } return cookies_model; } @@ -165,6 +192,7 @@ class CookiesTreeModelTest : public testing::Test { } protected: MessageLoop message_loop_; + ChromeThread ui_thread_; ChromeThread io_thread_; scoped_ptr<TestingProfile> profile_; @@ -188,7 +216,7 @@ TEST_F(CookiesTreeModelTest, RemoveAll) { GetDisplayedCookies(cookies_model.get())); EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); - EXPECT_EQ("origin1,origin2", + EXPECT_EQ("http://host1:1/,http://host2:2/", GetDisplayedLocalStorages(cookies_model.get())); } @@ -220,7 +248,7 @@ TEST_F(CookiesTreeModelTest, Remove) { EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); - EXPECT_EQ("origin1,origin2", + EXPECT_EQ("http://host1:1/,http://host2:2/", GetDisplayedLocalStorages(cookies_model.get())); EXPECT_EQ(19, cookies_model->GetRoot()->GetTotalNodeCount()); } @@ -231,7 +259,7 @@ 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", + EXPECT_EQ("http://host1:1/,http://host2:2/", GetDisplayedLocalStorages(cookies_model.get())); EXPECT_EQ(16, cookies_model->GetRoot()->GetTotalNodeCount()); } @@ -242,7 +270,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("origin2", GetDisplayedLocalStorages(cookies_model.get())); + EXPECT_EQ("http://host2:2/", + GetDisplayedLocalStorages(cookies_model.get())); EXPECT_EQ(13, cookies_model->GetRoot()->GetTotalNodeCount()); } } @@ -261,10 +290,11 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { // node beneath it has been deleted. So, we have // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c // dbhost1 -> database -> db1, dbhost2 -> database -> db2, - // host1 -> localstorage -> origin1, host2 -> localstorage -> origin2. + // host1 -> localstorage -> http://host1:1/, + // host2 -> localstorage -> http://host2:2/. EXPECT_EQ(20, cookies_model->GetRoot()->GetTotalNodeCount()); EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); - EXPECT_EQ("origin1,origin2", + EXPECT_EQ("http://host1:1/,http://host2:2/", GetDisplayedLocalStorages(cookies_model.get())); } @@ -274,7 +304,7 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { 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", + EXPECT_EQ("http://host1:1/,http://host2:2/", GetDisplayedLocalStorages(cookies_model.get())); EXPECT_EQ(18, cookies_model->GetRoot()->GetTotalNodeCount()); } @@ -285,7 +315,8 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { 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("origin2", GetDisplayedLocalStorages(cookies_model.get())); + EXPECT_EQ("http://host2:2/", + GetDisplayedLocalStorages(cookies_model.get())); EXPECT_EQ(16, cookies_model->GetRoot()->GetTotalNodeCount()); } } @@ -301,13 +332,14 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) { EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); - EXPECT_EQ("origin1,origin2", + EXPECT_EQ("http://host1:1/,http://host2:2/", GetDisplayedLocalStorages(cookies_model.get())); // 20 because in this case, the origin remains, although the COOKIES // node beneath it has been deleted. So, we have // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c // dbhost1 -> database -> db1, dbhost2 -> database -> db2, - // host1 -> localstorage -> origin1, host2 -> localstorage -> origin2. + // host1 -> localstorage -> http://host1:1/, + // host2 -> localstorage -> http://host2:2/. EXPECT_EQ(20, cookies_model->GetRoot()->GetTotalNodeCount()); } @@ -317,7 +349,7 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) { EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); - EXPECT_EQ("origin1,origin2", + EXPECT_EQ("http://host1:1/,http://host2:2/", GetDisplayedLocalStorages(cookies_model.get())); EXPECT_EQ(18, cookies_model->GetRoot()->GetTotalNodeCount()); } @@ -328,7 +360,8 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) { EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); - EXPECT_EQ("origin2", GetDisplayedLocalStorages(cookies_model.get())); + EXPECT_EQ("http://host2:2/", + GetDisplayedLocalStorages(cookies_model.get())); EXPECT_EQ(16, cookies_model->GetRoot()->GetTotalNodeCount()); } } @@ -353,12 +386,14 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { // 23 because there's the root, then foo1 -> cookies -> a, // foo2 -> cookies -> b, foo3 -> cookies -> c,d // dbhost1 -> database -> db1, dbhost2 -> database -> db2, - // host1 -> localstorage -> origin1, host2 -> localstorage -> origin2. + // host1 -> localstorage -> http://host1:1/, + // host2 -> localstorage -> http://host2:2/. EXPECT_EQ(23, cookies_model.GetRoot()->GetTotalNodeCount()); EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); - EXPECT_EQ("origin1,origin2", GetDisplayedLocalStorages(&cookies_model)); + EXPECT_EQ("http://host1:1/,http://host2:2/", + GetDisplayedLocalStorages(&cookies_model)); } DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); { @@ -366,7 +401,8 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); - EXPECT_EQ("origin1,origin2", GetDisplayedLocalStorages(&cookies_model)); + EXPECT_EQ("http://host1:1/,http://host2:2/", + GetDisplayedLocalStorages(&cookies_model)); EXPECT_EQ(19, cookies_model.GetRoot()->GetTotalNodeCount()); } } @@ -392,12 +428,14 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { // 24 because there's the root, then foo1 -> cookies -> a, // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e // dbhost1 -> database -> db1, dbhost2 -> database -> db2, - // host1 -> localstorage -> origin1, host2 -> localstorage -> origin2. + // host1 -> localstorage -> http://host1:1/, + // host2 -> localstorage -> http://host2:2/. EXPECT_EQ(24, cookies_model.GetRoot()->GetTotalNodeCount()); EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); - EXPECT_EQ("origin1,origin2", GetDisplayedLocalStorages(&cookies_model)); + EXPECT_EQ("http://host1:1/,http://host2:2/", + GetDisplayedLocalStorages(&cookies_model)); } DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> GetChild(1)); @@ -407,7 +445,8 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); EXPECT_EQ(23, cookies_model.GetRoot()->GetTotalNodeCount()); EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); - EXPECT_EQ("origin1,origin2", GetDisplayedLocalStorages(&cookies_model)); + EXPECT_EQ("http://host1:1/,http://host2:2/", + GetDisplayedLocalStorages(&cookies_model)); } } @@ -472,4 +511,35 @@ TEST_F(CookiesTreeModelTest, OriginOrdering) { } } +TEST_F(CookiesTreeModelTest, ContentSettings) { + GURL host("http://example.com/"); + HostContentSettingsMap::Pattern pattern("[*.]example.com"); + net::CookieMonster* monster = profile_->GetCookieMonster(); + monster->SetCookie(host, "A=1"); + + CookiesTreeModel cookies_model(monster, + new MockBrowsingDataDatabaseHelper(profile_.get()), + new MockBrowsingDataLocalStorageHelper(profile_.get()), + new MockBrowsingDataAppCacheHelper(profile_.get())); + + TestingProfile profile; + HostContentSettingsMap* content_settings = + profile.GetHostContentSettingsMap(); + StubSettingsObserver observer; + + CookieTreeRootNode* root = + static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); + CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); + + EXPECT_EQ(1, origin->GetChildCount()); + EXPECT_TRUE(origin->CanCreateContentException()); + origin->CreateContentException( + content_settings, CONTENT_SETTING_SESSION_ONLY); + + EXPECT_EQ(2, observer.counter); + EXPECT_EQ(pattern, observer.last_pattern); + EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, + content_settings->GetContentSetting(host, CONTENT_SETTINGS_TYPE_COOKIES)); +} + } // namespace diff --git a/chrome/browser/gtk/options/cookies_view_unittest.cc b/chrome/browser/gtk/options/cookies_view_unittest.cc index 01e9937..8205032 100644 --- a/chrome/browser/gtk/options/cookies_view_unittest.cc +++ b/chrome/browser/gtk/options/cookies_view_unittest.cc @@ -233,8 +233,8 @@ TEST_F(CookiesViewTest, Noop) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -267,8 +267,8 @@ TEST_F(CookiesViewTest, RemoveAll) { EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); } @@ -313,8 +313,8 @@ TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) { EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); } @@ -363,8 +363,8 @@ TEST_F(CookiesViewTest, Remove) { EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); } @@ -376,8 +376,8 @@ TEST_F(CookiesViewTest, Remove) { EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -394,8 +394,8 @@ TEST_F(CookiesViewTest, Remove) { EXPECT_STREQ("foo1,_Cookies,__A," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -407,8 +407,8 @@ TEST_F(CookiesViewTest, Remove) { EXPECT_STREQ("foo1,+Cookies,++A," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -422,16 +422,16 @@ TEST_F(CookiesViewTest, Remove) { CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); } ASSERT_TRUE(ExpandByPath(cookies_view, "0")); EXPECT_STREQ("gdbhost1,+Web Databases,++db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0")); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -444,8 +444,8 @@ TEST_F(CookiesViewTest, Remove) { EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_TRUE(mock_browsing_data_database_helper_->last_deleted_origin_ == "http_gdbhost1_1"); @@ -455,8 +455,8 @@ TEST_F(CookiesViewTest, Remove) { ASSERT_TRUE(ExpandByPath(cookies_view, "1")); EXPECT_STREQ("gdbhost2,_Web Databases,__db2," - "host1,+Local Storage,++origin1," - "host2,_Local Storage,__origin2", + "host1,+Local Storage,++http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -469,7 +469,7 @@ TEST_F(CookiesViewTest, Remove) { EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); CheckDetailsSensitivity(FALSE, FALSE, FALSE, FALSE, cookies_view); EXPECT_STREQ("gdbhost2,_Web Databases,__db2," - "host2,_Local Storage,__origin2", + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_TRUE(mock_browsing_data_local_storage_helper_->last_deleted_file_ == FilePath(FILE_PATH_LITERAL("file1"))); @@ -501,8 +501,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(ExpandByPath(cookies_view, "1")); @@ -511,8 +511,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "1:0")); @@ -526,8 +526,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -537,8 +537,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); @@ -547,8 +547,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { EXPECT_STREQ("foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -557,8 +557,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { EXPECT_STREQ("foo2,+Cookies,++G,++X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); @@ -566,8 +566,8 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -575,16 +575,16 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { ASSERT_TRUE(ExpandByPath(cookies_view, "0")); EXPECT_STREQ("gdbhost1,+Web Databases,++db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "0:0")); gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -595,15 +595,15 @@ TEST_F(CookiesViewTest, RemoveCookiesByType) { ASSERT_TRUE(ExpandByPath(cookies_view, "1")); EXPECT_STREQ("gdbhost2,_Web Databases,__db2," - "host1,+Local Storage,++origin1," - "host2,_Local Storage,__origin2", + "host1,+Local Storage,++http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "1:0")); gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost2,_Web Databases,__db2," - "host2,_Local Storage,__origin2", + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -636,8 +636,8 @@ TEST_F(CookiesViewTest, RemoveByDomain) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "1")); @@ -652,8 +652,8 @@ TEST_F(CookiesViewTest, RemoveByDomain) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -666,8 +666,8 @@ TEST_F(CookiesViewTest, RemoveByDomain) { EXPECT_STREQ("foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -678,8 +678,8 @@ TEST_F(CookiesViewTest, RemoveByDomain) { EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -689,8 +689,8 @@ TEST_F(CookiesViewTest, RemoveByDomain) { EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -703,8 +703,8 @@ TEST_F(CookiesViewTest, RemoveByDomain) { gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); - EXPECT_STREQ("host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + EXPECT_STREQ("host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -717,7 +717,7 @@ TEST_F(CookiesViewTest, RemoveByDomain) { gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); - EXPECT_STREQ("host2,_Local Storage,__origin2", + EXPECT_STREQ("host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -762,8 +762,8 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); @@ -777,8 +777,8 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { "foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); @@ -790,8 +790,8 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { EXPECT_STREQ("foo2,_Cookies,__G,__X," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); @@ -802,8 +802,8 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); @@ -813,8 +813,8 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); @@ -823,8 +823,8 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); - EXPECT_STREQ("host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + EXPECT_STREQ("host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); @@ -833,7 +833,7 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) { gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_)); EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); - EXPECT_STREQ("host2,_Local Storage,__origin2", + EXPECT_STREQ("host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); @@ -871,8 +871,8 @@ TEST_F(CookiesViewTest, Filter) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); @@ -886,8 +886,8 @@ TEST_F(CookiesViewTest, Filter) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); // Results are filtered immediately if you activate (hit enter in the entry). @@ -905,16 +905,16 @@ TEST_F(CookiesViewTest, Filter) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos"); gtk_widget_activate(cookies_view.filter_entry_); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); } @@ -941,8 +941,8 @@ TEST_F(CookiesViewTest, FilterRemoveAll) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_)); @@ -956,8 +956,8 @@ TEST_F(CookiesViewTest, FilterRemoveAll) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); // Results are filtered immediately if you activate (hit enter in the entry). @@ -981,8 +981,8 @@ TEST_F(CookiesViewTest, FilterRemoveAll) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); } @@ -1010,8 +1010,8 @@ TEST_F(CookiesViewTest, FilterRemove) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_STREQ("D,A,E,C,B", GetMonsterCookies(monster).c_str()); @@ -1026,8 +1026,8 @@ TEST_F(CookiesViewTest, FilterRemove) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); // Results are filtered immediately if you activate (hit enter in the entry). @@ -1096,8 +1096,8 @@ TEST_F(CookiesViewTest, FilterRemove) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos"); @@ -1107,23 +1107,23 @@ TEST_F(CookiesViewTest, FilterRemove) { "foo1,_Cookies,__B," "gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); // Results are filtered immediately if you activate (hit enter in the entry). gtk_widget_activate(cookies_view.filter_entry_); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," "gdbhost2,_Web Databases,__db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(ExpandByPath(cookies_view, "1")); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," "gdbhost2,+Web Databases,++db2," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0")); @@ -1140,8 +1140,8 @@ TEST_F(CookiesViewTest, FilterRemove) { SCOPED_TRACE("First selection removed"); EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," - "host1,_Local Storage,__origin1," - "host2,_Local Storage,__origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,_Local Storage,__http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); @@ -1150,8 +1150,8 @@ TEST_F(CookiesViewTest, FilterRemove) { ASSERT_TRUE(ExpandByPath(cookies_view, "2")); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," - "host1,_Local Storage,__origin1," - "host2,+Local Storage,++origin2", + "host1,_Local Storage,__http://host1:1/," + "host2,+Local Storage,++http://host2:2/", GetDisplayedCookies(cookies_view).c_str()); ASSERT_TRUE(SelectByPath(cookies_view, "2:0:0")); @@ -1168,7 +1168,7 @@ TEST_F(CookiesViewTest, FilterRemove) { SCOPED_TRACE("First selection removed"); EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str()); EXPECT_STREQ("gdbhost1,_Web Databases,__db1," - "host1,_Local Storage,__origin1", + "host1,_Local Storage,__http://host1:1/", GetDisplayedCookies(cookies_view).c_str()); EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_)); EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_)); diff --git a/chrome/browser/mock_browsing_data_database_helper.cc b/chrome/browser/mock_browsing_data_database_helper.cc index 54e33f4..c62445e 100644 --- a/chrome/browser/mock_browsing_data_database_helper.cc +++ b/chrome/browser/mock_browsing_data_database_helper.cc @@ -36,10 +36,12 @@ void MockBrowsingDataDatabaseHelper::DeleteDatabase( void MockBrowsingDataDatabaseHelper::AddDatabaseSamples() { response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo( - "gdbhost1", "db1", "http_gdbhost1_1", "description 1", 1, base::Time())); + "gdbhost1", "db1", "http_gdbhost1_1", "description 1", + "http://gdbhost1:1/", 1, base::Time())); databases_["http_gdbhost1_1:db1"] = true; response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo( - "gdbhost2", "db2", "http_gdbhost2_2", "description 2", 2, base::Time())); + "gdbhost2", "db2", "http_gdbhost2_2", "description 2", + "http://gdbhost2:2/", 2, base::Time())); databases_["http_gdbhost2_2:db2"] = true; } diff --git a/chrome/browser/mock_browsing_data_local_storage_helper.cc b/chrome/browser/mock_browsing_data_local_storage_helper.cc index bb6c0ce..0b80d37 100644 --- a/chrome/browser/mock_browsing_data_local_storage_helper.cc +++ b/chrome/browser/mock_browsing_data_local_storage_helper.cc @@ -35,12 +35,12 @@ void MockBrowsingDataLocalStorageHelper::DeleteLocalStorageFile( void MockBrowsingDataLocalStorageHelper::AddLocalStorageSamples() { response_.push_back( BrowsingDataLocalStorageHelper::LocalStorageInfo( - "http", "host1", 1, "db1", "origin1", + "http", "host1", 1, "db1", "http://host1:1/", FilePath(FILE_PATH_LITERAL("file1")), 1, base::Time())); files_[FILE_PATH_LITERAL("file1")] = true; response_.push_back( BrowsingDataLocalStorageHelper::LocalStorageInfo( - "http", "host2", 2, "db2", "origin2", + "http", "host2", 2, "db2", "http://host2:2/", FilePath(FILE_PATH_LITERAL("file2")), 2, base::Time())); files_[FILE_PATH_LITERAL("file2")] = true; } |