| 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> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 ManagedBookmarkServiceFactory::GetForProfile(profile); | 40 ManagedBookmarkServiceFactory::GetForProfile(profile); |
| 41 bookmarks::test::WaitForBookmarkModelToLoad(model); | 41 bookmarks::test::WaitForBookmarkModelToLoad(model); |
| 42 | 42 |
| 43 base::ListValue list; | 43 base::ListValue list; |
| 44 std::unique_ptr<base::DictionaryValue> node(new base::DictionaryValue()); | 44 std::unique_ptr<base::DictionaryValue> node(new base::DictionaryValue()); |
| 45 node->SetString("name", "Managed Bookmark"); | 45 node->SetString("name", "Managed Bookmark"); |
| 46 node->SetString("url", "http://www.chromium.org"); | 46 node->SetString("url", "http://www.chromium.org"); |
| 47 list.Append(std::move(node)); | 47 list.Append(std::move(node)); |
| 48 node.reset(new base::DictionaryValue()); | 48 node.reset(new base::DictionaryValue()); |
| 49 node->SetString("name", "Managed Folder"); | 49 node->SetString("name", "Managed Folder"); |
| 50 node->Set("children", new base::ListValue()); | 50 node->Set("children", base::MakeUnique<base::ListValue>()); |
| 51 list.Append(std::move(node)); | 51 list.Append(std::move(node)); |
| 52 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); | 52 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); |
| 53 ASSERT_EQ(2, managed->managed_node()->child_count()); | 53 ASSERT_EQ(2, managed->managed_node()->child_count()); |
| 54 | 54 |
| 55 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) | 55 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) |
| 56 << message_; | 56 << message_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { | 59 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { |
| 60 Profile* profile = browser()->profile(); | 60 Profile* profile = browser()->profile(); |
| 61 | 61 |
| 62 // Provide some testing data here, since bookmark editing will be disabled | 62 // Provide some testing data here, since bookmark editing will be disabled |
| 63 // within the extension. | 63 // within the extension. |
| 64 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); | 64 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); |
| 65 bookmarks::test::WaitForBookmarkModelToLoad(model); | 65 bookmarks::test::WaitForBookmarkModelToLoad(model); |
| 66 const BookmarkNode* bar = model->bookmark_bar_node(); | 66 const BookmarkNode* bar = model->bookmark_bar_node(); |
| 67 const BookmarkNode* folder = | 67 const BookmarkNode* folder = |
| 68 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); | 68 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); |
| 69 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), | 69 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), |
| 70 GURL("http://aaa.example.com")); | 70 GURL("http://aaa.example.com")); |
| 71 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), | 71 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), |
| 72 GURL("http://bbb.example.com")); | 72 GURL("http://bbb.example.com")); |
| 73 | 73 |
| 74 PrefService* prefs = user_prefs::UserPrefs::Get(profile); | 74 PrefService* prefs = user_prefs::UserPrefs::Get(profile); |
| 75 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); | 75 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); |
| 76 | 76 |
| 77 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) | 77 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) |
| 78 << message_; | 78 << message_; |
| 79 } | 79 } |
| OLD | NEW |