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

Side by Side Diff: chrome/browser/extensions/api/bookmarks/bookmark_apitest.cc

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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 <memory>
6 #include <utility>
7
5 #include "base/values.h" 8 #include "base/values.h"
6 #include "build/build_config.h" 9 #include "build/build_config.h"
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
8 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 11 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 12 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
12 #include "components/bookmarks/browser/bookmark_model.h" 15 #include "components/bookmarks/browser/bookmark_model.h"
13 #include "components/bookmarks/browser/bookmark_node.h" 16 #include "components/bookmarks/browser/bookmark_node.h"
14 #include "components/bookmarks/common/bookmark_pref_names.h" 17 #include "components/bookmarks/common/bookmark_pref_names.h"
(...skipping 13 matching lines...) Expand all
28 // Add test managed and supervised bookmarks to verify that the bookmarks API 31 // Add test managed and supervised bookmarks to verify that the bookmarks API
29 // can read them and can't modify them. 32 // can read them and can't modify them.
30 Profile* profile = browser()->profile(); 33 Profile* profile = browser()->profile();
31 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 34 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
32 bookmarks::ManagedBookmarkService* managed = 35 bookmarks::ManagedBookmarkService* managed =
33 ManagedBookmarkServiceFactory::GetForProfile(profile); 36 ManagedBookmarkServiceFactory::GetForProfile(profile);
34 bookmarks::test::WaitForBookmarkModelToLoad(model); 37 bookmarks::test::WaitForBookmarkModelToLoad(model);
35 38
36 { 39 {
37 base::ListValue list; 40 base::ListValue list;
38 base::DictionaryValue* node = new base::DictionaryValue(); 41 std::unique_ptr<base::DictionaryValue> node(new base::DictionaryValue());
39 node->SetString("name", "Managed Bookmark"); 42 node->SetString("name", "Managed Bookmark");
40 node->SetString("url", "http://www.chromium.org"); 43 node->SetString("url", "http://www.chromium.org");
41 list.Append(node); 44 list.Append(std::move(node));
42 node = new base::DictionaryValue(); 45 node.reset(new base::DictionaryValue());
43 node->SetString("name", "Managed Folder"); 46 node->SetString("name", "Managed Folder");
44 node->Set("children", new base::ListValue()); 47 node->Set("children", new base::ListValue());
45 list.Append(node); 48 list.Append(std::move(node));
46 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); 49 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list);
47 ASSERT_EQ(2, managed->managed_node()->child_count()); 50 ASSERT_EQ(2, managed->managed_node()->child_count());
48 } 51 }
49 52
50 { 53 {
51 base::ListValue list; 54 base::ListValue list;
52 base::DictionaryValue* node = new base::DictionaryValue(); 55 std::unique_ptr<base::DictionaryValue> node(new base::DictionaryValue());
53 node->SetString("name", "Supervised Bookmark"); 56 node->SetString("name", "Supervised Bookmark");
54 node->SetString("url", "http://www.pbskids.org"); 57 node->SetString("url", "http://www.pbskids.org");
55 list.Append(node); 58 list.Append(std::move(node));
56 node = new base::DictionaryValue(); 59 node.reset(new base::DictionaryValue());
57 node->SetString("name", "Supervised Folder"); 60 node->SetString("name", "Supervised Folder");
58 node->Set("children", new base::ListValue()); 61 node->Set("children", new base::ListValue());
59 list.Append(node); 62 list.Append(std::move(node));
60 profile->GetPrefs()->Set(bookmarks::prefs::kSupervisedBookmarks, list); 63 profile->GetPrefs()->Set(bookmarks::prefs::kSupervisedBookmarks, list);
61 ASSERT_EQ(2, managed->supervised_node()->child_count()); 64 ASSERT_EQ(2, managed->supervised_node()->child_count());
62 } 65 }
63 66
64 ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_; 67 ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
65 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698