summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/options
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/gtk/options')
-rw-r--r--chrome/browser/gtk/options/advanced_contents_gtk.cc4
-rw-r--r--chrome/browser/gtk/options/cookies_view.cc152
-rw-r--r--chrome/browser/gtk/options/cookies_view.h35
-rw-r--r--chrome/browser/gtk/options/cookies_view_unittest.cc369
4 files changed, 456 insertions, 104 deletions
diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc
index 908f212..d493a39 100644
--- a/chrome/browser/gtk/options/advanced_contents_gtk.cc
+++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc
@@ -761,7 +761,9 @@ void PrivacySection::OnCookieBehaviorChanged(GtkComboBox* combo_box,
void PrivacySection::OnShowCookiesButtonClicked(
GtkButton *button, PrivacySection* privacy_section) {
privacy_section->UserMetricsRecordAction("Options_ShowCookies", NULL);
- CookiesView::Show(privacy_section->profile());
+ CookiesView::Show(privacy_section->profile(),
+ new BrowsingDataLocalStorageHelper(
+ privacy_section->profile()));
}
void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) {
diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc
index fb9c8c6..896e3b1 100644
--- a/chrome/browser/gtk/options/cookies_view.cc
+++ b/chrome/browser/gtk/options/cookies_view.cc
@@ -35,8 +35,8 @@ enum {
// The currently open cookie manager, if any.
CookiesView* instance_ = NULL;
-void InitCookieDetailStyle(GtkWidget* entry, GtkStyle* label_style,
- GtkStyle* dialog_style) {
+void InitBrowserDetailStyle(GtkWidget* entry, GtkStyle* label_style,
+ GtkStyle* dialog_style) {
gtk_widget_modify_fg(entry, GTK_STATE_NORMAL,
&label_style->fg[GTK_STATE_NORMAL]);
gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE,
@@ -57,20 +57,26 @@ CookiesView::~CookiesView() {
}
// static
-void CookiesView::Show(Profile* profile) {
+void CookiesView::Show(
+ Profile* profile,
+ BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper) {
DCHECK(profile);
+ DCHECK(browsing_data_local_storage_helper);
// If there's already an existing editor window, activate it.
if (instance_) {
gtk_window_present(GTK_WINDOW(instance_->dialog_));
} else {
- instance_ = new CookiesView(profile);
+ instance_ = new CookiesView(profile, browsing_data_local_storage_helper);
instance_->InitStylesAndShow();
}
}
-CookiesView::CookiesView(Profile* profile)
+CookiesView::CookiesView(
+ Profile* profile,
+ BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper)
: profile_(profile),
+ browsing_data_local_storage_helper_(browsing_data_local_storage_helper),
filter_update_factory_(this) {
Init();
}
@@ -160,7 +166,8 @@ void CookiesView::Init() {
GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0);
- cookies_tree_model_.reset(new CookiesTreeModel(profile_));
+ cookies_tree_model_.reset(new CookiesTreeModel(
+ profile_, browsing_data_local_storage_helper_));
cookies_tree_adapter_.reset(
new gtk_tree::TreeAdapter(this, cookies_tree_model_.get()));
tree_ = gtk_tree_view_new_with_model(
@@ -193,31 +200,54 @@ void CookiesView::Init() {
G_CALLBACK(OnSelectionChanged), this);
// Cookie details.
- GtkWidget* details_frame = gtk_frame_new(NULL);
- gtk_frame_set_shadow_type(GTK_FRAME(details_frame), GTK_SHADOW_ETCHED_IN);
- gtk_box_pack_start(GTK_BOX(cookie_list_vbox), details_frame,
+ GtkWidget* cookie_details_frame = gtk_frame_new(NULL);
+ gtk_frame_set_shadow_type(GTK_FRAME(cookie_details_frame),
+ GTK_SHADOW_ETCHED_IN);
+ gtk_box_pack_start(GTK_BOX(cookie_list_vbox), cookie_details_frame,
FALSE, FALSE, 0);
cookie_details_table_ = gtk_table_new(7, 2, FALSE);
- gtk_container_add(GTK_CONTAINER(details_frame), cookie_details_table_);
+ gtk_container_add(GTK_CONTAINER(cookie_details_frame), cookie_details_table_);
gtk_table_set_col_spacing(GTK_TABLE(cookie_details_table_), 0,
gtk_util::kLabelSpacing);
int row = 0;
- InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL,
- &cookie_name_entry_);
- InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_CONTENT_LABEL,
- &cookie_content_entry_);
- InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL,
- &cookie_domain_entry_);
- InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_PATH_LABEL,
- &cookie_path_entry_);
- InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_SENDFOR_LABEL,
- &cookie_send_for_entry_);
- InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL,
- &cookie_created_entry_);
- InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL,
- &cookie_expires_entry_);
+ InitDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL,
+ cookie_details_table_, &cookie_name_entry_);
+ InitDetailRow(row++, IDS_COOKIES_COOKIE_CONTENT_LABEL,
+ cookie_details_table_, &cookie_content_entry_);
+ InitDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL,
+ cookie_details_table_, &cookie_domain_entry_);
+ InitDetailRow(row++, IDS_COOKIES_COOKIE_PATH_LABEL,
+ cookie_details_table_, &cookie_path_entry_);
+ InitDetailRow(row++, IDS_COOKIES_COOKIE_SENDFOR_LABEL,
+ cookie_details_table_, &cookie_send_for_entry_);
+ InitDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL,
+ cookie_details_table_, &cookie_created_entry_);
+ InitDetailRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL,
+ cookie_details_table_, &cookie_expires_entry_);
+
+ // Local storage details.
+ GtkWidget* local_storage_details_frame = gtk_frame_new(NULL);
+ gtk_frame_set_shadow_type(GTK_FRAME(local_storage_details_frame),
+ GTK_SHADOW_ETCHED_IN);
+ gtk_box_pack_start(GTK_BOX(cookie_list_vbox), local_storage_details_frame,
+ FALSE, FALSE, 0);
+ local_storage_details_table_ = gtk_table_new(3, 2, FALSE);
+ gtk_container_add(GTK_CONTAINER(local_storage_details_frame),
+ local_storage_details_table_);
+ gtk_table_set_col_spacing(GTK_TABLE(local_storage_details_table_), 0,
+ gtk_util::kLabelSpacing);
+
+ row = 0;
+ InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL,
+ local_storage_details_table_, &local_storage_origin_entry_);
+ InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL,
+ local_storage_details_table_, &local_storage_size_entry_);
+ InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL,
+ local_storage_details_table_,
+ &local_storage_last_modified_entry_);
+ UpdateVisibleDetailedInfo(cookie_details_table_);
// Populate the view.
cookies_tree_adapter_->Init();
SetInitialTreeState();
@@ -231,30 +261,38 @@ void CookiesView::InitStylesAndShow() {
GtkStyle* label_style = gtk_widget_get_style(description_label_);
GtkStyle* dialog_style = gtk_widget_get_style(dialog_);
- InitCookieDetailStyle(cookie_name_entry_, label_style, dialog_style);
- InitCookieDetailStyle(cookie_content_entry_, label_style, dialog_style);
- InitCookieDetailStyle(cookie_domain_entry_, label_style, dialog_style);
- InitCookieDetailStyle(cookie_path_entry_, label_style, dialog_style);
- InitCookieDetailStyle(cookie_send_for_entry_, label_style, dialog_style);
- InitCookieDetailStyle(cookie_created_entry_, label_style, dialog_style);
- InitCookieDetailStyle(cookie_expires_entry_, label_style, dialog_style);
+ // Cookie details.
+ InitBrowserDetailStyle(cookie_name_entry_, label_style, dialog_style);
+ InitBrowserDetailStyle(cookie_content_entry_, label_style, dialog_style);
+ InitBrowserDetailStyle(cookie_domain_entry_, label_style, dialog_style);
+ InitBrowserDetailStyle(cookie_path_entry_, label_style, dialog_style);
+ InitBrowserDetailStyle(cookie_send_for_entry_, label_style, dialog_style);
+ InitBrowserDetailStyle(cookie_created_entry_, label_style, dialog_style);
+ InitBrowserDetailStyle(cookie_expires_entry_, label_style, dialog_style);
+
+ // Local storage details.
+ InitBrowserDetailStyle(local_storage_origin_entry_, label_style,
+ dialog_style);
+ InitBrowserDetailStyle(local_storage_size_entry_, label_style, dialog_style);
+ InitBrowserDetailStyle(local_storage_last_modified_entry_, label_style,
+ dialog_style);
gtk_widget_show_all(dialog_);
}
-void CookiesView::InitCookieDetailRow(int row, int label_id,
- GtkWidget** entry) {
+void CookiesView::InitDetailRow(int row, int label_id,
+ GtkWidget* details_table, GtkWidget** entry) {
GtkWidget* name_label = gtk_label_new(
l10n_util::GetStringUTF8(label_id).c_str());
gtk_misc_set_alignment(GTK_MISC(name_label), 1, 0.5);
- gtk_table_attach(GTK_TABLE(cookie_details_table_), name_label,
+ gtk_table_attach(GTK_TABLE(details_table), name_label,
0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
*entry = gtk_entry_new();
gtk_entry_set_editable(GTK_ENTRY(*entry), FALSE);
gtk_entry_set_has_frame(GTK_ENTRY(*entry), FALSE);
- gtk_table_attach_defaults(GTK_TABLE(cookie_details_table_), *entry,
+ gtk_table_attach_defaults(GTK_TABLE(details_table), *entry,
1, 2, row, row + 1);
}
@@ -279,9 +317,15 @@ void CookiesView::EnableControls() {
static_cast<CookieTreeNode*>(
cookies_tree_adapter_->GetNode(&iter))->GetDetailedInfo();
if (detailed_info.node_type == CookieTreeNode::DetailedInfo::TYPE_COOKIE) {
+ UpdateVisibleDetailedInfo(cookie_details_table_);
PopulateCookieDetails(detailed_info.cookie->first,
detailed_info.cookie->second);
+ } else if (detailed_info.node_type ==
+ CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE) {
+ UpdateVisibleDetailedInfo(local_storage_details_table_);
+ PopulateLocalStorageDetails(*detailed_info.local_storage_info);
} else {
+ UpdateVisibleDetailedInfo(cookie_details_table_);
ClearCookieDetails();
}
} else {
@@ -299,6 +343,12 @@ void CookiesView::SetCookieDetailsSensitivity(gboolean enabled) {
gtk_widget_set_sensitive(cookie_expires_entry_, enabled);
}
+void CookiesView::SetLocalStorageDetailsSensitivity(gboolean enabled) {
+ gtk_widget_set_sensitive(local_storage_origin_entry_, enabled);
+ gtk_widget_set_sensitive(local_storage_size_entry_, enabled);
+ gtk_widget_set_sensitive(local_storage_last_modified_entry_, enabled);
+}
+
void CookiesView::PopulateCookieDetails(
const std::string& domain,
const net::CookieMonster::CanonicalCookie& cookie) {
@@ -326,6 +376,22 @@ void CookiesView::PopulateCookieDetails(
SetCookieDetailsSensitivity(TRUE);
}
+void CookiesView::PopulateLocalStorageDetails(
+ const BrowsingDataLocalStorageHelper::LocalStorageInfo&
+ local_storage_info) {
+ gtk_entry_set_text(GTK_ENTRY(local_storage_origin_entry_),
+ local_storage_info.origin.c_str());
+ gtk_entry_set_text(GTK_ENTRY(local_storage_size_entry_),
+ WideToUTF8(FormatBytes(
+ local_storage_info.size,
+ GetByteDisplayUnits(local_storage_info.size),
+ true)).c_str());
+ gtk_entry_set_text(GTK_ENTRY(local_storage_last_modified_entry_),
+ WideToUTF8(base::TimeFormatFriendlyDateAndTime(
+ local_storage_info.last_modified)).c_str());
+ SetLocalStorageDetailsSensitivity(TRUE);
+}
+
void CookiesView::ClearCookieDetails() {
std::string no_cookie =
l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_NONESELECTED);
@@ -387,6 +453,7 @@ void CookiesView::OnResponse(GtkDialog* dialog, int response_id,
window->RemoveSelectedItems();
} else if (response_id == RESPONSE_REMOVE_ALL) {
window->cookies_tree_model_->DeleteAllCookies();
+ window->browsing_data_local_storage_helper_->DeleteAllLocalStorageFiles();
} else {
gtk_widget_destroy(window->dialog_);
}
@@ -437,6 +504,21 @@ void CookiesView::UpdateFilterResults() {
}
}
+void CookiesView::UpdateVisibleDetailedInfo(GtkWidget* table) {
+ // Toggle the parent (the table frame) visibility and sensitivity.
+ gtk_widget_show(gtk_widget_get_parent(table));
+ // Toggle the other tables.
+ if (table == cookie_details_table_) {
+ SetCookieDetailsSensitivity(true);
+ SetLocalStorageDetailsSensitivity(false);
+ gtk_widget_hide(gtk_widget_get_parent(local_storage_details_table_));
+ } else if (table == local_storage_details_table_) {
+ SetCookieDetailsSensitivity(false);
+ SetLocalStorageDetailsSensitivity(true);
+ gtk_widget_hide(gtk_widget_get_parent(cookie_details_table_));
+ }
+}
+
// static
void CookiesView::OnFilterEntryActivated(GtkEntry* entry, CookiesView* window) {
window->filter_update_factory_.RevokeAll();
diff --git a/chrome/browser/gtk/options/cookies_view.h b/chrome/browser/gtk/options/cookies_view.h
index 260e3db..7720e13 100644
--- a/chrome/browser/gtk/options/cookies_view.h
+++ b/chrome/browser/gtk/options/cookies_view.h
@@ -12,6 +12,7 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
+#include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/common/gtk_tree.h"
#include "net/base/cookie_monster.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
@@ -31,14 +32,18 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate {
virtual ~CookiesView();
// Create (if necessary) and show the cookie manager window.
- static void Show(Profile* profile);
+ static void Show(
+ Profile* profile,
+ BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper);
// gtk_tree::TreeAdapter::Delegate implementation.
virtual void OnAnyModelUpdateStart();
virtual void OnAnyModelUpdate();
private:
- explicit CookiesView(Profile* profile);
+ CookiesView(
+ Profile* profile,
+ BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper);
// Initialize the dialog contents and layout.
void Init();
@@ -46,8 +51,9 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate {
// Initialize the widget styles and display the dialog.
void InitStylesAndShow();
- // Helper for initializing cookie details table.
- void InitCookieDetailRow(int row, int label_id, GtkWidget** display_label);
+ // Helper for initializing cookie / local storage details table.
+ void InitDetailRow(int row, int label_id,
+ GtkWidget* details_table, GtkWidget** display_label);
// Set the initial selection and tree expanded state.
void SetInitialTreeState();
@@ -58,10 +64,18 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate {
// Set sensitivity of cookie details.
void SetCookieDetailsSensitivity(gboolean enabled);
+ // Set sensitivity of local storage details.
+ void SetLocalStorageDetailsSensitivity(gboolean enabled);
+
// Show the details of the currently selected cookie.
void PopulateCookieDetails(const std::string& domain,
const net::CookieMonster::CanonicalCookie& cookie);
+ // Show the details of the currently selected local storage.
+ void PopulateLocalStorageDetails(
+ const BrowsingDataLocalStorageHelper::LocalStorageInfo&
+ local_storage_info);
+
// Reset the cookie details display.
void ClearCookieDetails();
@@ -90,6 +104,9 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate {
// Filter the list against the text in |filter_entry_|.
void UpdateFilterResults();
+ // Sets which of the detailed info table is visible.
+ void UpdateVisibleDetailedInfo(GtkWidget* table);
+
// Callbacks for user actions filtering the list.
static void OnFilterEntryActivated(GtkEntry* entry, CookiesView* window);
static void OnFilterEntryChanged(GtkEditable* editable, CookiesView* window);
@@ -120,9 +137,19 @@ class CookiesView : public gtk_tree::TreeAdapter::Delegate {
GtkWidget* cookie_created_entry_;
GtkWidget* cookie_expires_entry_;
+ // The local storage details widgets.
+ GtkWidget* local_storage_details_table_;
+ GtkWidget* local_storage_origin_entry_;
+ GtkWidget* local_storage_size_entry_;
+ GtkWidget* local_storage_last_modified_entry_;
+
// The profile.
Profile* profile_;
+ // Local Storage Helper.
+ scoped_refptr<BrowsingDataLocalStorageHelper>
+ browsing_data_local_storage_helper_;
+
// A factory to construct Runnable Methods so that we can be called back to
// re-evaluate the model after the search query string changes.
ScopedRunnableMethodFactory<CookiesView> filter_update_factory_;
diff --git a/chrome/browser/gtk/options/cookies_view_unittest.cc b/chrome/browser/gtk/options/cookies_view_unittest.cc
index 935f6c2..4092dbf 100644
--- a/chrome/browser/gtk/options/cookies_view_unittest.cc
+++ b/chrome/browser/gtk/options/cookies_view_unittest.cc
@@ -10,6 +10,7 @@
#include <gtk/gtk.h>
#include "base/string_util.h"
+#include "chrome/browser/mock_browsing_data_local_storage_helper.h"
#include "chrome/browser/net/url_request_context_getter.h"
#include "chrome/test/testing_profile.h"
#include "net/url_request/url_request_context.h"
@@ -26,24 +27,37 @@ class CookiesViewTest : public testing::Test {
virtual void SetUp() {
profile_.reset(new TestingProfile());
profile_->CreateRequestContext();
+ mock_browsing_data_helper_ = new MockBrowsingDataLocalStorageHelper(
+ profile_.get());
}
- void CheckDetailsSensitivity(gboolean expected,
+ void CheckDetailsSensitivity(gboolean expected_cookies,
+ gboolean expected_local_storage,
const CookiesView& cookies_view) {
- EXPECT_EQ(expected,
+ // Cookies
+ EXPECT_EQ(expected_cookies,
GTK_WIDGET_SENSITIVE(cookies_view.cookie_name_entry_));
- EXPECT_EQ(expected,
+ EXPECT_EQ(expected_cookies,
GTK_WIDGET_SENSITIVE(cookies_view.cookie_content_entry_));
- EXPECT_EQ(expected,
+ EXPECT_EQ(expected_cookies,
GTK_WIDGET_SENSITIVE(cookies_view.cookie_domain_entry_));
- EXPECT_EQ(expected,
+ EXPECT_EQ(expected_cookies,
GTK_WIDGET_SENSITIVE(cookies_view.cookie_path_entry_));
- EXPECT_EQ(expected,
+ EXPECT_EQ(expected_cookies,
GTK_WIDGET_SENSITIVE(cookies_view.cookie_send_for_entry_));
- EXPECT_EQ(expected,
+ EXPECT_EQ(expected_cookies,
GTK_WIDGET_SENSITIVE(cookies_view.cookie_created_entry_));
- EXPECT_EQ(expected,
+ EXPECT_EQ(expected_cookies,
GTK_WIDGET_SENSITIVE(cookies_view.cookie_expires_entry_));
+ // Local Storage
+ EXPECT_EQ(expected_local_storage,
+ GTK_WIDGET_SENSITIVE(cookies_view.local_storage_origin_entry_));
+ EXPECT_EQ(expected_local_storage,
+ GTK_WIDGET_SENSITIVE(cookies_view.local_storage_size_entry_));
+ EXPECT_EQ(expected_local_storage,
+ GTK_WIDGET_SENSITIVE(
+ cookies_view.local_storage_last_modified_entry_));
+
}
// Get the cookie names in the cookie list, as a comma seperated string.
@@ -148,13 +162,14 @@ class CookiesViewTest : public testing::Test {
ChromeThread io_thread_;
scoped_ptr<TestingProfile> profile_;
+ scoped_refptr<MockBrowsingDataLocalStorageHelper> mock_browsing_data_helper_;
};
TEST_F(CookiesViewTest, Empty) {
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
}
@@ -167,21 +182,27 @@ TEST_F(CookiesViewTest, Noop) {
monster->SetCookie(GURL("http://foo1"), "E=1");
monster->SetCookie(GURL("http://foo2"), "G=1");
monster->SetCookie(GURL("http://foo2"), "X=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
EXPECT_STREQ("foo0,_Cookies,__C,__D,"
"foo1,_Cookies,__A,__B,__E,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
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_));
- CheckDetailsSensitivity(FALSE, cookies_view);
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
}
TEST_F(CookiesViewTest, RemoveAll) {
net::CookieMonster* monster = profile_->GetCookieMonster();
monster->SetCookie(GURL("http://foo"), "A=1");
monster->SetCookie(GURL("http://foo2"), "B=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
// Reset the selection of the first row.
gtk_tree_selection_unselect_all(cookies_view.selection_);
@@ -190,8 +211,10 @@ TEST_F(CookiesViewTest, RemoveAll) {
SCOPED_TRACE("Before removing");
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
- EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B",
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
+ EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
}
@@ -201,8 +224,9 @@ TEST_F(CookiesViewTest, RemoveAll) {
EXPECT_EQ(0u, monster->GetAllCookies().size());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
+ EXPECT_TRUE(mock_browsing_data_helper_->delete_all_files_called_);
}
}
@@ -210,7 +234,9 @@ TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) {
net::CookieMonster* monster = profile_->GetCookieMonster();
monster->SetCookie(GURL("http://foo"), "A=1");
monster->SetCookie(GURL("http://foo2"), "B=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str());
EXPECT_EQ(1, gtk_tree_selection_count_selected_rows(cookies_view.selection_));
@@ -218,8 +244,10 @@ TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) {
SCOPED_TRACE("Before removing");
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
- EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B",
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
+ EXPECT_STREQ("foo,_Cookies,__A,foo2,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
}
@@ -229,10 +257,11 @@ TEST_F(CookiesViewTest, RemoveAllWithDefaultSelected) {
EXPECT_EQ(0u, monster->GetAllCookies().size());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(FALSE, cookies_view);
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(0,
gtk_tree_selection_count_selected_rows(cookies_view.selection_));
+ EXPECT_TRUE(mock_browsing_data_helper_->delete_all_files_called_);
}
}
@@ -241,7 +270,9 @@ TEST_F(CookiesViewTest, Remove) {
monster->SetCookie(GURL("http://foo1"), "A=1");
monster->SetCookie(GURL("http://foo2"), "B=1");
monster->SetCookie(GURL("http://foo2"), "C=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
ASSERT_TRUE(ExpandByPath(cookies_view, "1"));
ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0"));
@@ -250,8 +281,10 @@ TEST_F(CookiesViewTest, Remove) {
SCOPED_TRACE("First selection");
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(TRUE, cookies_view);
- EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C",
+ CheckDetailsSensitivity(TRUE, FALSE, cookies_view);
+ EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++B,++C,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
}
@@ -260,12 +293,14 @@ TEST_F(CookiesViewTest, Remove) {
{
SCOPED_TRACE("First selection removed");
EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
- EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C",
+ EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,++C,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
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_));
EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str());
- CheckDetailsSensitivity(TRUE, cookies_view);
+ CheckDetailsSensitivity(TRUE, FALSE, cookies_view);
}
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
@@ -274,16 +309,20 @@ TEST_F(CookiesViewTest, Remove) {
{
SCOPED_TRACE("Second selection");
EXPECT_STREQ("A", GetMonsterCookies(monster).c_str());
- EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies",
+ EXPECT_STREQ("foo1,_Cookies,__A,foo2,+Cookies,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
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_));
EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str());
- CheckDetailsSensitivity(FALSE, cookies_view);
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
}
ASSERT_TRUE(ExpandByPath(cookies_view, "0"));
- EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies",
+ EXPECT_STREQ("foo1,+Cookies,++A,foo2,+Cookies,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
ASSERT_TRUE(SelectByPath(cookies_view, "0:0:0"));
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
@@ -295,9 +334,35 @@ TEST_F(CookiesViewTest, Remove) {
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str());
- CheckDetailsSensitivity(FALSE, cookies_view);
- EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies",
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
+ EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
+ GetDisplayedCookies(cookies_view).c_str());
+ }
+
+ ASSERT_TRUE(ExpandByPath(cookies_view, "2"));
+ EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies,"
+ "host1,+Local Storage,++origin1,"
+ "host2,_Local Storage,__origin2",
+ GetDisplayedCookies(cookies_view).c_str());
+ ASSERT_TRUE(SelectByPath(cookies_view, "2:0:0"));
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
+ gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
+
+ {
+ SCOPED_TRACE("Third selection removed");
+ EXPECT_EQ(0u, monster->GetAllCookies().size());
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
+ EXPECT_STREQ("2:0", GetSelectedPath(cookies_view).c_str());
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
+ EXPECT_STREQ("foo1,+Cookies,foo2,+Cookies,"
+ "host1,+Local Storage,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
+ EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ ==
+ FilePath(FILE_PATH_LITERAL("file1")));
}
}
@@ -310,16 +375,23 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) {
monster->SetCookie(GURL("http://foo1"), "E=1");
monster->SetCookie(GURL("http://foo2"), "G=1");
monster->SetCookie(GURL("http://foo2"), "X=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
+
EXPECT_STREQ("foo0,_Cookies,__C,__D,"
"foo1,_Cookies,__A,__B,__E,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
ASSERT_TRUE(ExpandByPath(cookies_view, "1"));
EXPECT_STREQ("foo0,_Cookies,__C,__D,"
"foo1,+Cookies,++A,++B,++E,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
ASSERT_TRUE(SelectByPath(cookies_view, "1:0"));
@@ -331,7 +403,9 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) {
EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("foo0,_Cookies,__C,__D,"
"foo1,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
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_));
@@ -340,7 +414,9 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) {
ASSERT_TRUE(ExpandByPath(cookies_view, "0"));
EXPECT_STREQ("foo0,+Cookies,++C,++D,"
"foo1,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
ASSERT_TRUE(SelectByPath(cookies_view, "0:0"));
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
@@ -348,7 +424,9 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) {
EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("foo0,"
"foo1,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
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_));
@@ -357,7 +435,9 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) {
ASSERT_TRUE(ExpandByPath(cookies_view, "2"));
EXPECT_STREQ("foo0,"
"foo1,"
- "foo2,+Cookies,++G,++X",
+ "foo2,+Cookies,++G,++X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
ASSERT_TRUE(SelectByPath(cookies_view, "2:0"));
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
@@ -365,11 +445,36 @@ TEST_F(CookiesViewTest, RemoveCookiesByDomain) {
EXPECT_STREQ("", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("foo0,"
"foo1,"
- "foo2",
+ "foo2,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
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_));
EXPECT_STREQ("2", GetSelectedPath(cookies_view).c_str());
+
+ ASSERT_TRUE(ExpandByPath(cookies_view, "3"));
+ EXPECT_STREQ("foo0,"
+ "foo1,"
+ "foo2,"
+ "host1,+Local Storage,++origin1,"
+ "host2,_Local Storage,__origin2",
+ GetDisplayedCookies(cookies_view).c_str());
+ ASSERT_TRUE(SelectByPath(cookies_view, "3:0"));
+ gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
+
+ EXPECT_STREQ("", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("foo0,"
+ "foo1,"
+ "foo2,"
+ "host1,"
+ "host2,_Local Storage,__origin2",
+ 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_));
+ EXPECT_STREQ("3", GetSelectedPath(cookies_view).c_str());
+ EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ ==
+ FilePath(FILE_PATH_LITERAL("file1")));
}
TEST_F(CookiesViewTest, RemoveByDomain) {
@@ -381,10 +486,15 @@ TEST_F(CookiesViewTest, RemoveByDomain) {
monster->SetCookie(GURL("http://foo1"), "E=1");
monster->SetCookie(GURL("http://foo2"), "G=1");
monster->SetCookie(GURL("http://foo2"), "X=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
+
EXPECT_STREQ("foo0,_Cookies,__C,__D,"
"foo1,_Cookies,__A,__B,__E,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
ASSERT_TRUE(SelectByPath(cookies_view, "1"));
@@ -396,7 +506,9 @@ TEST_F(CookiesViewTest, RemoveByDomain) {
EXPECT_STREQ("C,D,G,X", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("foo0,_Cookies,__C,__D,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
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_));
@@ -406,7 +518,9 @@ TEST_F(CookiesViewTest, RemoveByDomain) {
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str());
- EXPECT_STREQ("foo2,_Cookies,__G,__X",
+ EXPECT_STREQ("foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
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_));
@@ -415,9 +529,33 @@ TEST_F(CookiesViewTest, RemoveByDomain) {
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
EXPECT_STREQ("", GetMonsterCookies(monster).c_str());
- EXPECT_STREQ("", GetDisplayedCookies(cookies_view).c_str());
+ EXPECT_STREQ("host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
+ 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_));
+ EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str());
+
+ gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
+
+ EXPECT_STREQ("", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("host2,_Local Storage,__origin2",
+ 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_));
+ EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ ==
+ FilePath(FILE_PATH_LITERAL("file1")));
+ EXPECT_STREQ("0", GetSelectedPath(cookies_view).c_str());
+
+ gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
+ EXPECT_STREQ("", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("",
+ GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
+ EXPECT_TRUE(mock_browsing_data_helper_->last_deleted_file_ ==
+ FilePath(FILE_PATH_LITERAL("file2")));
+
EXPECT_EQ(0, gtk_tree_selection_count_selected_rows(cookies_view.selection_));
}
@@ -430,10 +568,15 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) {
monster->SetCookie(GURL("http://foo1"), "E=1");
monster->SetCookie(GURL("http://foo2"), "G=1");
monster->SetCookie(GURL("http://foo2"), "X=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
+
EXPECT_STREQ("foo0,_Cookies,__C,__D,"
"foo1,_Cookies,__A,__B,__E,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
@@ -444,7 +587,9 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) {
EXPECT_STREQ("B,A,E,G,X", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("foo1,_Cookies,__A,__B,__E,"
- "foo2,_Cookies,__G,__X",
+ "foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
@@ -453,7 +598,28 @@ TEST_F(CookiesViewTest, RemoveDefaultSelection) {
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
EXPECT_STREQ("G,X", GetMonsterCookies(monster).c_str());
- EXPECT_STREQ("foo2,_Cookies,__G,__X",
+ EXPECT_STREQ("foo2,_Cookies,__G,__X,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
+ 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_));
+
+ 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",
+ 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_));
+
+ gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
+
+ EXPECT_STREQ("", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
@@ -474,11 +640,16 @@ TEST_F(CookiesViewTest, Filter) {
monster->SetCookie(GURL("http://bar0"), "D=1");
monster->SetCookie(GURL("http://foo1"), "B=1");
monster->SetCookie(GURL("http://bar1"), "A=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
+
EXPECT_STREQ("bar0,_Cookies,__D,"
"bar1,_Cookies,__A,"
"foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_));
@@ -489,7 +660,9 @@ TEST_F(CookiesViewTest, Filter) {
EXPECT_STREQ("bar0,_Cookies,__D,"
"bar1,_Cookies,__A,"
"foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
// Results are filtered immediately if you activate (hit enter in the entry).
@@ -504,7 +677,15 @@ TEST_F(CookiesViewTest, Filter) {
EXPECT_STREQ("bar0,_Cookies,__D,"
"bar1,_Cookies,__A,"
"foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
+ 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("host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
}
@@ -514,11 +695,16 @@ TEST_F(CookiesViewTest, FilterRemoveAll) {
monster->SetCookie(GURL("http://bar0"), "D=1");
monster->SetCookie(GURL("http://foo1"), "B=1");
monster->SetCookie(GURL("http://bar1"), "A=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
+
EXPECT_STREQ("bar0,_Cookies,__D,"
"bar1,_Cookies,__A,"
"foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_));
@@ -529,7 +715,9 @@ TEST_F(CookiesViewTest, FilterRemoveAll) {
EXPECT_STREQ("bar0,_Cookies,__D,"
"bar1,_Cookies,__A,"
"foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
// Results are filtered immediately if you activate (hit enter in the entry).
@@ -550,7 +738,9 @@ TEST_F(CookiesViewTest, FilterRemoveAll) {
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_));
EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_)));
EXPECT_STREQ("foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
}
@@ -561,11 +751,16 @@ TEST_F(CookiesViewTest, FilterRemove) {
monster->SetCookie(GURL("http://foo1"), "B=1");
monster->SetCookie(GURL("http://bar1"), "A=1");
monster->SetCookie(GURL("http://bar1"), "E=1");
- CookiesView cookies_view(profile_.get());
+ CookiesView cookies_view(profile_.get(), mock_browsing_data_helper_);
+ mock_browsing_data_helper_->AddLocalStorageSamples();
+ mock_browsing_data_helper_->Notify();
+
EXPECT_STREQ("bar0,_Cookies,__D,"
"bar1,_Cookies,__A,__E,"
"foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
EXPECT_STREQ("D,A,E,C,B", GetMonsterCookies(monster).c_str());
@@ -577,7 +772,9 @@ TEST_F(CookiesViewTest, FilterRemove) {
EXPECT_STREQ("bar0,_Cookies,__D,"
"bar1,_Cookies,__A,__E,"
"foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
// Results are filtered immediately if you activate (hit enter in the entry).
@@ -596,7 +793,7 @@ TEST_F(CookiesViewTest, FilterRemove) {
SCOPED_TRACE("First selection");
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
- CheckDetailsSensitivity(TRUE, cookies_view);
+ CheckDetailsSensitivity(TRUE, FALSE, cookies_view);
}
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
@@ -610,7 +807,7 @@ TEST_F(CookiesViewTest, FilterRemove) {
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
EXPECT_STREQ("1:0:0", GetSelectedPath(cookies_view).c_str());
- CheckDetailsSensitivity(TRUE, cookies_view);
+ CheckDetailsSensitivity(TRUE, FALSE, cookies_view);
}
gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
@@ -624,7 +821,7 @@ TEST_F(CookiesViewTest, FilterRemove) {
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str());
- CheckDetailsSensitivity(FALSE, cookies_view);
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
}
ASSERT_TRUE(ExpandByPath(cookies_view, "0"));
@@ -638,7 +835,7 @@ TEST_F(CookiesViewTest, FilterRemove) {
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
EXPECT_STREQ("0:0", GetSelectedPath(cookies_view).c_str());
- CheckDetailsSensitivity(FALSE, cookies_view);
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
EXPECT_STREQ("bar0,+Cookies,"
"bar1,+Cookies",
GetDisplayedCookies(cookies_view).c_str());
@@ -648,6 +845,50 @@ TEST_F(CookiesViewTest, FilterRemove) {
EXPECT_EQ(FALSE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_));
EXPECT_STREQ("", gtk_entry_get_text(GTK_ENTRY(cookies_view.filter_entry_)));
EXPECT_STREQ("foo0,_Cookies,__C,"
- "foo1,_Cookies,__B",
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
GetDisplayedCookies(cookies_view).c_str());
+
+ gtk_entry_set_text(GTK_ENTRY(cookies_view.filter_entry_), "hos");
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.filter_clear_button_));
+ // Entering text doesn't immediately filter the results.
+ EXPECT_STREQ("foo0,_Cookies,__C,"
+ "foo1,_Cookies,__B,"
+ "host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
+ 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("host1,_Local Storage,__origin1,"
+ "host2,_Local Storage,__origin2",
+ GetDisplayedCookies(cookies_view).c_str());
+
+ ASSERT_TRUE(ExpandByPath(cookies_view, "1"));
+ EXPECT_STREQ("host1,_Local Storage,__origin1,"
+ "host2,+Local Storage,++origin2",
+ GetDisplayedCookies(cookies_view).c_str());
+ ASSERT_TRUE(SelectByPath(cookies_view, "1:0:0"));
+
+ {
+ SCOPED_TRACE("First selection");
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_all_button_));
+ EXPECT_EQ(TRUE, GTK_WIDGET_SENSITIVE(cookies_view.remove_button_));
+ CheckDetailsSensitivity(FALSE, TRUE, cookies_view);
+ }
+
+ gtk_button_clicked(GTK_BUTTON(cookies_view.remove_button_));
+
+ {
+ SCOPED_TRACE("First selection removed");
+ EXPECT_STREQ("C,B", GetMonsterCookies(monster).c_str());
+ EXPECT_STREQ("host1,_Local Storage,__origin1,"
+ "host2,+Local Storage",
+ 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_));
+ EXPECT_STREQ("1:0", GetSelectedPath(cookies_view).c_str());
+ CheckDetailsSensitivity(FALSE, FALSE, cookies_view);
+ }
}