summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 02:10:05 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-12 02:10:05 +0000
commitd32e75740a892b8578c825b9b5fb850ee5f41269 (patch)
tree3c5dcffec3c622877a4f60cbf662bd5bec614c61
parent869ebd911a37868c492ae798d0dfad2125990bb3 (diff)
downloadchromium_src-d32e75740a892b8578c825b9b5fb850ee5f41269.zip
chromium_src-d32e75740a892b8578c825b9b5fb850ee5f41269.tar.gz
chromium_src-d32e75740a892b8578c825b9b5fb850ee5f41269.tar.bz2
Remove cookies_table_model which has been succeeded by cookies_tree_model.
BUG=26713 TEST=still compiles Review URL: http://codereview.chromium.org/387031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31756 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cookies_table_model.cc190
-rw-r--r--chrome/browser/cookies_table_model.h58
-rw-r--r--chrome/browser/gtk/options/cookies_view_unittest.cc1
-rwxr-xr-xchrome/chrome.gyp2
4 files changed, 0 insertions, 251 deletions
diff --git a/chrome/browser/cookies_table_model.cc b/chrome/browser/cookies_table_model.cc
deleted file mode 100644
index 3cc140f..0000000
--- a/chrome/browser/cookies_table_model.cc
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/cookies_table_model.h"
-
-#include "app/l10n_util.h"
-#include "app/table_model_observer.h"
-#include "app/resource_bundle.h"
-#include "base/string_util.h"
-#include "chrome/browser/net/chrome_url_request_context.h"
-#include "chrome/browser/profile.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "net/url_request/url_request_context.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesTableModel, public:
-
-CookiesTableModel::CookiesTableModel(Profile* profile)
- : profile_(profile) {
- LoadCookies();
-}
-
-std::string CookiesTableModel::GetDomainAt(int index) {
- DCHECK(index >= 0 && index < RowCount());
- return shown_cookies_.at(index)->first;
-}
-
-net::CookieMonster::CanonicalCookie& CookiesTableModel::GetCookieAt(
- int index) {
- DCHECK(index >= 0 && index < RowCount());
- return shown_cookies_.at(index)->second;
-}
-
-void CookiesTableModel::RemoveCookies(int start_index, int remove_count) {
- if (remove_count <= 0) {
- NOTREACHED();
- return;
- }
- // Since we are running on the UI thread don't call GetURLRequestContext().
- net::CookieMonster* monster =
- profile_->GetRequestContext()->GetCookieStore()->GetCookieMonster();
-
- // We need to update the searched results list, the full cookie list,
- // and the view. We walk through the search results list (which is what
- // is displayed) and map these back to the full cookie list. They should
- // be in the same sort order, and always exist, so we can just walk once.
- // We can't delete any entries from all_cookies_ without invaliding all of
- // our pointers after it (which are in shown_cookies), so we go backwards.
- CookiePtrList::iterator first = shown_cookies_.begin() + start_index;
- CookiePtrList::iterator last = first + remove_count;
- CookieList::iterator all_it = all_cookies_.end();
- while (last != first) {
- --last;
- --all_it;
- // Seek to the corresponding entry in all_cookies_
- while (&*all_it != *last) --all_it;
- // Delete the cookie from the monster
- monster->DeleteCookie(all_it->first, all_it->second, true);
- all_it = all_cookies_.erase(all_it);
- }
-
- // By deleting entries from all_cookies, we just possibly moved stuff around
- // and have thus invalidated all of our pointers, so rebuild shown_cookies.
- // We could do this all better if there was a way to mark elements of
- // all_cookies as dead instead of deleting, but this should be fine for now.
- DoFilter();
- if (observer_)
- observer_->OnItemsRemoved(start_index, remove_count);
-}
-
-void CookiesTableModel::RemoveAllShownCookies() {
- RemoveCookies(0, RowCount());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesTableModel, TableModel implementation:
-
-int CookiesTableModel::RowCount() {
- return static_cast<int>(shown_cookies_.size());
-}
-
-std::wstring CookiesTableModel::GetText(int row, int column_id) {
- DCHECK(row >= 0 && row < RowCount());
- switch (column_id) {
- case IDS_COOKIES_DOMAIN_COLUMN_HEADER:
- {
- // Domain cookies start with a trailing dot, but we will show this
- // in the cookie details, show it without the dot in the list.
- std::string& domain = shown_cookies_.at(row)->first;
- std::wstring wide_domain;
- if (!domain.empty() && domain[0] == '.')
- wide_domain = UTF8ToWide(domain.substr(1));
- else
- wide_domain = UTF8ToWide(domain);
- // Force domain to be LTR
- if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
- l10n_util::WrapStringWithLTRFormatting(&wide_domain);
- return wide_domain;
- }
- break;
- case IDS_COOKIES_NAME_COLUMN_HEADER: {
- std::wstring name = UTF8ToWide(shown_cookies_.at(row)->second.Name());
- l10n_util::AdjustStringForLocaleDirection(name, &name);
- return name;
- break;
- }
- }
- NOTREACHED();
- return L"";
-}
-
-SkBitmap CookiesTableModel::GetIcon(int row) {
- static SkBitmap* icon = ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_COOKIE_ICON);
- return *icon;
-}
-
-void CookiesTableModel::SetObserver(TableModelObserver* observer) {
- observer_ = observer;
-}
-
-int CookiesTableModel::CompareValues(int row1, int row2, int column_id) {
- if (column_id == IDS_COOKIES_DOMAIN_COLUMN_HEADER) {
- // Sort ignore the '.' prefix for domain cookies.
- net::CookieMonster::CookieListPair* cp1 = shown_cookies_[row1];
- net::CookieMonster::CookieListPair* cp2 = shown_cookies_[row2];
- bool is1domain = !cp1->first.empty() && cp1->first[0] == '.';
- bool is2domain = !cp2->first.empty() && cp2->first[0] == '.';
-
- // They are both either domain or host cookies, sort them normally.
- if (is1domain == is2domain)
- return cp1->first.compare(cp2->first);
-
- // One (but only one) is a domain cookie, skip the beginning '.'.
- return is1domain ?
- cp1->first.compare(1, cp1->first.length() - 1, cp2->first) :
- -cp2->first.compare(1, cp2->first.length() - 1, cp1->first);
- }
- return TableModel::CompareValues(row1, row2, column_id);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookiesTableModel, private:
-
-// Returns true if |cookie| matches the specified filter, where "match" is
-// defined as the cookie's domain, name and value contains filter text
-// somewhere.
-static bool ContainsFilterText(
- const std::string& domain,
- const net::CookieMonster::CanonicalCookie& cookie,
- const std::string& filter) {
- return domain.find(filter) != std::string::npos ||
- cookie.Name().find(filter) != std::string::npos ||
- cookie.Value().find(filter) != std::string::npos;
-}
-
-void CookiesTableModel::LoadCookies() {
- // mmargh mmargh mmargh!
-
- // Since we are running on the UI thread don't call GetURLRequestContext().
- net::CookieMonster* cookie_monster =
- profile_->GetRequestContext()->GetCookieStore()->GetCookieMonster();
-
- all_cookies_ = cookie_monster->GetAllCookies();
- DoFilter();
-}
-
-void CookiesTableModel::DoFilter() {
- std::string utf8_filter = WideToUTF8(filter_);
- bool has_filter = !utf8_filter.empty();
-
- shown_cookies_.clear();
-
- CookieList::iterator iter = all_cookies_.begin();
- for (; iter != all_cookies_.end(); ++iter) {
- if (!has_filter ||
- ContainsFilterText(iter->first, iter->second, utf8_filter)) {
- shown_cookies_.push_back(&*iter);
- }
- }
-}
-
-void CookiesTableModel::UpdateSearchResults(const std::wstring& filter) {
- filter_ = filter;
- DoFilter();
- observer_->OnModelChanged();
-}
diff --git a/chrome/browser/cookies_table_model.h b/chrome/browser/cookies_table_model.h
deleted file mode 100644
index 2b69849..0000000
--- a/chrome/browser/cookies_table_model.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_COOKIES_TABLE_MODEL_H_
-#define CHROME_BROWSER_COOKIES_TABLE_MODEL_H_
-
-#include <string>
-#include <vector>
-
-#include "app/table_model.h"
-#include "net/base/cookie_monster.h"
-
-class Profile;
-
-class CookiesTableModel : public TableModel {
- public:
- explicit CookiesTableModel(Profile* profile);
- virtual ~CookiesTableModel() {}
-
- // Returns information about the Cookie at the specified index.
- std::string GetDomainAt(int index);
- net::CookieMonster::CanonicalCookie& GetCookieAt(int index);
-
- // Remove the specified cookies from the Cookie Monster and update the view.
- void RemoveCookies(int start_index, int remove_count);
- void RemoveAllShownCookies();
-
- // TableModel methods.
- virtual int RowCount();
- virtual std::wstring GetText(int row, int column_id);
- virtual SkBitmap GetIcon(int row);
- virtual int CompareValues(int row1, int row2, int column_id);
- virtual void SetObserver(TableModelObserver* observer);
-
- // Filter the cookies to only display matched results.
- void UpdateSearchResults(const std::wstring& filter);
-
- private:
- void LoadCookies();
- void DoFilter();
-
- std::wstring filter_;
-
- // The profile from which this model sources cookies.
- Profile* profile_;
-
- typedef net::CookieMonster::CookieList CookieList;
- typedef std::vector<net::CookieMonster::CookieListPair*> CookiePtrList;
- CookieList all_cookies_;
- CookiePtrList shown_cookies_;
-
- TableModelObserver* observer_;
-
- DISALLOW_COPY_AND_ASSIGN(CookiesTableModel);
-};
-
-#endif // CHROME_BROWSER_COOKIES_TABLE_MODEL_H_
diff --git a/chrome/browser/gtk/options/cookies_view_unittest.cc b/chrome/browser/gtk/options/cookies_view_unittest.cc
index 63e7d42..10f757e 100644
--- a/chrome/browser/gtk/options/cookies_view_unittest.cc
+++ b/chrome/browser/gtk/options/cookies_view_unittest.cc
@@ -10,7 +10,6 @@
#include <gtk/gtk.h>
#include "base/string_util.h"
-#include "chrome/browser/cookies_table_model.h"
#include "chrome/browser/net/url_request_context_getter.h"
#include "chrome/test/testing_profile.h"
#include "net/url_request/url_request_context.h"
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 17e780a..938aec3 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1268,8 +1268,6 @@
'browser/cocoa/web_drop_target.mm',
'browser/command_updater.cc',
'browser/command_updater.h',
- 'browser/cookies_table_model.cc',
- 'browser/cookies_table_model.h',
'browser/cookies_tree_model.cc',
'browser/cookies_tree_model.h',
'browser/cross_site_request_manager.cc',