| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 21 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | 22 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
| 22 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 23 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 153 |
| 153 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); | 154 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); |
| 154 CookieTreeNode* parent_node = tree_model->AsNode(parent); | 155 CookieTreeNode* parent_node = tree_model->AsNode(parent); |
| 155 | 156 |
| 156 std::unique_ptr<base::ListValue> children(new base::ListValue); | 157 std::unique_ptr<base::ListValue> children(new base::ListValue); |
| 157 model_util_->GetChildNodeList( | 158 model_util_->GetChildNodeList( |
| 158 parent_node, start, count, /*include_quota_nodes=*/true, children.get()); | 159 parent_node, start, count, /*include_quota_nodes=*/true, children.get()); |
| 159 | 160 |
| 160 base::ListValue args; | 161 base::ListValue args; |
| 161 if (parent == tree_model->GetRoot()) | 162 if (parent == tree_model->GetRoot()) |
| 162 args.Append(base::Value::CreateNullValue()); | 163 args.Append(base::MakeUnique<base::Value>()); |
| 163 else | 164 else |
| 164 args.AppendString(model_util_->GetTreeNodeId(parent_node)); | 165 args.AppendString(model_util_->GetTreeNodeId(parent_node)); |
| 165 args.AppendInteger(start); | 166 args.AppendInteger(start); |
| 166 args.Append(std::move(children)); | 167 args.Append(std::move(children)); |
| 167 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.onTreeItemAdded", args); | 168 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.onTreeItemAdded", args); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, | 171 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, |
| 171 ui::TreeModelNode* parent, | 172 ui::TreeModelNode* parent, |
| 172 int start, | 173 int start, |
| 173 int count) { | 174 int count) { |
| 174 // Skip if there is a batch update in progress. | 175 // Skip if there is a batch update in progress. |
| 175 if (batch_update_) | 176 if (batch_update_) |
| 176 return; | 177 return; |
| 177 | 178 |
| 178 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); | 179 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); |
| 179 | 180 |
| 180 base::ListValue args; | 181 base::ListValue args; |
| 181 if (parent == tree_model->GetRoot()) | 182 if (parent == tree_model->GetRoot()) |
| 182 args.Append(base::Value::CreateNullValue()); | 183 args.Append(base::MakeUnique<base::Value>()); |
| 183 else | 184 else |
| 184 args.AppendString(model_util_->GetTreeNodeId(tree_model->AsNode(parent))); | 185 args.AppendString(model_util_->GetTreeNodeId(tree_model->AsNode(parent))); |
| 185 args.AppendInteger(start); | 186 args.AppendInteger(start); |
| 186 args.AppendInteger(count); | 187 args.AppendInteger(count); |
| 187 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.onTreeItemRemoved", args); | 188 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.onTreeItemRemoved", args); |
| 188 } | 189 } |
| 189 | 190 |
| 190 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { | 191 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { |
| 191 DCHECK(!batch_update_); // There should be no nested batch begin. | 192 DCHECK(!batch_update_); // There should be no nested batch begin. |
| 192 batch_update_ = true; | 193 batch_update_ = true; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 SendChildren(node); | 273 SendChildren(node); |
| 273 } | 274 } |
| 274 | 275 |
| 275 void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) { | 276 void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) { |
| 276 std::unique_ptr<base::ListValue> children(new base::ListValue); | 277 std::unique_ptr<base::ListValue> children(new base::ListValue); |
| 277 model_util_->GetChildNodeList(parent, /*start=*/0, parent->child_count(), | 278 model_util_->GetChildNodeList(parent, /*start=*/0, parent->child_count(), |
| 278 /*include_quota_nodes=*/true, children.get()); | 279 /*include_quota_nodes=*/true, children.get()); |
| 279 | 280 |
| 280 base::ListValue args; | 281 base::ListValue args; |
| 281 if (parent == cookies_tree_model_->GetRoot()) | 282 if (parent == cookies_tree_model_->GetRoot()) |
| 282 args.Append(base::Value::CreateNullValue()); | 283 args.Append(base::MakeUnique<base::Value>()); |
| 283 else | 284 else |
| 284 args.AppendString(model_util_->GetTreeNodeId(parent)); | 285 args.AppendString(model_util_->GetTreeNodeId(parent)); |
| 285 args.Append(std::move(children)); | 286 args.Append(std::move(children)); |
| 286 | 287 |
| 287 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.loadChildren", args); | 288 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.loadChildren", args); |
| 288 } | 289 } |
| 289 | 290 |
| 290 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) { | 291 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) { |
| 291 cookies_tree_model_.reset(); | 292 cookies_tree_model_.reset(); |
| 292 | 293 |
| 293 EnsureCookiesTreeModelCreated(); | 294 EnsureCookiesTreeModelCreated(); |
| 294 } | 295 } |
| 295 | 296 |
| 296 } // namespace options | 297 } // namespace options |
| OLD | NEW |