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

Side by Side Diff: chrome/browser/ui/webui/cookies_tree_model_util.cc

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/cookies_tree_model_util.h" 5 #include "chrome/browser/ui/webui/cookies_tree_model_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 310 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
311 const CookieTreeNode* child = parent->GetChild(start + i); 311 const CookieTreeNode* child = parent->GetChild(start + i);
312 if (GetCookieTreeNodeDictionary(*child, dict.get())) 312 if (GetCookieTreeNodeDictionary(*child, dict.get()))
313 nodes->Append(dict.release()); 313 nodes->Append(dict.release());
314 } 314 }
315 } 315 }
316 316
317 const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromPath( 317 const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromPath(
318 const CookieTreeNode* root, 318 const CookieTreeNode* root,
319 const std::string& path) { 319 const std::string& path) {
320 std::vector<std::string> node_ids;
321 base::SplitString(path, ',', &node_ids);
322
323 const CookieTreeNode* child = NULL; 320 const CookieTreeNode* child = NULL;
324 const CookieTreeNode* parent = root; 321 const CookieTreeNode* parent = root;
325 int child_index = -1; 322 int child_index = -1;
326 323
327 // Validate the tree path and get the node pointer. 324 // Validate the tree path and get the node pointer.
328 for (size_t i = 0; i < node_ids.size(); ++i) { 325 for (const base::StringPiece& cur_node : base::SplitStringPiece(
326 path, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
329 int32 node_id = 0; 327 int32 node_id = 0;
330 if (!base::StringToInt(node_ids[i], &node_id)) 328 if (!base::StringToInt(cur_node, &node_id))
331 break; 329 break;
332 330
333 child = id_map_.Lookup(node_id); 331 child = id_map_.Lookup(node_id);
334 child_index = parent->GetIndexOf(child); 332 child_index = parent->GetIndexOf(child);
335 if (child_index == -1) 333 if (child_index == -1)
336 break; 334 break;
337 335
338 parent = child; 336 parent = child;
339 } 337 }
340 338
341 return child_index >= 0 ? child : NULL; 339 return child_index >= 0 ? child : NULL;
342 } 340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698