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

Side by Side Diff: chrome/browser/views/options/cookies_view.cc

Issue 155060: This patch changes the behavior of clear search button in cookies_view to wor... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/options/cookies_view.h" 5 #include "chrome/browser/views/options/cookies_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/color_utils.h" 10 #include "app/gfx/color_utils.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 virtual ~CookiesTableModel() {} 43 virtual ~CookiesTableModel() {}
44 44
45 // Returns information about the Cookie at the specified index. 45 // Returns information about the Cookie at the specified index.
46 std::string GetDomainAt(int index); 46 std::string GetDomainAt(int index);
47 net::CookieMonster::CanonicalCookie& GetCookieAt(int index); 47 net::CookieMonster::CanonicalCookie& GetCookieAt(int index);
48 48
49 // Remove the specified cookies from the Cookie Monster and update the view. 49 // Remove the specified cookies from the Cookie Monster and update the view.
50 void RemoveCookies(int start_index, int remove_count); 50 void RemoveCookies(int start_index, int remove_count);
51 void RemoveAllShownCookies(); 51 void RemoveAllShownCookies();
52 52
53 // TableModel implementation: 53 // TableModel methods.
54 virtual int RowCount(); 54 virtual int RowCount();
55 virtual std::wstring GetText(int row, int column_id); 55 virtual std::wstring GetText(int row, int column_id);
56 virtual SkBitmap GetIcon(int row); 56 virtual SkBitmap GetIcon(int row);
57 virtual int CompareValues(int row1, int row2, int column_id);
57 virtual void SetObserver(TableModelObserver* observer); 58 virtual void SetObserver(TableModelObserver* observer);
58 virtual int CompareValues(int row1, int row2, int column_id);
59 59
60 // Filter the cookies to only display matched results. 60 // Filter the cookies to only display matched results.
61 void UpdateSearchResults(const std::wstring& filter); 61 void UpdateSearchResults(const std::wstring& filter);
62 62
63 private: 63 private:
64 void LoadCookies(); 64 void LoadCookies();
65 void DoFilter(); 65 void DoFilter();
66 66
67 std::wstring filter_; 67 std::wstring filter_;
68 68
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Delete the cookie from the monster 123 // Delete the cookie from the monster
124 monster->DeleteCookie(all_it->first, all_it->second, true); 124 monster->DeleteCookie(all_it->first, all_it->second, true);
125 all_it = all_cookies_.erase(all_it); 125 all_it = all_cookies_.erase(all_it);
126 } 126 }
127 127
128 // By deleting entries from all_cookies, we just possibly moved stuff around 128 // By deleting entries from all_cookies, we just possibly moved stuff around
129 // and have thus invalidated all of our pointers, so rebuild shown_cookies. 129 // and have thus invalidated all of our pointers, so rebuild shown_cookies.
130 // We could do this all better if there was a way to mark elements of 130 // We could do this all better if there was a way to mark elements of
131 // all_cookies as dead instead of deleting, but this should be fine for now. 131 // all_cookies as dead instead of deleting, but this should be fine for now.
132 DoFilter(); 132 DoFilter();
133 observer_->OnItemsRemoved(start_index, remove_count); 133 if (observer_)
134 observer_->OnItemsRemoved(start_index, remove_count);
134 } 135 }
135 136
136 void CookiesTableModel::RemoveAllShownCookies() { 137 void CookiesTableModel::RemoveAllShownCookies() {
137 RemoveCookies(0, RowCount()); 138 RemoveCookies(0, RowCount());
138 } 139 }
139 140
140 /////////////////////////////////////////////////////////////////////////////// 141 ///////////////////////////////////////////////////////////////////////////////
141 // CookiesTableModel, TableModel implementation: 142 // CookiesTableModel, TableModel implementation:
142 143
143 int CookiesTableModel::RowCount() { 144 int CookiesTableModel::RowCount() {
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 609
609 void CookiesView::OnTableViewDelete(views::TableView* table_view) { 610 void CookiesView::OnTableViewDelete(views::TableView* table_view) {
610 cookies_table_->RemoveSelectedCookies(); 611 cookies_table_->RemoveSelectedCookies();
611 } 612 }
612 613
613 /////////////////////////////////////////////////////////////////////////////// 614 ///////////////////////////////////////////////////////////////////////////////
614 // CookiesView, views::Textfield::Controller implementation: 615 // CookiesView, views::Textfield::Controller implementation:
615 616
616 void CookiesView::ContentsChanged(views::Textfield* sender, 617 void CookiesView::ContentsChanged(views::Textfield* sender,
617 const std::wstring& new_contents) { 618 const std::wstring& new_contents) {
619 clear_search_button_->SetEnabled(!search_field_->text().empty());
618 search_update_factory_.RevokeAll(); 620 search_update_factory_.RevokeAll();
619 MessageLoop::current()->PostDelayedTask(FROM_HERE, 621 MessageLoop::current()->PostDelayedTask(FROM_HERE,
620 search_update_factory_.NewRunnableMethod( 622 search_update_factory_.NewRunnableMethod(
621 &CookiesView::UpdateSearchResults), kSearchFilterDelayMs); 623 &CookiesView::UpdateSearchResults), kSearchFilterDelayMs);
622 } 624 }
623 625
624 bool CookiesView::HandleKeystroke(views::Textfield* sender, 626 bool CookiesView::HandleKeystroke(views::Textfield* sender,
625 const views::Textfield::Keystroke& key) { 627 const views::Textfield::Keystroke& key) {
626 if (views::Textfield::IsKeystrokeEscape(key)) { 628 if (views::Textfield::IsKeystrokeEscape(key)) {
627 ResetSearchQuery(); 629 ResetSearchQuery();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 ALLOW_THIS_IN_INITIALIZER_LIST(search_update_factory_(this)) { 700 ALLOW_THIS_IN_INITIALIZER_LIST(search_update_factory_(this)) {
699 } 701 }
700 702
701 void CookiesView::Init() { 703 void CookiesView::Init() {
702 search_label_ = new views::Label( 704 search_label_ = new views::Label(
703 l10n_util::GetString(IDS_COOKIES_SEARCH_LABEL)); 705 l10n_util::GetString(IDS_COOKIES_SEARCH_LABEL));
704 search_field_ = new views::Textfield; 706 search_field_ = new views::Textfield;
705 search_field_->SetController(this); 707 search_field_->SetController(this);
706 clear_search_button_ = new views::NativeButton( 708 clear_search_button_ = new views::NativeButton(
707 this, l10n_util::GetString(IDS_COOKIES_CLEAR_SEARCH_LABEL)); 709 this, l10n_util::GetString(IDS_COOKIES_CLEAR_SEARCH_LABEL));
710 clear_search_button_->SetEnabled(false);
708 description_label_ = new views::Label( 711 description_label_ = new views::Label(
709 l10n_util::GetString(IDS_COOKIES_INFO_LABEL)); 712 l10n_util::GetString(IDS_COOKIES_INFO_LABEL));
710 description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 713 description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
711 714
712 cookies_table_model_.reset(new CookiesTableModel(profile_)); 715 cookies_table_model_.reset(new CookiesTableModel(profile_));
713 info_view_ = new CookieInfoView; 716 info_view_ = new CookieInfoView;
714 std::vector<TableColumn> columns; 717 std::vector<TableColumn> columns;
715 columns.push_back(TableColumn(IDS_COOKIES_DOMAIN_COLUMN_HEADER, 718 columns.push_back(TableColumn(IDS_COOKIES_DOMAIN_COLUMN_HEADER,
716 TableColumn::LEFT, 200, 0.5f)); 719 TableColumn::LEFT, 200, 0.5f));
717 columns.back().sortable = true; 720 columns.back().sortable = true;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 777
775 if (cookies_table_->RowCount() > 0) { 778 if (cookies_table_->RowCount() > 0) {
776 cookies_table_->Select(0); 779 cookies_table_->Select(0);
777 } else { 780 } else {
778 UpdateForEmptyState(); 781 UpdateForEmptyState();
779 } 782 }
780 } 783 }
781 784
782 void CookiesView::ResetSearchQuery() { 785 void CookiesView::ResetSearchQuery() {
783 search_field_->SetText(EmptyWString()); 786 search_field_->SetText(EmptyWString());
787 clear_search_button_->SetEnabled(false);
784 UpdateSearchResults(); 788 UpdateSearchResults();
785 } 789 }
786 790
787 void CookiesView::UpdateForEmptyState() { 791 void CookiesView::UpdateForEmptyState() {
788 info_view_->ClearCookieDisplay(); 792 info_view_->ClearCookieDisplay();
789 remove_button_->SetEnabled(false); 793 remove_button_->SetEnabled(false);
790 remove_all_button_->SetEnabled(false); 794 remove_all_button_->SetEnabled(false);
791 } 795 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698