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

Side by Side Diff: chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc

Issue 1203713002: Limit access to ChromeBookmarkClient to bookmarks code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_bookmark_client
Patch Set: Rebase Created 5 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 "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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
13 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
14 #include "chrome/browser/extensions/extension_apitest.h" 12 #include "chrome/browser/extensions/extension_apitest.h"
15 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
17 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
18 #include "components/bookmarks/browser/bookmark_model.h" 16 #include "components/bookmarks/browser/bookmark_model.h"
19 #include "components/bookmarks/common/bookmark_pref_names.h" 17 #include "components/bookmarks/common/bookmark_pref_names.h"
20 #include "components/bookmarks/test/bookmark_test_helpers.h" 18 #include "components/bookmarks/test/bookmark_test_helpers.h"
21 #include "components/user_prefs/user_prefs.h" 19 #include "components/user_prefs/user_prefs.h"
22 20
23 using bookmarks::BookmarkModel; 21 using bookmarks::BookmarkModel;
24 using bookmarks::BookmarkNode; 22 using bookmarks::BookmarkNode;
25 23
26 // Times out on win syzyasan, http://crbug.com/166026 24 // Times out on win syzyasan, http://crbug.com/166026
27 #if defined(SYZYASAN) 25 #if defined(SYZYASAN)
28 #define MAYBE_BookmarkManager DISABLED_BookmarkManager 26 #define MAYBE_BookmarkManager DISABLED_BookmarkManager
29 #else 27 #else
30 #define MAYBE_BookmarkManager BookmarkManager 28 #define MAYBE_BookmarkManager BookmarkManager
31 #endif 29 #endif
32 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) { 30 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) {
33 // Add managed bookmarks. 31 // Add managed bookmarks.
34 Profile* profile = browser()->profile(); 32 Profile* profile = browser()->profile();
35 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 33 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
36 ChromeBookmarkClient* client =
37 ChromeBookmarkClientFactory::GetForProfile(profile);
38 bookmarks::test::WaitForBookmarkModelToLoad(model); 34 bookmarks::test::WaitForBookmarkModelToLoad(model);
39 35
40 base::ListValue list; 36 base::ListValue list;
41 base::DictionaryValue* node = new base::DictionaryValue(); 37 base::DictionaryValue* node = new base::DictionaryValue();
42 node->SetString("name", "Managed Bookmark"); 38 node->SetString("name", "Managed Bookmark");
43 node->SetString("url", "http://www.chromium.org"); 39 node->SetString("url", "http://www.chromium.org");
44 list.Append(node); 40 list.Append(node);
45 node = new base::DictionaryValue(); 41 node = new base::DictionaryValue();
46 node->SetString("name", "Managed Folder"); 42 node->SetString("name", "Managed Folder");
47 node->Set("children", new base::ListValue()); 43 node->Set("children", new base::ListValue());
48 list.Append(node); 44 list.Append(node);
49 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); 45 profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list);
50 ASSERT_EQ(2, client->managed_node()->child_count()); 46 ASSERT_EQ(2, model->managed_node()->child_count());
51 47
52 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) 48 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard"))
53 << message_; 49 << message_;
54 } 50 }
55 51
56 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { 52 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) {
57 Profile* profile = browser()->profile(); 53 Profile* profile = browser()->profile();
58 54
59 // Provide some testing data here, since bookmark editing will be disabled 55 // Provide some testing data here, since bookmark editing will be disabled
60 // within the extension. 56 // within the extension.
61 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 57 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
62 bookmarks::test::WaitForBookmarkModelToLoad(model); 58 bookmarks::test::WaitForBookmarkModelToLoad(model);
63 const BookmarkNode* bar = model->bookmark_bar_node(); 59 const BookmarkNode* bar = model->bookmark_bar_node();
64 const BookmarkNode* folder = 60 const BookmarkNode* folder =
65 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); 61 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder"));
66 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), 62 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"),
67 GURL("http://aaa.example.com")); 63 GURL("http://aaa.example.com"));
68 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), 64 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"),
69 GURL("http://bbb.example.com")); 65 GURL("http://bbb.example.com"));
70 66
71 PrefService* prefs = user_prefs::UserPrefs::Get(profile); 67 PrefService* prefs = user_prefs::UserPrefs::Get(profile);
72 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); 68 prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false);
73 69
74 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) 70 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled"))
75 << message_; 71 << message_;
76 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698