| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/policy/managed_bookmarks_policy_handler.h" | 5 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/prefs/pref_value_map.h" | 9 #include "base/prefs/pref_value_map.h" |
| 8 #include "base/values.h" | 10 #include "base/values.h" |
| 9 #include "components/bookmarks/common/bookmark_pref_names.h" | 11 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 10 #include "components/bookmarks/managed/managed_bookmarks_tracker.h" | 12 #include "components/bookmarks/managed/managed_bookmarks_tracker.h" |
| 11 #include "components/policy/core/browser/policy_error_map.h" | 13 #include "components/policy/core/browser/policy_error_map.h" |
| 12 #include "components/policy/core/common/policy_map.h" | 14 #include "components/policy/core/common/policy_map.h" |
| 13 #include "components/url_formatter/url_fixer.h" | 15 #include "components/url_formatter/url_fixer.h" |
| 14 #include "policy/policy_constants.h" | 16 #include "policy/policy_constants.h" |
| 15 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 16 | 18 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 32 PrefValueMap* prefs) { | 34 PrefValueMap* prefs) { |
| 33 scoped_ptr<base::Value> value; | 35 scoped_ptr<base::Value> value; |
| 34 if (!CheckAndGetValue(policies, NULL, &value)) | 36 if (!CheckAndGetValue(policies, NULL, &value)) |
| 35 return; | 37 return; |
| 36 | 38 |
| 37 base::ListValue* list = NULL; | 39 base::ListValue* list = NULL; |
| 38 if (!value || !value->GetAsList(&list)) | 40 if (!value || !value->GetAsList(&list)) |
| 39 return; | 41 return; |
| 40 | 42 |
| 41 FilterBookmarks(list); | 43 FilterBookmarks(list); |
| 42 prefs->SetValue(bookmarks::prefs::kManagedBookmarks, value.Pass()); | 44 prefs->SetValue(bookmarks::prefs::kManagedBookmarks, std::move(value)); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void ManagedBookmarksPolicyHandler::FilterBookmarks(base::ListValue* list) { | 47 void ManagedBookmarksPolicyHandler::FilterBookmarks(base::ListValue* list) { |
| 46 // Remove any non-conforming values found. | 48 // Remove any non-conforming values found. |
| 47 base::ListValue::iterator it = list->begin(); | 49 base::ListValue::iterator it = list->begin(); |
| 48 while (it != list->end()) { | 50 while (it != list->end()) { |
| 49 base::DictionaryValue* dict = NULL; | 51 base::DictionaryValue* dict = NULL; |
| 50 if (!*it || !(*it)->GetAsDictionary(&dict)) { | 52 if (!*it || !(*it)->GetAsDictionary(&dict)) { |
| 51 it = list->Erase(it, NULL); | 53 it = list->Erase(it, NULL); |
| 52 continue; | 54 continue; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 77 continue; | 79 continue; |
| 78 } | 80 } |
| 79 dict->SetString(ManagedBookmarksTracker::kUrl, gurl.spec()); | 81 dict->SetString(ManagedBookmarksTracker::kUrl, gurl.spec()); |
| 80 } | 82 } |
| 81 | 83 |
| 82 ++it; | 84 ++it; |
| 83 } | 85 } |
| 84 } | 86 } |
| 85 | 87 |
| 86 } // namespace policy | 88 } // namespace policy |
| OLD | NEW |