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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 base::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 base::FundamentalValue start_value(start); | 73 base::NumberValue start_value(start); |
74 base::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 base::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 base::FundamentalValue start_value(start); | 91 base::NumberValue start_value(start); |
92 base::FundamentalValue count_value(count); | 92 base::NumberValue 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 18 matching lines...) Expand all Loading... |
121 scoped_ptr<Value> parend_id(GetTreeNodeId(model_->AsNode(parent))); | 121 scoped_ptr<Value> parend_id(GetTreeNodeId(model_->AsNode(parent))); |
122 ListValue children; | 122 ListValue children; |
123 cookies_tree_model_util::GetChildNodeList(parent, 0, parent->child_count(), | 123 cookies_tree_model_util::GetChildNodeList(parent, 0, parent->child_count(), |
124 &children); | 124 &children); |
125 web_ui_->CallJavascriptFunction("ui.CookiesTree.setChildren", | 125 web_ui_->CallJavascriptFunction("ui.CookiesTree.setChildren", |
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 base::NullValue(); |
132 | 132 |
133 return Value::CreateStringValue( | 133 return base::StringValue::New( |
134 cookies_tree_model_util::GetTreeNodeId(node)); | 134 cookies_tree_model_util::GetTreeNodeId(node)); |
135 } | 135 } |
OLD | NEW |