diff options
19 files changed, 298 insertions, 126 deletions
diff --git a/build/ios/grit_whitelist.txt b/build/ios/grit_whitelist.txt index 6174648..045c704 100644 --- a/build/ios/grit_whitelist.txt +++ b/build/ios/grit_whitelist.txt @@ -126,6 +126,8 @@ IDS_BLOCK_INSECURE_CONTENT_BUTTON IDS_BOOKMARK_ADD_EDITOR_TITLE IDS_BOOKMARK_ALL_TABS_DIALOG_TITLE IDS_BOOKMARK_BAR_FOLDER_NAME +IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME +IDS_BOOKMARK_BAR_MANAGED_FOLDER_DOMAIN_NAME IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME IDS_BOOKMARK_BAR_REDO @@ -685,8 +687,6 @@ IDS_POLICY_INVALID_BOOKMARK IDS_POLICY_INVALID_PROXY_MODE_ERROR IDS_POLICY_INVALID_SEARCH_URL_ERROR IDS_POLICY_LIST_ENTRY_ERROR -IDS_POLICY_MANAGED_BOOKMARKS -IDS_POLICY_MANAGED_BOOKMARKS_DEFAULT_NAME IDS_POLICY_NOT_SPECIFIED_ERROR IDS_POLICY_OUT_OF_RANGE_ERROR IDS_POLICY_OVERRIDDEN diff --git a/chrome/browser/android/bookmarks/managed_bookmarks_shim.cc b/chrome/browser/android/bookmarks/managed_bookmarks_shim.cc index 27fd424..644fd2d 100644 --- a/chrome/browser/android/bookmarks/managed_bookmarks_shim.cc +++ b/chrome/browser/android/bookmarks/managed_bookmarks_shim.cc @@ -72,10 +72,10 @@ void ManagedBookmarksShim::Reload() { base::string16 root_node_name; if (domain.empty()) { root_node_name = - l10n_util::GetStringUTF16(IDS_POLICY_MANAGED_BOOKMARKS_DEFAULT_NAME); + l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME); } else { - root_node_name = l10n_util::GetStringFUTF16(IDS_POLICY_MANAGED_BOOKMARKS, - base::UTF8ToUTF16(domain)); + root_node_name = l10n_util::GetStringFUTF16( + IDS_BOOKMARK_BAR_MANAGED_FOLDER_DOMAIN_NAME, base::UTF8ToUTF16(domain)); } root_.reset(new BookmarkPermanentNode(0)); diff --git a/chrome/browser/bookmarks/bookmark_model_factory.cc b/chrome/browser/bookmarks/bookmark_model_factory.cc index fb34ffe..6000d80 100644 --- a/chrome/browser/bookmarks/bookmark_model_factory.cc +++ b/chrome/browser/bookmarks/bookmark_model_factory.cc @@ -88,6 +88,9 @@ void BookmarkModelFactory::RegisterProfilePrefs( registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, new base::ListValue, user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); + registry->RegisterListPref( + prefs::kManagedBookmarks, + user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); } content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc index cbf8a45..6249a2c 100644 --- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc +++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc @@ -9,6 +9,7 @@ #include "base/memory/scoped_vector.h" #include "base/values.h" #include "chrome/browser/net/proxy_policy_handler.h" +#include "chrome/browser/policy/managed_bookmarks_policy_handler.h" #include "chrome/browser/profiles/incognito_mode_policy_handler.h" #include "chrome/browser/search_engines/default_search_policy_handler.h" #include "chrome/common/pref_names.h" @@ -46,10 +47,6 @@ #include "chromeos/dbus/power_policy_controller.h" #endif -#if defined(OS_ANDROID) || defined(OS_IOS) -#include "chrome/browser/policy/managed_bookmarks_policy_handler.h" -#endif - #if !defined(OS_ANDROID) && !defined(OS_IOS) #include "chrome/browser/download/download_dir_policy_handler.h" #endif @@ -525,6 +522,8 @@ scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( new IncognitoModePolicyHandler())); handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( + new ManagedBookmarksPolicyHandler(chrome_schema))); + handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( new ProxyPolicyHandler())); handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( new URLBlacklistPolicyHandler())); @@ -732,10 +731,6 @@ scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList( new ExternalDataPolicyHandler(key::kWallpaperImage))); #endif // defined(OS_CHROMEOS) -#if defined(OS_ANDROID) || defined(OS_IOS) - handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( - new ManagedBookmarksPolicyHandler())); -#endif return handlers.Pass(); } diff --git a/chrome/browser/policy/managed_bookmarks_policy_handler.cc b/chrome/browser/policy/managed_bookmarks_policy_handler.cc index bf493ce..e037067 100644 --- a/chrome/browser/policy/managed_bookmarks_policy_handler.cc +++ b/chrome/browser/policy/managed_bookmarks_policy_handler.cc @@ -7,7 +7,7 @@ #include "base/prefs/pref_value_map.h" #include "base/values.h" #include "chrome/common/net/url_fixer_upper.h" -#include "chrome/common/pref_names.h" +#include "components/bookmarks/common/bookmark_pref_names.h" #include "components/policy/core/browser/policy_error_map.h" #include "components/policy/core/common/policy_map.h" #include "grit/components_strings.h" @@ -16,88 +16,73 @@ namespace policy { -namespace { - -bool GetBookmark(const base::Value& value, - std::string* name, - std::string* url) { - const base::DictionaryValue* dict = NULL; - if (!value.GetAsDictionary(&dict)) - return false; - std::string url_string; - if (!dict->GetStringWithoutPathExpansion(ManagedBookmarksPolicyHandler::kName, - name) || - !dict->GetStringWithoutPathExpansion(ManagedBookmarksPolicyHandler::kUrl, - &url_string)) { - return false; - } - GURL gurl = URLFixerUpper::FixupURL(url_string, ""); - if (!gurl.is_valid()) - return false; - *url = gurl.spec(); - return true; -} - -} // namespace - const char ManagedBookmarksPolicyHandler::kName[] = "name"; const char ManagedBookmarksPolicyHandler::kUrl[] = "url"; +const char ManagedBookmarksPolicyHandler::kChildren[] = "children"; -ManagedBookmarksPolicyHandler::ManagedBookmarksPolicyHandler() - : TypeCheckingPolicyHandler(key::kManagedBookmarks, - base::Value::TYPE_LIST) {} +ManagedBookmarksPolicyHandler::ManagedBookmarksPolicyHandler( + Schema chrome_schema) + : SchemaValidatingPolicyHandler( + key::kManagedBookmarks, + chrome_schema.GetKnownProperty(key::kManagedBookmarks), + SCHEMA_ALLOW_INVALID) {} ManagedBookmarksPolicyHandler::~ManagedBookmarksPolicyHandler() {} -bool ManagedBookmarksPolicyHandler::CheckPolicySettings( - const PolicyMap& policies, - PolicyErrorMap* errors) { - const base::Value* value = NULL; - if (!CheckAndGetValue(policies, errors, &value)) - return false; - - if (!value) - return true; - - const base::ListValue* list = NULL; - value->GetAsList(&list); - DCHECK(list); - - for (base::ListValue::const_iterator it = list->begin(); - it != list->end(); ++it) { - std::string name; - std::string url; - if (!*it || !GetBookmark(**it, &name, &url)) { - size_t index = it - list->begin(); - errors->AddError(policy_name(), index, IDS_POLICY_INVALID_BOOKMARK); - } - } - - return true; -} - void ManagedBookmarksPolicyHandler::ApplyPolicySettings( const PolicyMap& policies, PrefValueMap* prefs) { - const base::Value* value = policies.GetValue(policy_name()); - const base::ListValue* list = NULL; + scoped_ptr<base::Value> value; + if (!CheckAndGetValue(policies, NULL, &value)) + return; + + base::ListValue* list = NULL; if (!value || !value->GetAsList(&list)) return; - base::ListValue* bookmarks = new base::ListValue(); - for (base::ListValue::const_iterator it = list->begin(); - it != list->end(); ++it) { + FilterBookmarks(list); + prefs->SetValue(prefs::kManagedBookmarks, value.release()); +} + +void ManagedBookmarksPolicyHandler::FilterBookmarks(base::ListValue* list) { + // Remove any non-conforming values found. + base::ListValue::iterator it = list->begin(); + while (it != list->end()) { + base::DictionaryValue* dict = NULL; + if (!*it || !(*it)->GetAsDictionary(&dict)) { + it = list->Erase(it, NULL); + continue; + } + std::string name; std::string url; - if (*it && GetBookmark(**it, &name, &url)) { - base::DictionaryValue* dict = new base::DictionaryValue(); - dict->SetString(kName, name); - dict->SetString(kUrl, url); - bookmarks->Append(dict); + base::ListValue* children = NULL; + // Every bookmark must have a name, and then either a URL of a list of + // child bookmarks. + if (!dict->GetString(kName, &name) || + (!dict->GetList(kChildren, &children) && + !dict->GetString(kUrl, &url))) { + it = list->Erase(it, NULL); + continue; } - } - prefs->SetValue(prefs::kManagedBookmarks, bookmarks); + if (children) { + // Ignore the URL if this bookmark has child nodes. + dict->Remove(kUrl, NULL); + FilterBookmarks(children); + } else { + // Make sure the URL is valid before passing a bookmark to the pref. + dict->Remove(kChildren, NULL); + GURL gurl = URLFixerUpper::FixupURL(url, ""); + if (!gurl.is_valid()) { + it = list->Erase(it, NULL); + continue; + } + dict->SetString(kUrl, gurl.spec()); + } + + ++it; + } } } // namespace policy diff --git a/chrome/browser/policy/managed_bookmarks_policy_handler.h b/chrome/browser/policy/managed_bookmarks_policy_handler.h index 13a4f9c..8fcb1c9 100644 --- a/chrome/browser/policy/managed_bookmarks_policy_handler.h +++ b/chrome/browser/policy/managed_bookmarks_policy_handler.h @@ -5,32 +5,31 @@ #ifndef CHROME_BROWSER_POLICY_MANAGED_BOOKMARKS_POLICY_HANDLER_H_ #define CHROME_BROWSER_POLICY_MANAGED_BOOKMARKS_POLICY_HANDLER_H_ -#include <string> - #include "components/policy/core/browser/configuration_policy_handler.h" namespace base { -class Value; +class ListValue; } namespace policy { // Handles the ManagedBookmarks policy. -class ManagedBookmarksPolicyHandler : public TypeCheckingPolicyHandler { +class ManagedBookmarksPolicyHandler : public SchemaValidatingPolicyHandler { public: static const char kName[]; static const char kUrl[]; + static const char kChildren[]; - ManagedBookmarksPolicyHandler(); + explicit ManagedBookmarksPolicyHandler(Schema chrome_schema); virtual ~ManagedBookmarksPolicyHandler(); // ConfigurationPolicyHandler methods: - virtual bool CheckPolicySettings(const PolicyMap& policies, - PolicyErrorMap* errors) OVERRIDE; virtual void ApplyPolicySettings(const PolicyMap& policies, PrefValueMap* prefs) OVERRIDE; private: + void FilterBookmarks(base::ListValue* bookmarks); + DISALLOW_COPY_AND_ASSIGN(ManagedBookmarksPolicyHandler); }; diff --git a/chrome/browser/policy/managed_bookmarks_policy_handler_unittest.cc b/chrome/browser/policy/managed_bookmarks_policy_handler_unittest.cc new file mode 100644 index 0000000..877c56f --- /dev/null +++ b/chrome/browser/policy/managed_bookmarks_policy_handler_unittest.cc @@ -0,0 +1,190 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/json/json_reader.h" +#include "chrome/browser/policy/managed_bookmarks_policy_handler.h" +#include "components/bookmarks/common/bookmark_pref_names.h" +#include "components/policy/core/browser/configuration_policy_pref_store.h" +#include "components/policy/core/browser/configuration_policy_pref_store_test.h" +#include "components/policy/core/common/policy_map.h" +#include "components/policy/core/common/schema.h" +#include "extensions/common/value_builder.h" +#include "policy/policy_constants.h" + +namespace policy { + +class ManagedBookmarksPolicyHandlerTest + : public ConfigurationPolicyPrefStoreTest { + virtual void SetUp() OVERRIDE { + Schema chrome_schema = Schema::Wrap(GetChromeSchemaData()); + handler_list_.AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>( + new ManagedBookmarksPolicyHandler(chrome_schema))); + } +}; + +TEST_F(ManagedBookmarksPolicyHandlerTest, ApplyPolicySettings) { + EXPECT_FALSE(store_->GetValue(prefs::kManagedBookmarks, NULL)); + + PolicyMap policy; + policy.Set(key::kManagedBookmarks, + POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_USER, + base::JSONReader::Read( + "[" + " {" + " \"name\": \"Google\"," + " \"url\": \"google.com\"" + " }," + " {" + " \"name\": \"Empty Folder\"," + " \"children\": []" + " }," + " {" + " \"name\": \"Big Folder\"," + " \"children\": [" + " {" + " \"name\": \"Youtube\"," + " \"url\": \"youtube.com\"" + " }," + " {" + " \"name\": \"Chromium\"," + " \"url\": \"chromium.org\"" + " }," + " {" + " \"name\": \"More Stuff\"," + " \"children\": [" + " {" + " \"name\": \"Bugs\"," + " \"url\": \"crbug.com\"" + " }" + " ]" + " }" + " ]" + " }" + "]"), + NULL); + UpdateProviderPolicy(policy); + const base::Value* pref_value = NULL; + EXPECT_TRUE(store_->GetValue(prefs::kManagedBookmarks, &pref_value)); + ASSERT_TRUE(pref_value); + + scoped_ptr<base::Value> expected( + extensions::ListBuilder() + .Append(extensions::DictionaryBuilder() + .Set("name", "Google") + .Set("url", "http://google.com/")) + .Append(extensions::DictionaryBuilder() + .Set("name", "Empty Folder") + .Set("children", extensions::ListBuilder().Pass())) + .Append(extensions::DictionaryBuilder() + .Set("name", "Big Folder") + .Set("children", extensions::ListBuilder() + .Append(extensions::DictionaryBuilder() + .Set("name", "Youtube") + .Set("url", "http://youtube.com/")) + .Append(extensions::DictionaryBuilder() + .Set("name", "Chromium") + .Set("url", "http://chromium.org/")) + .Append(extensions::DictionaryBuilder() + .Set("name", "More Stuff") + .Set("children", extensions::ListBuilder() + .Append(extensions::DictionaryBuilder() + .Set("name", "Bugs") + .Set("url", "http://crbug.com/") + .Pass()) + .Pass()) + .Pass()) + .Pass()) + .Pass()) + .Build()); + EXPECT_TRUE(pref_value->Equals(expected.get())); +} + +TEST_F(ManagedBookmarksPolicyHandlerTest, WrongPolicyType) { + PolicyMap policy; + // The expected type is base::ListValue, but this policy sets it as an + // unparsed base::StringValue. Any type other than ListValue should fail. + policy.Set(key::kManagedBookmarks, + POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_USER, + new base::StringValue( + "[" + " {" + " \"name\": \"Google\"," + " \"url\": \"google.com\"" + " }," + "]"), + NULL); + UpdateProviderPolicy(policy); + EXPECT_FALSE(store_->GetValue(prefs::kManagedBookmarks, NULL)); +} + +TEST_F(ManagedBookmarksPolicyHandlerTest, UnknownKeys) { + PolicyMap policy; + policy.Set(key::kManagedBookmarks, + POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_USER, + base::JSONReader::Read( + "[" + " {" + " \"name\": \"Google\"," + " \"unknown\": \"should be ignored\"," + " \"url\": \"google.com\"" + " }" + "]"), + NULL); + UpdateProviderPolicy(policy); + const base::Value* pref_value = NULL; + EXPECT_TRUE(store_->GetValue(prefs::kManagedBookmarks, &pref_value)); + ASSERT_TRUE(pref_value); + + scoped_ptr<base::Value> expected( + extensions::ListBuilder() + .Append(extensions::DictionaryBuilder() + .Set("name", "Google") + .Set("url", "http://google.com/")) + .Build()); + EXPECT_TRUE(pref_value->Equals(expected.get())); +} + +TEST_F(ManagedBookmarksPolicyHandlerTest, BadBookmark) { + PolicyMap policy; + policy.Set(key::kManagedBookmarks, + POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_USER, + base::JSONReader::Read( + "[" + " {" + " \"name\": \"Empty\"," + " \"url\": \"\"" + " }," + " {" + " \"name\": \"Invalid type\"," + " \"url\": 4" + " }," + " {" + " \"name\": \"Invalid URL\"," + " \"url\": \"?\"" + " }," + " {" + " \"name\": \"Google\"," + " \"url\": \"google.com\"" + " }" + "]"), + NULL); + UpdateProviderPolicy(policy); + const base::Value* pref_value = NULL; + EXPECT_TRUE(store_->GetValue(prefs::kManagedBookmarks, &pref_value)); + ASSERT_TRUE(pref_value); + + scoped_ptr<base::Value> expected( + extensions::ListBuilder() + .Append(extensions::DictionaryBuilder() + .Set("name", "Google") + .Set("url", "http://google.com/")) + .Build()); + EXPECT_TRUE(pref_value->Equals(expected.get())); +} + +} // namespace policy diff --git a/chrome/browser/policy/profile_policy_connector_factory.cc b/chrome/browser/policy/profile_policy_connector_factory.cc index c7eb67a..8089a3d 100644 --- a/chrome/browser/policy/profile_policy_connector_factory.cc +++ b/chrome/browser/policy/profile_policy_connector_factory.cc @@ -8,9 +8,7 @@ #include "base/memory/singleton.h" #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/common/pref_names.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" -#include "components/pref_registry/pref_registry_syncable.h" #if defined(ENABLE_CONFIGURATION_POLICY) #include "chrome/browser/policy/schema_registry_service.h" @@ -139,15 +137,6 @@ void ProfilePolicyConnectorFactory::BrowserContextDestroyed( BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); } -void ProfilePolicyConnectorFactory::RegisterProfilePrefs( - user_prefs::PrefRegistrySyncable* registry) { -#if defined(OS_ANDROID) || defined(OS_IOS) - registry->RegisterListPref( - prefs::kManagedBookmarks, - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); -#endif -} - void ProfilePolicyConnectorFactory::SetEmptyTestingFactory( content::BrowserContext* context) {} diff --git a/chrome/browser/policy/profile_policy_connector_factory.h b/chrome/browser/policy/profile_policy_connector_factory.h index e036889..46418ae 100644 --- a/chrome/browser/policy/profile_policy_connector_factory.h +++ b/chrome/browser/policy/profile_policy_connector_factory.h @@ -73,8 +73,6 @@ class ProfilePolicyConnectorFactory : public BrowserContextKeyedBaseFactory { content::BrowserContext* context) OVERRIDE; virtual void BrowserContextDestroyed( content::BrowserContext* context) OVERRIDE; - virtual void RegisterProfilePrefs( - user_prefs::PrefRegistrySyncable* registry) OVERRIDE; virtual void SetEmptyTestingFactory( content::BrowserContext* context) OVERRIDE; virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index bc33485..e0e51e5 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2805,8 +2805,6 @@ 'policy_path_parser', ], 'sources!': [ - 'browser/policy/managed_bookmarks_policy_handler.cc', - 'browser/policy/managed_bookmarks_policy_handler.h', 'browser/policy/cloud/user_policy_signin_service_mobile.cc', 'browser/policy/cloud/user_policy_signin_service_mobile.h', ], diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 5894c64..5b46ef6 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -1161,6 +1161,7 @@ 'browser/policy/cloud/user_policy_signin_service_unittest.cc', 'browser/policy/file_selection_dialogs_policy_handler_unittest.cc', 'browser/policy/javascript_policy_handler_unittest.cc', + 'browser/policy/managed_bookmarks_policy_handler_unittest.cc', 'browser/policy/policy_path_parser_unittest.cc', 'browser/policy/url_blacklist_manager_unittest.cc', 'browser/predictors/autocomplete_action_predictor_table_unittest.cc', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 114fb0b..8d55da4 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -476,11 +476,6 @@ const char kDisabledSchemes[] = "protocol.disabled_schemes"; // recorded on Android so that retries aren't attempted on every startup. // Instead the cloud policy registration is retried at least 1 or 3 days later. const char kLastPolicyCheckTime[] = "policy.last_policy_check_time"; - -// A list of bookmarks to include in a Managed Bookmarks root node. Each -// list item is a dictionary containing a "name" and an "url" entry, detailing -// the bookmark name and target URL respectively. -const char kManagedBookmarks[] = "policy.managed_bookmarks"; #endif // Prefix URL for the experimental Instant ZeroSuggest provider. diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 13d9265..0445e24 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -175,7 +175,6 @@ extern const char kAlternateProtocolServers[]; extern const char kDisabledSchemes[]; #if defined(OS_ANDROID) || defined(OS_IOS) extern const char kLastPolicyCheckTime[]; -extern const char kManagedBookmarks[]; #endif extern const char kInstantUIZeroSuggestUrlPrefix[]; extern const char kMultipleProfilePrefMigration[]; diff --git a/components/bookmarks/common/bookmark_pref_names.cc b/components/bookmarks/common/bookmark_pref_names.cc index fc64aa1..6099ee4 100644 --- a/components/bookmarks/common/bookmark_pref_names.cc +++ b/components/bookmarks/common/bookmark_pref_names.cc @@ -10,14 +10,19 @@ namespace prefs { // the bookmark editor. const char kBookmarkEditorExpandedNodes[] = "bookmark_editor.expanded_nodes"; -// Boolean which specifies whether the bookmark bar is visible on all tabs. -const char kShowBookmarkBar[] = "bookmark_bar.show_on_all_tabs"; - // Modifying bookmarks is completely disabled when this is set to false. const char kEditBookmarksEnabled[] = "bookmarks.editing_enabled"; +// A list of bookmarks to include in a Managed Bookmarks root node. Each +// list item is a dictionary containing a "name" and an "url" entry, detailing +// the bookmark name and target URL respectively. +const char kManagedBookmarks[] = "bookmarks.managed_bookmarks"; + // Boolean which specifies whether the apps shortcut is visible on the bookmark // bar. const char kShowAppsShortcutInBookmarkBar[] = "bookmark_bar.show_apps_shortcut"; +// Boolean which specifies whether the bookmark bar is visible on all tabs. +const char kShowBookmarkBar[] = "bookmark_bar.show_on_all_tabs"; + } // namespace prefs diff --git a/components/bookmarks/common/bookmark_pref_names.h b/components/bookmarks/common/bookmark_pref_names.h index 3cc3280..5474e0a 100644 --- a/components/bookmarks/common/bookmark_pref_names.h +++ b/components/bookmarks/common/bookmark_pref_names.h @@ -10,9 +10,10 @@ namespace prefs { extern const char kBookmarkEditorExpandedNodes[]; -extern const char kShowBookmarkBar[]; extern const char kEditBookmarksEnabled[]; +extern const char kManagedBookmarks[]; extern const char kShowAppsShortcutInBookmarkBar[]; +extern const char kShowBookmarkBar[]; } // namespace prefs diff --git a/components/bookmarks_strings.grdp b/components/bookmarks_strings.grdp index e21cf85..326953f 100644 --- a/components/bookmarks_strings.grdp +++ b/components/bookmarks_strings.grdp @@ -28,6 +28,12 @@ <message name="IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME" desc="Name shown in the tree for the other bookmarks folder"> Other bookmarks </message> + <message name="IDS_BOOKMARK_BAR_MANAGED_FOLDER_DOMAIN_NAME" desc="Name shown in the tree for the managed bookmarks folder, when the managed bookmarks come from a domain"> + <ph name="DOMAIN">$1<ex>google.com</ex></ph> bookmarks + </message> + <message name="IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME" desc="Name shown in the tree for the managed bookmarks folder, when the managed bookmarks don't come from a domain"> + Managed bookmarks + </message> </if> <if expr="use_titlecase"> <message name="IDS_BOOKMARK_BAR_MOBILE_FOLDER_NAME" desc="In Title Case: Name shown in the tree for the mobile bookmarks folder"> @@ -36,5 +42,11 @@ <message name="IDS_BOOKMARK_BAR_OTHER_FOLDER_NAME" desc="In Title Case: Name shown in the tree for the other bookmarks folder"> Other Bookmarks </message> + <message name="IDS_BOOKMARK_BAR_MANAGED_FOLDER_DOMAIN_NAME" desc="In Title Case: Name shown in the tree for the managed bookmarks folder, when the managed bookmarks come from a domain"> + <ph name="DOMAIN">$1<ex>google.com</ex></ph> Bookmarks + </message> + <message name="IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME" desc="In Title Case: Name shown in the tree for the managed bookmarks folder, when the managed bookmarks don't come from a domain"> + Managed Bookmarks + </message> </if> </grit-part> diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 744f831..50b442a 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json @@ -6262,13 +6262,23 @@ 'type': 'array', 'items': { 'type': 'object', + 'id': 'BookmarkType', 'properties': { 'name': { 'type': 'string' }, 'url': { 'type': 'string' }, + 'children': { + 'type': 'array', + 'items': { '$ref': 'BookmarkType' }, + }, }, }, }, - 'supported_on': ['android:30-', 'ios:35-'], + 'supported_on': [ + 'android:30-', + 'ios:35-', + 'chrome.*:37-', + 'chrome_os:37-', + ], 'features': { 'dynamic_refresh': True, 'per_profile': True, diff --git a/components/policy/tools/generate_policy_source.py b/components/policy/tools/generate_policy_source.py index 0be012a..99b3342 100755 --- a/components/policy/tools/generate_policy_source.py +++ b/components/policy/tools/generate_policy_source.py @@ -420,7 +420,8 @@ class SchemaNodesGenerator: if schema['type'] == 'array': # Special case for lists of strings, which is a common policy type. - if schema['items']['type'] == 'string': + # The 'type' may be missing if the schema has a '$ref' attribute. + if schema['items'].get('type', '') == 'string': return self.GetStringList() return self.AppendSchema('TYPE_LIST', self.GenerateAndCollectID(schema['items'], 'items of ' + name)) diff --git a/components/policy_strings.grdp b/components/policy_strings.grdp index 502b5b7..de2e5eb 100644 --- a/components/policy_strings.grdp +++ b/components/policy_strings.grdp @@ -298,16 +298,7 @@ <message name="IDS_POLICY_LEVEL_MANDATORY" desc="Text displayed in the Level column when a policy is mandatory."> Mandatory </message> - - <if expr="is_android or is_ios"> - <message name="IDS_POLICY_MANAGED_BOOKMARKS" desc="Mobile: name of the managed bookmarks folder"> - <ph name="DOMAIN">$1<ex>google.com</ex></ph> bookmarks - </message> - <message name="IDS_POLICY_MANAGED_BOOKMARKS_DEFAULT_NAME" desc="Mobile: name of the managed bookmarks folder when the management domain can't be determined."> - Managed bookmarks - </message> - <message name="IDS_POLICY_INVALID_BOOKMARK" desc="Text displayed in the status column when an entry of the ManagedBookmarks policy is not a valid bookmark."> - Ignored invalid bookmark at index <ph name="ENTRY_INDEX">$1<ex>3</ex></ph> - </message> - </if> + <message name="IDS_POLICY_INVALID_BOOKMARK" desc="Text displayed in the status column when an entry of the ManagedBookmarks policy is not a valid bookmark."> + Ignored invalid bookmark at index <ph name="ENTRY_INDEX">$1<ex>3</ex></ph> + </message> </grit-part> |