| 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 "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
| 6 #include "base/values.h" | 6 #include "base/values.h" |
| 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 8 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 8 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
| 9 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 12 #include "components/bookmarks/browser/bookmark_model.h" | 13 #include "components/bookmarks/browser/bookmark_model.h" |
| 13 #include "components/bookmarks/browser/bookmark_node.h" | 14 #include "components/bookmarks/browser/bookmark_node.h" |
| 14 #include "components/bookmarks/common/bookmark_pref_names.h" | 15 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 15 #include "components/bookmarks/test/bookmark_test_helpers.h" | 16 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 16 | 17 |
| 17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Bookmarks) { | 18 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Bookmarks) { |
| 18 // Add test managed bookmarks to verify that the bookmarks API can read them | 19 // Add test managed bookmarks to verify that the bookmarks API can read them |
| 19 // and can't modify them. | 20 // and can't modify them. |
| 20 Profile* profile = browser()->profile(); | 21 Profile* profile = browser()->profile(); |
| 22 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); |
| 21 ChromeBookmarkClient* client = | 23 ChromeBookmarkClient* client = |
| 22 BookmarkModelFactory::GetChromeBookmarkClientForProfile(profile); | 24 ChromeBookmarkClientFactory::GetForProfile(profile); |
| 23 BookmarkModel* model = client->model(); | |
| 24 test::WaitForBookmarkModelToLoad(model); | 25 test::WaitForBookmarkModelToLoad(model); |
| 25 | 26 |
| 26 base::ListValue list; | 27 base::ListValue list; |
| 27 base::DictionaryValue* node = new base::DictionaryValue(); | 28 base::DictionaryValue* node = new base::DictionaryValue(); |
| 28 node->SetString("name", "Managed Bookmark"); | 29 node->SetString("name", "Managed Bookmark"); |
| 29 node->SetString("url", "http://www.chromium.org"); | 30 node->SetString("url", "http://www.chromium.org"); |
| 30 list.Append(node); | 31 list.Append(node); |
| 31 node = new base::DictionaryValue(); | 32 node = new base::DictionaryValue(); |
| 32 node->SetString("name", "Managed Folder"); | 33 node->SetString("name", "Managed Folder"); |
| 33 node->Set("children", new base::ListValue()); | 34 node->Set("children", new base::ListValue()); |
| 34 list.Append(node); | 35 list.Append(node); |
| 35 profile->GetPrefs()->Set(prefs::kManagedBookmarks, list); | 36 profile->GetPrefs()->Set(prefs::kManagedBookmarks, list); |
| 36 ASSERT_EQ(2, client->managed_node()->child_count()); | 37 ASSERT_EQ(2, client->managed_node()->child_count()); |
| 37 | 38 |
| 38 ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_; | 39 ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_; |
| 39 } | 40 } |
| OLD | NEW |