OLD | NEW |
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/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api.h" | 5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api.h" |
6 | 6 |
| 7 #include <memory> |
| 8 #include <utility> |
| 9 |
7 #include "base/command_line.h" | 10 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 12 #include "base/values.h" |
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
11 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 14 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
12 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
13 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
16 #include "components/bookmarks/browser/bookmark_model.h" | 19 #include "components/bookmarks/browser/bookmark_model.h" |
(...skipping 14 matching lines...) Expand all Loading... |
31 #endif | 34 #endif |
32 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) { | 35 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) { |
33 // Add managed bookmarks. | 36 // Add managed bookmarks. |
34 Profile* profile = browser()->profile(); | 37 Profile* profile = browser()->profile(); |
35 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 38 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
36 bookmarks::ManagedBookmarkService* managed = | 39 bookmarks::ManagedBookmarkService* managed = |
37 ManagedBookmarkServiceFactory::GetForProfile(profile); | 40 ManagedBookmarkServiceFactory::GetForProfile(profile); |
38 bookmarks::test::WaitForBookmarkModelToLoad(model); | 41 bookmarks::test::WaitForBookmarkModelToLoad(model); |
39 | 42 |
40 base::ListValue list; | 43 base::ListValue list; |
41 base::DictionaryValue* node = new base::DictionaryValue(); | 44 std::unique_ptr<base::DictionaryValue> node(new base::DictionaryValue()); |
42 node->SetString("name", "Managed Bookmark"); | 45 node->SetString("name", "Managed Bookmark"); |
43 node->SetString("url", "http://www.chromium.org"); | 46 node->SetString("url", "http://www.chromium.org"); |
44 list.Append(node); | 47 list.Append(std::move(node)); |
45 node = new base::DictionaryValue(); | 48 node.reset(new base::DictionaryValue()); |
46 node->SetString("name", "Managed Folder"); | 49 node->SetString("name", "Managed Folder"); |
47 node->Set("children", new base::ListValue()); | 50 node->Set("children", new base::ListValue()); |
48 list.Append(node); | 51 list.Append(std::move(node)); |
49 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); | 52 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); |
50 ASSERT_EQ(2, managed->managed_node()->child_count()); | 53 ASSERT_EQ(2, managed->managed_node()->child_count()); |
51 | 54 |
52 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) | 55 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) |
53 << message_; | 56 << message_; |
54 } | 57 } |
55 | 58 |
56 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { | 59 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { |
57 Profile* profile = browser()->profile(); | 60 Profile* profile = browser()->profile(); |
58 | 61 |
59 // Provide some testing data here, since bookmark editing will be disabled | 62 // Provide some testing data here, since bookmark editing will be disabled |
60 // within the extension. | 63 // within the extension. |
61 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 64 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
62 bookmarks::test::WaitForBookmarkModelToLoad(model); | 65 bookmarks::test::WaitForBookmarkModelToLoad(model); |
63 const BookmarkNode* bar = model->bookmark_bar_node(); | 66 const BookmarkNode* bar = model->bookmark_bar_node(); |
64 const BookmarkNode* folder = | 67 const BookmarkNode* folder = |
65 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); | 68 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); |
66 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), | 69 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), |
67 GURL("http://aaa.example.com")); | 70 GURL("http://aaa.example.com")); |
68 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), | 71 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), |
69 GURL("http://bbb.example.com")); | 72 GURL("http://bbb.example.com")); |
70 | 73 |
71 PrefService* prefs = user_prefs::UserPrefs::Get(profile); | 74 PrefService* prefs = user_prefs::UserPrefs::Get(profile); |
72 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); | 75 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); |
73 | 76 |
74 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) | 77 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) |
75 << message_; | 78 << message_; |
76 } | 79 } |
OLD | NEW |