| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); | 145 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); |
| 146 CookieTreeNode* parent_node = tree_model->AsNode(parent); | 146 CookieTreeNode* parent_node = tree_model->AsNode(parent); |
| 147 | 147 |
| 148 ListValue* children = new ListValue; | 148 ListValue* children = new ListValue; |
| 149 model_util_->GetChildNodeList(parent_node, start, count, | 149 model_util_->GetChildNodeList(parent_node, start, count, |
| 150 children); | 150 children); |
| 151 | 151 |
| 152 ListValue args; | 152 ListValue args; |
| 153 args.Append(parent == tree_model->GetRoot() ? | 153 args.Append(parent == tree_model->GetRoot() ? |
| 154 Value::CreateNullValue() : | 154 Value::CreateNullValue() : |
| 155 Value::CreateStringValue( | 155 new base::StringValue(model_util_->GetTreeNodeId(parent_node))); |
| 156 model_util_->GetTreeNodeId(parent_node))); | |
| 157 args.Append(Value::CreateIntegerValue(start)); | 156 args.Append(Value::CreateIntegerValue(start)); |
| 158 args.Append(children); | 157 args.Append(children); |
| 159 web_ui()->CallJavascriptFunction( | 158 web_ui()->CallJavascriptFunction( |
| 160 GetCallback("onTreeItemAdded", tree_model), args); | 159 GetCallback("onTreeItemAdded", tree_model), args); |
| 161 } | 160 } |
| 162 | 161 |
| 163 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, | 162 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, |
| 164 ui::TreeModelNode* parent, | 163 ui::TreeModelNode* parent, |
| 165 int start, | 164 int start, |
| 166 int count) { | 165 int count) { |
| 167 // Skip if there is a batch update in progress. | 166 // Skip if there is a batch update in progress. |
| 168 if (batch_update_) | 167 if (batch_update_) |
| 169 return; | 168 return; |
| 170 | 169 |
| 171 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); | 170 CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model); |
| 172 | 171 |
| 173 ListValue args; | 172 ListValue args; |
| 174 args.Append(parent == tree_model->GetRoot() ? | 173 args.Append(parent == tree_model->GetRoot() ? |
| 175 Value::CreateNullValue() : | 174 Value::CreateNullValue() : |
| 176 Value::CreateStringValue(model_util_->GetTreeNodeId( | 175 new base::StringValue(model_util_->GetTreeNodeId( |
| 177 tree_model->AsNode(parent)))); | 176 tree_model->AsNode(parent)))); |
| 178 args.Append(Value::CreateIntegerValue(start)); | 177 args.Append(Value::CreateIntegerValue(start)); |
| 179 args.Append(Value::CreateIntegerValue(count)); | 178 args.Append(Value::CreateIntegerValue(count)); |
| 180 web_ui()->CallJavascriptFunction( | 179 web_ui()->CallJavascriptFunction( |
| 181 GetCallback("onTreeItemRemoved", tree_model), args); | 180 GetCallback("onTreeItemRemoved", tree_model), args); |
| 182 } | 181 } |
| 183 | 182 |
| 184 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { | 183 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { |
| 185 DCHECK(!batch_update_); // There should be no nested batch begin. | 184 DCHECK(!batch_update_); // There should be no nested batch begin. |
| 186 batch_update_ = true; | 185 batch_update_ = true; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 301 } |
| 303 | 302 |
| 304 void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) { | 303 void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) { |
| 305 ListValue* children = new ListValue; | 304 ListValue* children = new ListValue; |
| 306 model_util_->GetChildNodeList(parent, 0, parent->child_count(), | 305 model_util_->GetChildNodeList(parent, 0, parent->child_count(), |
| 307 children); | 306 children); |
| 308 | 307 |
| 309 ListValue args; | 308 ListValue args; |
| 310 args.Append(parent == GetTreeModel()->GetRoot() ? | 309 args.Append(parent == GetTreeModel()->GetRoot() ? |
| 311 Value::CreateNullValue() : | 310 Value::CreateNullValue() : |
| 312 Value::CreateStringValue(model_util_->GetTreeNodeId(parent))); | 311 new base::StringValue(model_util_->GetTreeNodeId(parent))); |
| 313 args.Append(children); | 312 args.Append(children); |
| 314 | 313 |
| 315 web_ui()->CallJavascriptFunction( | 314 web_ui()->CallJavascriptFunction( |
| 316 GetCallback("loadChildren", GetTreeModel()), args); | 315 GetCallback("loadChildren", GetTreeModel()), args); |
| 317 } | 316 } |
| 318 | 317 |
| 319 void CookiesViewHandler::SetViewContext(const base::ListValue* args) { | 318 void CookiesViewHandler::SetViewContext(const base::ListValue* args) { |
| 320 bool app_context = false; | 319 bool app_context = false; |
| 321 if (args->GetBoolean(0, &app_context)) | 320 if (args->GetBoolean(0, &app_context)) |
| 322 app_context_ = app_context; | 321 app_context_ = app_context; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 339 std::string CookiesViewHandler::GetCallback( | 338 std::string CookiesViewHandler::GetCallback( |
| 340 std::string method, CookiesTreeModel* model) { | 339 std::string method, CookiesTreeModel* model) { |
| 341 std::string callback("CookiesView"); | 340 std::string callback("CookiesView"); |
| 342 | 341 |
| 343 if (model == app_cookies_tree_model_) | 342 if (model == app_cookies_tree_model_) |
| 344 callback.append("App"); | 343 callback.append("App"); |
| 345 return callback.append(".").append(method); | 344 return callback.append(".").append(method); |
| 346 } | 345 } |
| 347 | 346 |
| 348 } // namespace options | 347 } // namespace options |
| OLD | NEW |