| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/webui/options/cookies_view_handler.h" | 5 #include "chrome/browser/ui/webui/options/cookies_view_handler.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/browsing_data_appcache_helper.h" | 9 #include "chrome/browser/browsing_data_appcache_helper.h" |
| 10 #include "chrome/browser/browsing_data_database_helper.h" | 10 #include "chrome/browser/browsing_data_database_helper.h" |
| 11 #include "chrome/browser/browsing_data_file_system_helper.h" |
| 11 #include "chrome/browser/browsing_data_indexed_db_helper.h" | 12 #include "chrome/browser/browsing_data_indexed_db_helper.h" |
| 12 #include "chrome/browser/browsing_data_local_storage_helper.h" | 13 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" | 15 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" |
| 15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 | 18 |
| 18 CookiesViewHandler::CookiesViewHandler() : batch_update_(false) { | 19 CookiesViewHandler::CookiesViewHandler() : batch_update_(false) { |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 if (!cookies_tree_model_.get()) { | 136 if (!cookies_tree_model_.get()) { |
| 136 Profile* profile = web_ui_->GetProfile(); | 137 Profile* profile = web_ui_->GetProfile(); |
| 137 cookies_tree_model_.reset(new CookiesTreeModel( | 138 cookies_tree_model_.reset(new CookiesTreeModel( |
| 138 profile->GetRequestContext()->DONTUSEME_GetCookieStore()-> | 139 profile->GetRequestContext()->DONTUSEME_GetCookieStore()-> |
| 139 GetCookieMonster(), | 140 GetCookieMonster(), |
| 140 new BrowsingDataDatabaseHelper(profile), | 141 new BrowsingDataDatabaseHelper(profile), |
| 141 new BrowsingDataLocalStorageHelper(profile), | 142 new BrowsingDataLocalStorageHelper(profile), |
| 142 NULL, | 143 NULL, |
| 143 new BrowsingDataAppCacheHelper(profile), | 144 new BrowsingDataAppCacheHelper(profile), |
| 144 BrowsingDataIndexedDBHelper::Create(profile), | 145 BrowsingDataIndexedDBHelper::Create(profile), |
| 146 BrowsingDataFileSystemHelper::Create(profile), |
| 145 false)); | 147 false)); |
| 146 cookies_tree_model_->AddCookiesTreeObserver(this); | 148 cookies_tree_model_->AddCookiesTreeObserver(this); |
| 147 } | 149 } |
| 148 } | 150 } |
| 149 | 151 |
| 150 void CookiesViewHandler::UpdateSearchResults(const ListValue* args) { | 152 void CookiesViewHandler::UpdateSearchResults(const ListValue* args) { |
| 151 std::string query; | 153 std::string query; |
| 152 if (!args->GetString(0, &query)){ | 154 if (!args->GetString(0, &query)) { |
| 153 return; | 155 return; |
| 154 } | 156 } |
| 155 | 157 |
| 156 EnsureCookiesTreeModelCreated(); | 158 EnsureCookiesTreeModelCreated(); |
| 157 | 159 |
| 158 cookies_tree_model_->UpdateSearchResults(UTF8ToWide(query)); | 160 cookies_tree_model_->UpdateSearchResults(UTF8ToWide(query)); |
| 159 } | 161 } |
| 160 | 162 |
| 161 void CookiesViewHandler::RemoveAll(const ListValue* args) { | 163 void CookiesViewHandler::RemoveAll(const ListValue* args) { |
| 162 EnsureCookiesTreeModelCreated(); | 164 EnsureCookiesTreeModelCreated(); |
| 163 cookies_tree_model_->DeleteAllStoredObjects(); | 165 cookies_tree_model_->DeleteAllStoredObjects(); |
| 164 } | 166 } |
| 165 | 167 |
| 166 void CookiesViewHandler::Remove(const ListValue* args) { | 168 void CookiesViewHandler::Remove(const ListValue* args) { |
| 167 std::string node_path; | 169 std::string node_path; |
| 168 if (!args->GetString(0, &node_path)){ | 170 if (!args->GetString(0, &node_path)) { |
| 169 return; | 171 return; |
| 170 } | 172 } |
| 171 | 173 |
| 172 EnsureCookiesTreeModelCreated(); | 174 EnsureCookiesTreeModelCreated(); |
| 173 | 175 |
| 174 CookieTreeNode* node = cookies_tree_model_util::GetTreeNodeFromPath( | 176 CookieTreeNode* node = cookies_tree_model_util::GetTreeNodeFromPath( |
| 175 cookies_tree_model_->GetRoot(), node_path); | 177 cookies_tree_model_->GetRoot(), node_path); |
| 176 if (node) | 178 if (node) |
| 177 cookies_tree_model_->DeleteCookieNode(node); | 179 cookies_tree_model_->DeleteCookieNode(node); |
| 178 } | 180 } |
| 179 | 181 |
| 180 void CookiesViewHandler::LoadChildren(const ListValue* args) { | 182 void CookiesViewHandler::LoadChildren(const ListValue* args) { |
| 181 std::string node_path; | 183 std::string node_path; |
| 182 if (!args->GetString(0, &node_path)){ | 184 if (!args->GetString(0, &node_path)) { |
| 183 return; | 185 return; |
| 184 } | 186 } |
| 185 | 187 |
| 186 EnsureCookiesTreeModelCreated(); | 188 EnsureCookiesTreeModelCreated(); |
| 187 | 189 |
| 188 CookieTreeNode* node = cookies_tree_model_util::GetTreeNodeFromPath( | 190 CookieTreeNode* node = cookies_tree_model_util::GetTreeNodeFromPath( |
| 189 cookies_tree_model_->GetRoot(), node_path); | 191 cookies_tree_model_->GetRoot(), node_path); |
| 190 if (node) | 192 if (node) |
| 191 SendChildren(node); | 193 SendChildren(node); |
| 192 } | 194 } |
| 193 | 195 |
| 194 void CookiesViewHandler::SendChildren(CookieTreeNode* parent) { | 196 void CookiesViewHandler::SendChildren(CookieTreeNode* parent) { |
| 195 ListValue* children = new ListValue; | 197 ListValue* children = new ListValue; |
| 196 cookies_tree_model_util::GetChildNodeList(parent, 0, parent->child_count(), | 198 cookies_tree_model_util::GetChildNodeList(parent, 0, parent->child_count(), |
| 197 children); | 199 children); |
| 198 | 200 |
| 199 ListValue args; | 201 ListValue args; |
| 200 args.Append(parent == cookies_tree_model_->GetRoot() ? | 202 args.Append(parent == cookies_tree_model_->GetRoot() ? |
| 201 Value::CreateNullValue() : | 203 Value::CreateNullValue() : |
| 202 Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId(parent))); | 204 Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId(parent))); |
| 203 args.Append(children); | 205 args.Append(children); |
| 204 | 206 |
| 205 web_ui_->CallJavascriptFunction("CookiesView.loadChildren", args); | 207 web_ui_->CallJavascriptFunction("CookiesView.loadChildren", args); |
| 206 } | 208 } |
| OLD | NEW |