OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/settings/settings_cookies_view_handler.h" | 5 #include "chrome/browser/ui/webui/settings/settings_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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 model_util_->GetChildNodeList( | 101 model_util_->GetChildNodeList( |
102 parent_node, start, count, /*include_quota_nodes=*/false, children.get()); | 102 parent_node, start, count, /*include_quota_nodes=*/false, children.get()); |
103 | 103 |
104 base::DictionaryValue args; | 104 base::DictionaryValue args; |
105 if (parent == tree_model->GetRoot()) | 105 if (parent == tree_model->GetRoot()) |
106 args.Set(kId, base::MakeUnique<base::Value>()); | 106 args.Set(kId, base::MakeUnique<base::Value>()); |
107 else | 107 else |
108 args.SetString(kId, model_util_->GetTreeNodeId(parent_node)); | 108 args.SetString(kId, model_util_->GetTreeNodeId(parent_node)); |
109 args.SetInteger(kStart, start); | 109 args.SetInteger(kStart, start); |
110 args.Set(kChildren, std::move(children)); | 110 args.Set(kChildren, std::move(children)); |
111 CallJavascriptFunction("cr.webUIListenerCallback", | 111 FireWebUIListener("onTreeItemAdded", args); |
112 base::Value("onTreeItemAdded"), args); | |
113 } | 112 } |
114 | 113 |
115 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, | 114 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, |
116 ui::TreeModelNode* parent, | 115 ui::TreeModelNode* parent, |
117 int start, | 116 int start, |
118 int count) { | 117 int count) { |
119 // Skip if there is a batch update in progress. | 118 // Skip if there is a batch update in progress. |
120 if (batch_update_) | 119 if (batch_update_) |
121 return; | 120 return; |
122 | 121 |
123 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); | 122 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); |
124 | 123 |
125 base::DictionaryValue args; | 124 base::DictionaryValue args; |
126 if (parent == tree_model->GetRoot()) | 125 if (parent == tree_model->GetRoot()) |
127 args.Set(kId, base::MakeUnique<base::Value>()); | 126 args.Set(kId, base::MakeUnique<base::Value>()); |
128 else | 127 else |
129 args.SetString(kId, model_util_->GetTreeNodeId(tree_model->AsNode(parent))); | 128 args.SetString(kId, model_util_->GetTreeNodeId(tree_model->AsNode(parent))); |
130 args.SetInteger(kStart, start); | 129 args.SetInteger(kStart, start); |
131 args.SetInteger(kCount, count); | 130 args.SetInteger(kCount, count); |
132 CallJavascriptFunction("cr.webUIListenerCallback", | 131 FireWebUIListener("onTreeItemRemoved", args); |
133 base::Value("onTreeItemRemoved"), args); | |
134 } | 132 } |
135 | 133 |
136 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { | 134 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { |
137 DCHECK(!batch_update_); // There should be no nested batch begin. | 135 DCHECK(!batch_update_); // There should be no nested batch begin. |
138 batch_update_ = true; | 136 batch_update_ = true; |
139 } | 137 } |
140 | 138 |
141 void CookiesViewHandler::TreeModelEndBatch(CookiesTreeModel* model) { | 139 void CookiesViewHandler::TreeModelEndBatch(CookiesTreeModel* model) { |
142 DCHECK(batch_update_); | 140 DCHECK(batch_update_); |
143 batch_update_ = false; | 141 batch_update_ = false; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 args.Set(kId, base::MakeUnique<base::Value>()); | 276 args.Set(kId, base::MakeUnique<base::Value>()); |
279 else | 277 else |
280 args.SetString(kId, model_util_->GetTreeNodeId(parent)); | 278 args.SetString(kId, model_util_->GetTreeNodeId(parent)); |
281 args.Set(kChildren, std::move(children)); | 279 args.Set(kChildren, std::move(children)); |
282 | 280 |
283 ResolveJavascriptCallback(base::Value(callback_id_), args); | 281 ResolveJavascriptCallback(base::Value(callback_id_), args); |
284 callback_id_.clear(); | 282 callback_id_.clear(); |
285 } | 283 } |
286 | 284 |
287 } // namespace settings | 285 } // namespace settings |
OLD | NEW |