OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/android/bookmarks/managed_bookmarks_shim.h" | 5 #include "chrome/browser/android/bookmarks/managed_bookmarks_shim.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/policy/managed_bookmarks_policy_handler.h" | |
12 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
13 #include "components/bookmarks/browser/bookmark_model.h" | 12 #include "components/bookmarks/browser/bookmark_model.h" |
| 13 #include "components/policy/core/browser/managed_bookmarks_tracker.h" |
14 #include "google_apis/gaia/gaia_auth_util.h" | 14 #include "google_apis/gaia/gaia_auth_util.h" |
15 #include "grit/components_strings.h" | 15 #include "grit/components_strings.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 | 17 |
18 using policy::ManagedBookmarksPolicyHandler; | |
19 | |
20 ManagedBookmarksShim::ManagedBookmarksShim(PrefService* prefs) | 18 ManagedBookmarksShim::ManagedBookmarksShim(PrefService* prefs) |
21 : prefs_(prefs) { | 19 : prefs_(prefs) { |
22 registrar_.Init(prefs_); | 20 registrar_.Init(prefs_); |
23 registrar_.Add( | 21 registrar_.Add( |
24 prefs::kManagedBookmarks, | 22 prefs::kManagedBookmarks, |
25 base::Bind(&ManagedBookmarksShim::Reload, base::Unretained(this))); | 23 base::Bind(&ManagedBookmarksShim::Reload, base::Unretained(this))); |
26 Reload(); | 24 Reload(); |
27 } | 25 } |
28 | 26 |
29 ManagedBookmarksShim::~ManagedBookmarksShim() {} | 27 ManagedBookmarksShim::~ManagedBookmarksShim() {} |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 for (base::ListValue::const_iterator it = list->begin(); | 85 for (base::ListValue::const_iterator it = list->begin(); |
88 it != list->end(); ++it) { | 86 it != list->end(); ++it) { |
89 const base::DictionaryValue* dict = NULL; | 87 const base::DictionaryValue* dict = NULL; |
90 if (!*it || !(*it)->GetAsDictionary(&dict)) { | 88 if (!*it || !(*it)->GetAsDictionary(&dict)) { |
91 NOTREACHED(); | 89 NOTREACHED(); |
92 continue; | 90 continue; |
93 } | 91 } |
94 | 92 |
95 base::string16 name; | 93 base::string16 name; |
96 std::string url; | 94 std::string url; |
97 if (!dict->GetString(ManagedBookmarksPolicyHandler::kName, &name) || | 95 if (!dict->GetString(policy::ManagedBookmarksTracker::kName, &name) || |
98 !dict->GetString(ManagedBookmarksPolicyHandler::kUrl, &url)) { | 96 !dict->GetString(policy::ManagedBookmarksTracker::kUrl, &url)) { |
99 NOTREACHED(); | 97 NOTREACHED(); |
100 continue; | 98 continue; |
101 } | 99 } |
102 | 100 |
103 BookmarkNode* node = new BookmarkNode(id++, GURL(url)); | 101 BookmarkNode* node = new BookmarkNode(id++, GURL(url)); |
104 node->set_type(BookmarkNode::URL); | 102 node->set_type(BookmarkNode::URL); |
105 node->SetTitle(name); | 103 node->SetTitle(name); |
106 root_->Add(node, root_->child_count()); | 104 root_->Add(node, root_->child_count()); |
107 } | 105 } |
108 } | 106 } |
109 | 107 |
110 FOR_EACH_OBSERVER(Observer, observers_, OnManagedBookmarksChanged()); | 108 FOR_EACH_OBSERVER(Observer, observers_, OnManagedBookmarksChanged()); |
111 } | 109 } |
OLD | NEW |