diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-02 12:49:59 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-02 12:49:59 +0000 |
commit | be896a761f3f022200a8e53003da99e132d9d848 (patch) | |
tree | a3a1ea65484f582e34a92e16005a0f4a094524ff /chrome/browser/views/options/cookies_view.cc | |
parent | 64dc6bf1b0d06163e07c63354d3aae18bd5605a2 (diff) | |
download | chromium_src-be896a761f3f022200a8e53003da99e132d9d848.zip chromium_src-be896a761f3f022200a8e53003da99e132d9d848.tar.gz chromium_src-be896a761f3f022200a8e53003da99e132d9d848.tar.bz2 |
- Add a note about a subtle requirement of the current code (bug 2994).
- Don't statically construct the cookie icon, removing a static constructor.
- Properly enable and disable the cookie text fields. Patch from Arthur Lussos.
Review URL: http://codereview.chromium.org/6077
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/options/cookies_view.cc')
-rw-r--r-- | chrome/browser/views/options/cookies_view.cc | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc index 3c272b9..3ef2c47 100644 --- a/chrome/browser/views/options/cookies_view.cc +++ b/chrome/browser/views/options/cookies_view.cc @@ -73,22 +73,14 @@ class CookiesTableModel : public ChromeViews::TableModel { ChromeViews::TableModelObserver* observer_; - // Static resources for this object. - static SkBitmap cookie_icon_; - static void InitClass(); - DISALLOW_EVIL_CONSTRUCTORS(CookiesTableModel); }; -// static -SkBitmap CookiesTableModel::cookie_icon_; - /////////////////////////////////////////////////////////////////////////////// // CookiesTableModel, public: CookiesTableModel::CookiesTableModel(Profile* profile) : profile_(profile) { - InitClass(); LoadCookies(); } @@ -171,7 +163,9 @@ std::wstring CookiesTableModel::GetText(int row, int column_id) { } SkBitmap CookiesTableModel::GetIcon(int row) { - return cookie_icon_; + static SkBitmap* icon = ResourceBundle::GetSharedInstance().GetBitmapNamed( + IDR_COOKIE_ICON); + return *icon; } void CookiesTableModel::SetObserver(ChromeViews::TableModelObserver* observer) { @@ -242,17 +236,6 @@ void CookiesTableModel::UpdateSearchResults(const std::wstring& filter) { observer_->OnModelChanged(); } -// static -void CookiesTableModel::InitClass() { - static bool initialized = false; - if (!initialized) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - cookie_icon_ = *rb.GetBitmapNamed(IDR_COOKIE_ICON); - initialized = true; - } -} - - /////////////////////////////////////////////////////////////////////////////// // CookiesTableView // Overridden to handle Delete key presses @@ -295,7 +278,8 @@ void CookiesTableView::RemoveSelectedCookies() { return; } - // Remove the selected cookies. + // Remove the selected cookies. This iterates over the rows backwards, which + // is required when calling RemoveCookies, see bug 2994. int first_selected_row = -1; for (ChromeViews::TableView::iterator i = SelectionBegin(); i != SelectionEnd(); ++i) { @@ -331,6 +315,9 @@ class CookieInfoView : public ChromeViews::View { // selected. void ClearCookieDisplay(); + // Enables or disables the cookie proerty text fields. + void EnableCookieDisplay(bool enabled); + protected: // ChromeViews::View overrides: virtual void ViewHierarchyChanged(bool is_add, @@ -410,25 +397,30 @@ void CookieInfoView::SetCookie( sendfor_text = l10n_util::GetString(IDS_COOKIES_COOKIE_SENDFOR_ANY); } send_for_value_field_->SetText(sendfor_text); + EnableCookieDisplay(true); +} + +void CookieInfoView::EnableCookieDisplay(bool enabled) { + name_value_field_->SetEnabled(enabled); + content_value_field_->SetEnabled(enabled); + domain_value_field_->SetEnabled(enabled); + path_value_field_->SetEnabled(enabled); + send_for_value_field_->SetEnabled(enabled); + created_value_field_->SetEnabled(enabled); + expires_value_field_->SetEnabled(enabled); } void CookieInfoView::ClearCookieDisplay() { std::wstring no_cookie_string = l10n_util::GetString(IDS_COOKIES_COOKIE_NONESELECTED); name_value_field_->SetText(no_cookie_string); - name_value_field_->SetEnabled(false); content_value_field_->SetText(no_cookie_string); - content_value_field_->SetEnabled(false); domain_value_field_->SetText(no_cookie_string); - domain_value_field_->SetEnabled(false); path_value_field_->SetText(no_cookie_string); - path_value_field_->SetEnabled(false); send_for_value_field_->SetText(no_cookie_string); - send_for_value_field_->SetEnabled(false); created_value_field_->SetText(no_cookie_string); - created_value_field_->SetEnabled(false); expires_value_field_->SetText(no_cookie_string); - expires_value_field_->SetEnabled(false); + EnableCookieDisplay(false); } /////////////////////////////////////////////////////////////////////////////// |