Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2288)

Unified Diff: chrome/browser/views/options/cookies_view.cc

Issue 435024: Adds back the ability to filter cookies by origin in the cookies options view... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/options/cookies_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/options/cookies_view.cc
===================================================================
--- chrome/browser/views/options/cookies_view.cc (revision 32803)
+++ chrome/browser/views/options/cookies_view.cc (working copy)
@@ -29,6 +29,7 @@
views::Window* CookiesView::instance_ = NULL;
static const int kCookieInfoViewBorderSize = 1;
static const int kCookieInfoViewInsetSize = 3;
+static const int kSearchFilterDelayMs = 500;
///////////////////////////////////////////////////////////////////////////////
@@ -44,15 +45,11 @@
void RemoveSelectedItems();
private:
- // Our model, as a CookiesTreeModel.
- CookiesTreeModel* cookies_model_;
-
DISALLOW_COPY_AND_ASSIGN(CookiesTreeView);
};
-CookiesTreeView::CookiesTreeView(CookiesTreeModel* cookies_model)
- : cookies_model_(cookies_model) {
- SetModel(cookies_model_);
+CookiesTreeView::CookiesTreeView(CookiesTreeModel* cookies_model) {
+ SetModel(cookies_model);
SetRootShown(false);
SetEditable(false);
}
@@ -60,8 +57,8 @@
void CookiesTreeView::RemoveSelectedItems() {
TreeModelNode* selected_node = GetSelectedNode();
if (selected_node) {
- cookies_model_->DeleteCookieNode(static_cast<CookieTreeCookieNode*>(
- GetSelectedNode()));
+ static_cast<CookiesTreeModel*>(model())->DeleteCookieNode(
+ static_cast<CookieTreeCookieNode*>(GetSelectedNode()));
}
}
@@ -286,10 +283,35 @@
} else if (sender == remove_all_button_) {
cookies_tree_model_->DeleteAllCookies();
UpdateForEmptyState();
+ } else if (sender == clear_search_button_) {
+ ResetSearchQuery();
}
}
///////////////////////////////////////////////////////////////////////////////
+// CookiesView, views::Textfield::Controller implementation:
+
+void CookiesView::ContentsChanged(views::Textfield* sender,
+ const std::wstring& new_contents) {
+ clear_search_button_->SetEnabled(!search_field_->text().empty());
+ search_update_factory_.RevokeAll();
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ search_update_factory_.NewRunnableMethod(
+ &CookiesView::UpdateSearchResults), kSearchFilterDelayMs);
+}
+
+bool CookiesView::HandleKeystroke(views::Textfield* sender,
+ const views::Textfield::Keystroke& key) {
+ if (key.GetKeyboardCode() == base::VKEY_ESCAPE) {
+ ResetSearchQuery();
+ } else if (key.GetKeyboardCode() == base::VKEY_RETURN) {
+ search_update_factory_.RevokeAll();
+ UpdateSearchResults();
+ }
+ return false;
+}
+
+///////////////////////////////////////////////////////////////////////////////
// CookiesView, views::DialogDelegate implementation:
std::wstring CookiesView::GetWindowTitle() const {
@@ -364,19 +386,33 @@
CookiesView::CookiesView(Profile* profile)
:
+ search_label_(NULL),
+ search_field_(NULL),
+ clear_search_button_(NULL),
description_label_(NULL),
cookies_tree_(NULL),
info_view_(NULL),
remove_button_(NULL),
remove_all_button_(NULL),
- profile_(profile) {
+ profile_(profile),
+ ALLOW_THIS_IN_INITIALIZER_LIST(search_update_factory_(this)) {
}
-views::View* CookiesView::GetInitiallyFocusedView() {
- return cookies_tree_;
+
+void CookiesView::UpdateSearchResults() {
+ cookies_tree_model_->UpdateSearchResults(search_field_->text());
+ remove_all_button_->SetEnabled(cookies_tree_model_->GetRoot()->
+ GetTotalNodeCount() > 1);
}
void CookiesView::Init() {
+ search_label_ = new views::Label(
+ l10n_util::GetString(IDS_COOKIES_SEARCH_LABEL));
+ search_field_ = new views::Textfield;
+ search_field_->SetController(this);
+ clear_search_button_ = new views::NativeButton(
+ this, l10n_util::GetString(IDS_COOKIES_CLEAR_SEARCH_LABEL));
+ clear_search_button_->SetEnabled(false);
description_label_ = new views::Label(
l10n_util::GetString(IDS_COOKIES_INFO_LABEL));
description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
@@ -410,6 +446,12 @@
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
+ layout->StartRow(0, five_column_layout_id);
+ layout->AddView(search_label_);
+ layout->AddView(search_field_);
+ layout->AddView(clear_search_button_);
+ layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
+
layout->StartRow(0, single_column_layout_id);
layout->AddView(description_label_);
@@ -433,6 +475,12 @@
UpdateForEmptyState();
}
+void CookiesView::ResetSearchQuery() {
+ search_field_->SetText(EmptyWString());
+ clear_search_button_->SetEnabled(false);
+ UpdateSearchResults();
+}
+
void CookiesView::UpdateForEmptyState() {
info_view_->ClearCookieDisplay();
remove_button_->SetEnabled(false);
« no previous file with comments | « chrome/browser/views/options/cookies_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698