| 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" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 std::unique_ptr<base::ListValue> children(new base::ListValue); | 149 std::unique_ptr<base::ListValue> children(new base::ListValue); |
| 150 model_util_->GetChildNodeList(parent_node, start, count, children.get()); | 150 model_util_->GetChildNodeList(parent_node, start, count, children.get()); |
| 151 | 151 |
| 152 base::ListValue args; | 152 base::ListValue args; |
| 153 if (parent == tree_model->GetRoot()) | 153 if (parent == tree_model->GetRoot()) |
| 154 args.Append(base::Value::CreateNullValue()); | 154 args.Append(base::Value::CreateNullValue()); |
| 155 else | 155 else |
| 156 args.AppendString(model_util_->GetTreeNodeId(parent_node)); | 156 args.AppendString(model_util_->GetTreeNodeId(parent_node)); |
| 157 args.AppendInteger(start); | 157 args.AppendInteger(start); |
| 158 args.Append(std::move(children)); | 158 args.Append(std::move(children)); |
| 159 web_ui()->CallJavascriptFunction("CookiesView.onTreeItemAdded", args); | 159 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.onTreeItemAdded", args); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, | 162 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, |
| 163 ui::TreeModelNode* parent, | 163 ui::TreeModelNode* parent, |
| 164 int start, | 164 int start, |
| 165 int count) { | 165 int count) { |
| 166 // Skip if there is a batch update in progress. | 166 // Skip if there is a batch update in progress. |
| 167 if (batch_update_) | 167 if (batch_update_) |
| 168 return; | 168 return; |
| 169 | 169 |
| 170 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); | 170 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); |
| 171 | 171 |
| 172 base::ListValue args; | 172 base::ListValue args; |
| 173 if (parent == tree_model->GetRoot()) | 173 if (parent == tree_model->GetRoot()) |
| 174 args.Append(base::Value::CreateNullValue()); | 174 args.Append(base::Value::CreateNullValue()); |
| 175 else | 175 else |
| 176 args.AppendString(model_util_->GetTreeNodeId(tree_model->AsNode(parent))); | 176 args.AppendString(model_util_->GetTreeNodeId(tree_model->AsNode(parent))); |
| 177 args.AppendInteger(start); | 177 args.AppendInteger(start); |
| 178 args.AppendInteger(count); | 178 args.AppendInteger(count); |
| 179 web_ui()->CallJavascriptFunction("CookiesView.onTreeItemRemoved", args); | 179 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.onTreeItemRemoved", args); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { | 182 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { |
| 183 DCHECK(!batch_update_); // There should be no nested batch begin. | 183 DCHECK(!batch_update_); // There should be no nested batch begin. |
| 184 batch_update_ = true; | 184 batch_update_ = true; |
| 185 } | 185 } |
| 186 | 186 |
| 187 void CookiesViewHandler::TreeModelEndBatch(CookiesTreeModel* model) { | 187 void CookiesViewHandler::TreeModelEndBatch(CookiesTreeModel* model) { |
| 188 DCHECK(batch_update_); | 188 DCHECK(batch_update_); |
| 189 batch_update_ = false; | 189 batch_update_ = false; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 model_util_->GetChildNodeList(parent, 0, parent->child_count(), | 270 model_util_->GetChildNodeList(parent, 0, parent->child_count(), |
| 271 children.get()); | 271 children.get()); |
| 272 | 272 |
| 273 base::ListValue args; | 273 base::ListValue args; |
| 274 if (parent == cookies_tree_model_->GetRoot()) | 274 if (parent == cookies_tree_model_->GetRoot()) |
| 275 args.Append(base::Value::CreateNullValue()); | 275 args.Append(base::Value::CreateNullValue()); |
| 276 else | 276 else |
| 277 args.AppendString(model_util_->GetTreeNodeId(parent)); | 277 args.AppendString(model_util_->GetTreeNodeId(parent)); |
| 278 args.Append(std::move(children)); | 278 args.Append(std::move(children)); |
| 279 | 279 |
| 280 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); | 280 web_ui()->CallJavascriptFunctionUnsafe("CookiesView.loadChildren", args); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) { | 283 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) { |
| 284 cookies_tree_model_.reset(); | 284 cookies_tree_model_.reset(); |
| 285 | 285 |
| 286 EnsureCookiesTreeModelCreated(); | 286 EnsureCookiesTreeModelCreated(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 } // namespace options | 289 } // namespace options |
| OLD | NEW |