| 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 "base/prefs/pref_value_map.h" | 7 #include "base/prefs/pref_value_map.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "components/bookmarks/common/bookmark_pref_names.h" | 9 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 10 #include "components/policy/core/browser/managed_bookmarks_tracker.h" | 10 #include "components/policy/core/browser/managed_bookmarks_tracker.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 PrefValueMap* prefs) { | 30 PrefValueMap* prefs) { |
| 31 scoped_ptr<base::Value> value; | 31 scoped_ptr<base::Value> value; |
| 32 if (!CheckAndGetValue(policies, NULL, &value)) | 32 if (!CheckAndGetValue(policies, NULL, &value)) |
| 33 return; | 33 return; |
| 34 | 34 |
| 35 base::ListValue* list = NULL; | 35 base::ListValue* list = NULL; |
| 36 if (!value || !value->GetAsList(&list)) | 36 if (!value || !value->GetAsList(&list)) |
| 37 return; | 37 return; |
| 38 | 38 |
| 39 FilterBookmarks(list); | 39 FilterBookmarks(list); |
| 40 prefs->SetValue(prefs::kManagedBookmarks, value.release()); | 40 prefs->SetValue(bookmarks::prefs::kManagedBookmarks, value.release()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ManagedBookmarksPolicyHandler::FilterBookmarks(base::ListValue* list) { | 43 void ManagedBookmarksPolicyHandler::FilterBookmarks(base::ListValue* list) { |
| 44 // Remove any non-conforming values found. | 44 // Remove any non-conforming values found. |
| 45 base::ListValue::iterator it = list->begin(); | 45 base::ListValue::iterator it = list->begin(); |
| 46 while (it != list->end()) { | 46 while (it != list->end()) { |
| 47 base::DictionaryValue* dict = NULL; | 47 base::DictionaryValue* dict = NULL; |
| 48 if (!*it || !(*it)->GetAsDictionary(&dict)) { | 48 if (!*it || !(*it)->GetAsDictionary(&dict)) { |
| 49 it = list->Erase(it, NULL); | 49 it = list->Erase(it, NULL); |
| 50 continue; | 50 continue; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 75 continue; | 75 continue; |
| 76 } | 76 } |
| 77 dict->SetString(ManagedBookmarksTracker::kUrl, gurl.spec()); | 77 dict->SetString(ManagedBookmarksTracker::kUrl, gurl.spec()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 ++it; | 80 ++it; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace policy | 84 } // namespace policy |
| OLD | NEW |