diff options
-rw-r--r-- | chrome/browser/cocoa/cookies_window_controller.mm | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookies_window_controller_unittest.mm | 7 | ||||
-rw-r--r-- | chrome/browser/cookies_tree_model.cc | 18 | ||||
-rw-r--r-- | chrome/browser/cookies_tree_model.h | 6 | ||||
-rw-r--r-- | chrome/browser/cookies_tree_model_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/browser/gtk/options/cookies_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/options/cookies_view.cc | 3 |
7 files changed, 23 insertions, 30 deletions
diff --git a/chrome/browser/cocoa/cookies_window_controller.mm b/chrome/browser/cocoa/cookies_window_controller.mm index 639ebaf..9c602d5 100644 --- a/chrome/browser/cocoa/cookies_window_controller.mm +++ b/chrome/browser/cocoa/cookies_window_controller.mm @@ -425,8 +425,9 @@ bool CookiesTreeModelObserverBridge::HasCocoaModel() { // to rebuild after the user clears browsing data. Because the models get // clobbered, we rebuild the icon cache for safety (though they do not change). - (void)loadTreeModelFromProfile { - treeModel_.reset(new CookiesTreeModel(profile_, databaseHelper_, - storageHelper_, appcacheHelper_)); + treeModel_.reset(new CookiesTreeModel( + profile_->GetRequestContext()->GetCookieStore()->GetCookieMonster(), + databaseHelper_, storageHelper_, appcacheHelper_)); modelObserver_.reset(new CookiesTreeModelObserverBridge(self)); treeModel_->AddObserver(modelObserver_.get()); diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm index 657a8c6..ea07ff1 100644 --- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm +++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm @@ -17,6 +17,7 @@ #include "chrome/browser/mock_browsing_data_local_storage_helper.h" #include "chrome/browser/mock_browsing_data_appcache_helper.h" #include "chrome/browser/cookies_tree_model.h" +#include "chrome/browser/profile.h" #include "chrome/common/net/url_request_context_getter.h" #include "chrome/test/testing_profile.h" #include "googleurl/src/gurl.h" @@ -140,8 +141,7 @@ TEST_F(CookiesWindowControllerTest, FindCocoaNodeRecursive) { TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeCookie) { net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster(); cm->SetCookie(GURL("http://foo.com"), "A=B"); - CookiesTreeModel model(browser_helper_.profile(), database_helper_, - local_storage_helper_, nil); + CookiesTreeModel model(cm, database_helper_, local_storage_helper_, nil); // Root --> foo.com --> Cookies --> A. Create node for 'A'. TreeModelNode* node = model.GetRoot()->GetChild(0)->GetChild(0)->GetChild(0); @@ -165,8 +165,7 @@ TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeCookie) { TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeRecursive) { net::CookieMonster* cm = browser_helper_.profile()->GetCookieMonster(); cm->SetCookie(GURL("http://foo.com"), "A=B"); - CookiesTreeModel model(browser_helper_.profile(), database_helper_, - local_storage_helper_, nil); + CookiesTreeModel model(cm, database_helper_, local_storage_helper_, nil); // Root --> foo.com --> Cookies --> A. Create node for 'foo.com'. CookieTreeNode* node = model.GetRoot()->GetChild(0); diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index 89d94e2..239a36d 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -18,8 +18,6 @@ #include "base/string_util.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/in_process_webkit/webkit_context.h" -#include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/browser/profile.h" #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -57,16 +55,14 @@ CookieTreeCookieNode::CookieTreeCookieNode( void CookieTreeCookieNode::DeleteStoredObjects() { // notify CookieMonster that we should delete this cookie - // Since we are running on the UI thread don't call GetURLRequestContext(). - net::CookieMonster* monster = GetModel()->profile_-> - GetRequestContext()->GetCookieStore()->GetCookieMonster(); // We have stored a copy of all the cookies in the model, and our model is // never re-calculated. Thus, we just need to delete the nodes from our // model, and tell CookieMonster to delete the cookies. We can keep the // vector storing the cookies in-tact and not delete from there (that would // invalidate our pointers), and the fact that it contains semi out-of-date // data is not problematic as we don't re-build the model based on that. - monster->DeleteCookie(cookie_->first, cookie_->second, true); + GetModel()->cookie_monster_-> + DeleteCookie(cookie_->first, cookie_->second, true); } namespace { @@ -294,13 +290,13 @@ void CookieTreeNode::AddChildSortedByTitle(CookieTreeNode* new_child) { // CookiesTreeModel, public: CookiesTreeModel::CookiesTreeModel( - Profile* profile, + net::CookieMonster* cookie_monster, BrowsingDataDatabaseHelper* database_helper, BrowsingDataLocalStorageHelper* local_storage_helper, BrowsingDataAppCacheHelper* appcache_helper) : ALLOW_THIS_IN_INITIALIZER_LIST(TreeNodeModel<CookieTreeNode>( new CookieTreeRootNode(this))), - profile_(profile), + cookie_monster_(cookie_monster), appcache_helper_(appcache_helper), database_helper_(database_helper), local_storage_helper_(local_storage_helper), @@ -376,11 +372,7 @@ void CookiesTreeModel::LoadCookies() { void CookiesTreeModel::LoadCookiesWithFilter(const std::wstring& filter) { // 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(); + all_cookies_ = cookie_monster_->GetAllCookies(); CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); for (CookieList::iterator it = all_cookies_.begin(); it != all_cookies_.end(); ++it) { diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h index 7b68640..1a07785 100644 --- a/chrome/browser/cookies_tree_model.h +++ b/chrome/browser/cookies_tree_model.h @@ -26,7 +26,6 @@ class CookieTreeDatabasesNode; class CookieTreeLocalStorageNode; class CookieTreeLocalStoragesNode; class CookieTreeOriginNode; -class Profile; // CookieTreeNode ------------------------------------------------------------- // The base node type in the Cookies, Databases, and Local Storage options @@ -357,7 +356,7 @@ class CookiesTreeModel : public TreeNodeModel<CookieTreeNode> { }; CookiesTreeModel( - Profile* profile, + net::CookieMonster* cookie_monster_, BrowsingDataDatabaseHelper* database_helper, BrowsingDataLocalStorageHelper* local_storage_helper, BrowsingDataAppCacheHelper* appcache_helper); @@ -417,8 +416,7 @@ class CookiesTreeModel : public TreeNodeModel<CookieTreeNode> { void NotifyObserverBeginBatch(); void NotifyObserverEndBatch(); - // The profile from which this model sources cookies. - Profile* profile_; + scoped_refptr<net::CookieMonster> cookie_monster_; CookieList all_cookies_; scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; diff --git a/chrome/browser/cookies_tree_model_unittest.cc b/chrome/browser/cookies_tree_model_unittest.cc index 9417c21..02a04c2 100644 --- a/chrome/browser/cookies_tree_model_unittest.cc +++ b/chrome/browser/cookies_tree_model_unittest.cc @@ -43,7 +43,7 @@ class CookiesTreeModelTest : public testing::Test { monster->SetCookie(GURL("http://foo2"), "B=1"); monster->SetCookie(GURL("http://foo3"), "C=1"); CookiesTreeModel* cookies_model = new CookiesTreeModel( - profile_.get(), mock_browsing_data_database_helper_, + monster, mock_browsing_data_database_helper_, mock_browsing_data_local_storage_helper_, mock_browsing_data_appcache_helper_); mock_browsing_data_database_helper_->AddDatabaseSamples(); @@ -339,7 +339,7 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { monster->SetCookie(GURL("http://foo2"), "B=1"); monster->SetCookie(GURL("http://foo3"), "C=1"); monster->SetCookie(GURL("http://foo3"), "D=1"); - CookiesTreeModel cookies_model(profile_.get(), + CookiesTreeModel cookies_model(monster, mock_browsing_data_database_helper_, mock_browsing_data_local_storage_helper_, mock_browsing_data_appcache_helper_); @@ -378,7 +378,7 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { monster->SetCookie(GURL("http://foo3"), "C=1"); monster->SetCookie(GURL("http://foo3"), "D=1"); monster->SetCookie(GURL("http://foo3"), "E=1"); - CookiesTreeModel cookies_model(profile_.get(), + CookiesTreeModel cookies_model(monster, mock_browsing_data_database_helper_, mock_browsing_data_local_storage_helper_, mock_browsing_data_appcache_helper_); @@ -418,7 +418,7 @@ TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { monster->SetCookie(GURL("http://foo3"), "C=1"); monster->SetCookie(GURL("http://foo3"), "D=1"); monster->SetCookie(GURL("http://foo3"), "E=1"); - CookiesTreeModel cookies_model(profile_.get(), + CookiesTreeModel cookies_model(monster, mock_browsing_data_database_helper_, mock_browsing_data_local_storage_helper_, mock_browsing_data_appcache_helper_); @@ -452,7 +452,7 @@ TEST_F(CookiesTreeModelTest, OriginOrdering) { monster->SetCookie(GURL("http://foo3.com"), "G=1"); monster->SetCookie(GURL("http://foo4.com"), "H=1"); - CookiesTreeModel cookies_model(profile_.get(), + CookiesTreeModel cookies_model(monster, new MockBrowsingDataDatabaseHelper(profile_.get()), new MockBrowsingDataLocalStorageHelper(profile_.get()), new MockBrowsingDataAppCacheHelper(profile_.get())); diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc index 155e775..bdefa04 100644 --- a/chrome/browser/gtk/options/cookies_view.cc +++ b/chrome/browser/gtk/options/cookies_view.cc @@ -13,6 +13,7 @@ #include "base/string_util.h" #include "chrome/browser/cookies_tree_model.h" #include "chrome/browser/gtk/gtk_util.h" +#include "chrome/browser/profile.h" #include "gfx/gtk_util.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -181,7 +182,8 @@ void CookiesView::Init(GtkWindow* parent) { 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_->GetRequestContext()->GetCookieStore()->GetCookieMonster(), browsing_data_database_helper_, browsing_data_local_storage_helper_, browsing_data_appcache_helper_)); diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc index 0b1f7f9..9bdbb67 100644 --- a/chrome/browser/views/options/cookies_view.cc +++ b/chrome/browser/views/options/cookies_view.cc @@ -281,7 +281,8 @@ void CookiesView::Init() { description_label_ = new views::Label( l10n_util::GetString(IDS_COOKIES_INFO_LABEL)); description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - cookies_tree_model_.reset(new CookiesTreeModel(profile_, + cookies_tree_model_.reset(new CookiesTreeModel( + profile_->GetRequestContext()->GetCookieStore()->GetCookieMonster(), new BrowsingDataDatabaseHelper(profile_), new BrowsingDataLocalStorageHelper(profile_), new BrowsingDataAppCacheHelper(profile_))); |