Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/ui/webui/options2/cookies_view_handler2.cc

Issue 10703127: Merge 145197 - clean-up: Use an id instead of memory pointer string in webui. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/options2/cookies_view_handler2.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/options2/cookies_view_handler2.h" 5 #include "chrome/browser/ui/webui/options2/cookies_view_handler2.h"
6 6
7 #include <string>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
9 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 12 #include "base/values.h"
11 #include "chrome/browser/browsing_data_appcache_helper.h" 13 #include "chrome/browser/browsing_data_appcache_helper.h"
12 #include "chrome/browser/browsing_data_cookie_helper.h" 14 #include "chrome/browser/browsing_data_cookie_helper.h"
13 #include "chrome/browser/browsing_data_database_helper.h" 15 #include "chrome/browser/browsing_data_database_helper.h"
14 #include "chrome/browser/browsing_data_file_system_helper.h" 16 #include "chrome/browser/browsing_data_file_system_helper.h"
15 #include "chrome/browser/browsing_data_indexed_db_helper.h" 17 #include "chrome/browser/browsing_data_indexed_db_helper.h"
16 #include "chrome/browser/browsing_data_local_storage_helper.h" 18 #include "chrome/browser/browsing_data_local_storage_helper.h"
17 #include "chrome/browser/browsing_data_quota_helper.h" 19 #include "chrome/browser/browsing_data_quota_helper.h"
18 #include "chrome/browser/browsing_data_server_bound_cert_helper.h" 20 #include "chrome/browser/browsing_data_server_bound_cert_helper.h"
19 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" 22 #include "chrome/browser/ui/webui/cookies_tree_model_util.h"
21 #include "content/public/browser/web_ui.h" 23 #include "content/public/browser/web_ui.h"
22 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
23 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
24 26
25 namespace options2 { 27 namespace options2 {
26 28
27 CookiesViewHandler::CookiesViewHandler() : batch_update_(false) { 29 CookiesViewHandler::CookiesViewHandler()
30 : batch_update_(false),
31 model_util_(new CookiesTreeModelUtil) {
28 } 32 }
29 33
30 CookiesViewHandler::~CookiesViewHandler() { 34 CookiesViewHandler::~CookiesViewHandler() {
31 } 35 }
32 36
33 void CookiesViewHandler::GetLocalizedValues( 37 void CookiesViewHandler::GetLocalizedValues(
34 DictionaryValue* localized_strings) { 38 DictionaryValue* localized_strings) {
35 DCHECK(localized_strings); 39 DCHECK(localized_strings);
36 40
37 static OptionsStringResource resources[] = { 41 static OptionsStringResource resources[] = {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ui::TreeModelNode* parent, 113 ui::TreeModelNode* parent,
110 int start, 114 int start,
111 int count) { 115 int count) {
112 // Skip if there is a batch update in progress. 116 // Skip if there is a batch update in progress.
113 if (batch_update_) 117 if (batch_update_)
114 return; 118 return;
115 119
116 CookieTreeNode* parent_node = cookies_tree_model_->AsNode(parent); 120 CookieTreeNode* parent_node = cookies_tree_model_->AsNode(parent);
117 121
118 ListValue* children = new ListValue; 122 ListValue* children = new ListValue;
119 cookies_tree_model_util::GetChildNodeList(parent_node, start, count, 123 model_util_->GetChildNodeList(parent_node, start, count,
120 children); 124 children);
121 125
122 ListValue args; 126 ListValue args;
123 args.Append(parent == cookies_tree_model_->GetRoot() ? 127 args.Append(parent == cookies_tree_model_->GetRoot() ?
124 Value::CreateNullValue() : 128 Value::CreateNullValue() :
125 Value::CreateStringValue( 129 Value::CreateStringValue(
126 cookies_tree_model_util::GetTreeNodeId(parent_node))); 130 model_util_->GetTreeNodeId(parent_node)));
127 args.Append(Value::CreateIntegerValue(start)); 131 args.Append(Value::CreateIntegerValue(start));
128 args.Append(children); 132 args.Append(children);
129 web_ui()->CallJavascriptFunction("CookiesView.onTreeItemAdded", args); 133 web_ui()->CallJavascriptFunction("CookiesView.onTreeItemAdded", args);
130 } 134 }
131 135
132 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, 136 void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model,
133 ui::TreeModelNode* parent, 137 ui::TreeModelNode* parent,
134 int start, 138 int start,
135 int count) { 139 int count) {
136 // Skip if there is a batch update in progress. 140 // Skip if there is a batch update in progress.
137 if (batch_update_) 141 if (batch_update_)
138 return; 142 return;
139 143
140 ListValue args; 144 ListValue args;
141 args.Append(parent == cookies_tree_model_->GetRoot() ? 145 args.Append(parent == cookies_tree_model_->GetRoot() ?
142 Value::CreateNullValue() : 146 Value::CreateNullValue() :
143 Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId( 147 Value::CreateStringValue(model_util_->GetTreeNodeId(
144 cookies_tree_model_->AsNode(parent)))); 148 cookies_tree_model_->AsNode(parent))));
145 args.Append(Value::CreateIntegerValue(start)); 149 args.Append(Value::CreateIntegerValue(start));
146 args.Append(Value::CreateIntegerValue(count)); 150 args.Append(Value::CreateIntegerValue(count));
147 web_ui()->CallJavascriptFunction("CookiesView.onTreeItemRemoved", args); 151 web_ui()->CallJavascriptFunction("CookiesView.onTreeItemRemoved", args);
148 } 152 }
149 153
150 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) { 154 void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) {
151 DCHECK(!batch_update_); // There should be no nested batch begin. 155 DCHECK(!batch_update_); // There should be no nested batch begin.
152 batch_update_ = true; 156 batch_update_ = true;
153 } 157 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 198 }
195 199
196 void CookiesViewHandler::Remove(const ListValue* args) { 200 void CookiesViewHandler::Remove(const ListValue* args) {
197 std::string node_path; 201 std::string node_path;
198 if (!args->GetString(0, &node_path)) { 202 if (!args->GetString(0, &node_path)) {
199 return; 203 return;
200 } 204 }
201 205
202 EnsureCookiesTreeModelCreated(); 206 EnsureCookiesTreeModelCreated();
203 207
204 CookieTreeNode* node = cookies_tree_model_util::GetTreeNodeFromPath( 208 const CookieTreeNode* node = model_util_->GetTreeNodeFromPath(
205 cookies_tree_model_->GetRoot(), node_path); 209 cookies_tree_model_->GetRoot(), node_path);
206 if (node) 210 if (node)
207 cookies_tree_model_->DeleteCookieNode(node); 211 cookies_tree_model_->DeleteCookieNode(const_cast<CookieTreeNode*>(node));
208 } 212 }
209 213
210 void CookiesViewHandler::LoadChildren(const ListValue* args) { 214 void CookiesViewHandler::LoadChildren(const ListValue* args) {
211 std::string node_path; 215 std::string node_path;
212 if (!args->GetString(0, &node_path)) { 216 if (!args->GetString(0, &node_path)) {
213 return; 217 return;
214 } 218 }
215 219
216 EnsureCookiesTreeModelCreated(); 220 EnsureCookiesTreeModelCreated();
217 221
218 CookieTreeNode* node = cookies_tree_model_util::GetTreeNodeFromPath( 222 const CookieTreeNode* node = model_util_->GetTreeNodeFromPath(
219 cookies_tree_model_->GetRoot(), node_path); 223 cookies_tree_model_->GetRoot(), node_path);
220 if (node) 224 if (node)
221 SendChildren(node); 225 SendChildren(node);
222 } 226 }
223 227
224 void CookiesViewHandler::SendChildren(CookieTreeNode* parent) { 228 void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) {
225 ListValue* children = new ListValue; 229 ListValue* children = new ListValue;
226 cookies_tree_model_util::GetChildNodeList(parent, 0, parent->child_count(), 230 model_util_->GetChildNodeList(parent, 0, parent->child_count(),
227 children); 231 children);
228 232
229 ListValue args; 233 ListValue args;
230 args.Append(parent == cookies_tree_model_->GetRoot() ? 234 args.Append(parent == cookies_tree_model_->GetRoot() ?
231 Value::CreateNullValue() : 235 Value::CreateNullValue() :
232 Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId(parent))); 236 Value::CreateStringValue(model_util_->GetTreeNodeId(parent)));
233 args.Append(children); 237 args.Append(children);
234 238
235 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); 239 web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args);
236 } 240 }
237 241
238 } // namespace options2 242 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/cookies_view_handler2.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698