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

Side by Side Diff: chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc

Issue 2248683006: Site Settings Desktop: Implement individual cookie removal and RemoveAll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 4 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
OLDNEW
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 base::string16 query; 170 base::string16 query;
171 if (!args->GetString(0, &query)) 171 if (!args->GetString(0, &query))
172 return; 172 return;
173 173
174 EnsureCookiesTreeModelCreated(); 174 EnsureCookiesTreeModelCreated();
175 175
176 cookies_tree_model_->UpdateSearchResults(query); 176 cookies_tree_model_->UpdateSearchResults(query);
177 } 177 }
178 178
179 void CookiesViewHandler::RemoveAll(const base::ListValue* args) { 179 void CookiesViewHandler::RemoveAll(const base::ListValue* args) {
180 CHECK_EQ(1U, args->GetSize());
181 CHECK(args->GetString(0, &callback_id_));
182
180 EnsureCookiesTreeModelCreated(); 183 EnsureCookiesTreeModelCreated();
181 cookies_tree_model_->DeleteAllStoredObjects(); 184 cookies_tree_model_->DeleteAllStoredObjects();
182 } 185 }
183 186
184 void CookiesViewHandler::Remove(const base::ListValue* args) { 187 void CookiesViewHandler::Remove(const base::ListValue* args) {
185 std::string node_path; 188 std::string node_path;
186 if (!args->GetString(0, &node_path)) 189 if (!args->GetString(0, &node_path))
187 return; 190 return;
188 191
189 EnsureCookiesTreeModelCreated(); 192 EnsureCookiesTreeModelCreated();
190 193
191 const CookieTreeNode* node = model_util_->GetTreeNodeFromPath( 194 const CookieTreeNode* node = model_util_->GetTreeNodeFromPath(
192 cookies_tree_model_->GetRoot(), node_path); 195 cookies_tree_model_->GetRoot(), node_path);
193 if (node) 196 if (node)
194 cookies_tree_model_->DeleteCookieNode(const_cast<CookieTreeNode*>(node)); 197 cookies_tree_model_->DeleteCookieNode(const_cast<CookieTreeNode*>(node));
195 } 198 }
196 199
197 void CookiesViewHandler::LoadChildren(const base::ListValue* args) { 200 void CookiesViewHandler::LoadChildren(const base::ListValue* args) {
201 CHECK_LT(0U, args->GetSize());
202 CHECK(args->GetString(0, &callback_id_));
203
198 std::string node_path; 204 std::string node_path;
199 if (!args->GetString(0, &node_path)) 205 if (!args->GetString(1, &node_path))
200 return; 206 return;
201 207
202 EnsureCookiesTreeModelCreated(); 208 EnsureCookiesTreeModelCreated();
203 209
204 const CookieTreeNode* node = model_util_->GetTreeNodeFromPath( 210 const CookieTreeNode* node = model_util_->GetTreeNodeFromPath(
205 cookies_tree_model_->GetRoot(), node_path); 211 cookies_tree_model_->GetRoot(), node_path);
206 if (node) 212 if (node)
207 SendChildren(node); 213 SendChildren(node);
208 } 214 }
209 215
210 void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) { 216 void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) {
211 AllowJavascript(); 217 AllowJavascript();
212 218
213 std::unique_ptr<base::ListValue> children(new base::ListValue); 219 std::unique_ptr<base::ListValue> children(new base::ListValue);
214 model_util_->GetChildNodeList(parent, 0, parent->child_count(), 220 model_util_->GetChildNodeList(parent, 0, parent->child_count(),
215 children.get()); 221 children.get());
216 222
217 base::ListValue args; 223 base::ListValue args;
218 if (parent == cookies_tree_model_->GetRoot()) 224 if (parent == cookies_tree_model_->GetRoot())
219 args.Append(base::Value::CreateNullValue()); 225 args.Append(base::Value::CreateNullValue());
220 else 226 else
221 args.AppendString(model_util_->GetTreeNodeId(parent)); 227 args.AppendString(model_util_->GetTreeNodeId(parent));
222 args.Append(std::move(children)); 228 args.Append(std::move(children));
223 229
224 CallJavascriptFunction("cr.webUIListenerCallback", 230 ResolveJavascriptCallback(base::StringValue(callback_id_), args);
225 base::StringValue("loadChildren"), 231 callback_id_ = "";
226 args);
227 } 232 }
228 233
229 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) { 234 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) {
235 CHECK_EQ(1U, args->GetSize());
236 CHECK(args->GetString(0, &callback_id_));
237
230 cookies_tree_model_.reset(); 238 cookies_tree_model_.reset();
231 239
232 EnsureCookiesTreeModelCreated(); 240 EnsureCookiesTreeModelCreated();
233 } 241 }
234 242
235 } // namespace settings 243 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698