| 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/cookies_tree_model_adapter.h" | 5 #include "chrome/browser/ui/webui/cookies_tree_model_adapter.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" | 10 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 void CookiesTreeModelAdapter::TreeNodesAdded(ui::TreeModel* model, | 61 void CookiesTreeModelAdapter::TreeNodesAdded(ui::TreeModel* model, |
| 62 ui::TreeModelNode* parent, | 62 ui::TreeModelNode* parent, |
| 63 int start, | 63 int start, |
| 64 int count) { | 64 int count) { |
| 65 // Skip if there is a batch update in progress. | 65 // Skip if there is a batch update in progress. |
| 66 if (batch_update_) | 66 if (batch_update_) |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 CookieTreeNode* parent_node = model_->AsNode(parent); | 69 CookieTreeNode* parent_node = model_->AsNode(parent); |
| 70 | 70 |
| 71 StringValue tree_id(tree_id_); | 71 base::StringValue tree_id(tree_id_); |
| 72 scoped_ptr<Value> parend_id(GetTreeNodeId(parent_node)); | 72 scoped_ptr<Value> parend_id(GetTreeNodeId(parent_node)); |
| 73 FundamentalValue start_value(start); | 73 base::FundamentalValue start_value(start); |
| 74 ListValue children; | 74 base::ListValue children; |
| 75 cookies_tree_model_util::GetChildNodeList(parent_node, start, count, | 75 cookies_tree_model_util::GetChildNodeList(parent_node, start, count, |
| 76 &children); | 76 &children); |
| 77 web_ui_->CallJavascriptFunction("ui.CookiesTree.onTreeItemAdded", | 77 web_ui_->CallJavascriptFunction("ui.CookiesTree.onTreeItemAdded", |
| 78 tree_id, *parend_id.get(), start_value, children); | 78 tree_id, *parend_id.get(), start_value, children); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void CookiesTreeModelAdapter::TreeNodesRemoved(ui::TreeModel* model, | 81 void CookiesTreeModelAdapter::TreeNodesRemoved(ui::TreeModel* model, |
| 82 ui::TreeModelNode* parent, | 82 ui::TreeModelNode* parent, |
| 83 int start, | 83 int start, |
| 84 int count) { | 84 int count) { |
| 85 // Skip if there is a batch update in progress. | 85 // Skip if there is a batch update in progress. |
| 86 if (batch_update_) | 86 if (batch_update_) |
| 87 return; | 87 return; |
| 88 | 88 |
| 89 StringValue tree_id(tree_id_); | 89 base::StringValue tree_id(tree_id_); |
| 90 scoped_ptr<Value> parend_id(GetTreeNodeId(model_->AsNode(parent))); | 90 scoped_ptr<Value> parend_id(GetTreeNodeId(model_->AsNode(parent))); |
| 91 FundamentalValue start_value(start); | 91 base::FundamentalValue start_value(start); |
| 92 FundamentalValue count_value(count); | 92 base::FundamentalValue count_value(count); |
| 93 web_ui_->CallJavascriptFunction("ui.CookiesTree.onTreeItemRemoved", | 93 web_ui_->CallJavascriptFunction("ui.CookiesTree.onTreeItemRemoved", |
| 94 tree_id, *parend_id.get(), start_value, count_value); | 94 tree_id, *parend_id.get(), start_value, count_value); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void CookiesTreeModelAdapter::TreeModelBeginBatch(CookiesTreeModel* model) { | 97 void CookiesTreeModelAdapter::TreeModelBeginBatch(CookiesTreeModel* model) { |
| 98 DCHECK(!batch_update_); // There should be no nested batch begin. | 98 DCHECK(!batch_update_); // There should be no nested batch begin. |
| 99 batch_update_ = true; | 99 batch_update_ = true; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void CookiesTreeModelAdapter::TreeModelEndBatch(CookiesTreeModel* model) { | 102 void CookiesTreeModelAdapter::TreeModelEndBatch(CookiesTreeModel* model) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 126 tree_id, *parend_id.get(), children); | 126 tree_id, *parend_id.get(), children); |
| 127 } | 127 } |
| 128 | 128 |
| 129 Value* CookiesTreeModelAdapter::GetTreeNodeId(CookieTreeNode* node) { | 129 Value* CookiesTreeModelAdapter::GetTreeNodeId(CookieTreeNode* node) { |
| 130 if (node == model_->GetRoot()) | 130 if (node == model_->GetRoot()) |
| 131 return Value::CreateNullValue(); | 131 return Value::CreateNullValue(); |
| 132 | 132 |
| 133 return Value::CreateStringValue( | 133 return Value::CreateStringValue( |
| 134 cookies_tree_model_util::GetTreeNodeId(node)); | 134 cookies_tree_model_util::GetTreeNodeId(node)); |
| 135 } | 135 } |
| OLD | NEW |