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/bookmarks/chrome_bookmark_client.h" | 5 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/favicon/favicon_changed_details.h" | 9 #include "chrome/browser/favicon/favicon_changed_details.h" |
10 #include "chrome/browser/favicon/favicon_service.h" | 10 #include "chrome/browser/favicon/favicon_service.h" |
11 #include "chrome/browser/favicon/favicon_service_factory.h" | 11 #include "chrome/browser/favicon/favicon_service_factory.h" |
12 #include "chrome/browser/history/history_service.h" | 12 #include "chrome/browser/history/history_service.h" |
13 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
14 #include "chrome/browser/history/url_database.h" | 14 #include "chrome/browser/history/url_database.h" |
| 15 #include "chrome/browser/policy/profile_policy_connector.h" |
| 16 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
16 #include "components/bookmarks/browser/bookmark_model.h" | 18 #include "components/bookmarks/browser/bookmark_model.h" |
17 #include "components/bookmarks/browser/bookmark_node.h" | 19 #include "components/bookmarks/browser/bookmark_node.h" |
18 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/user_metrics.h" | 22 #include "content/public/browser/user_metrics.h" |
| 23 #include "policy/policy_constants.h" |
21 | 24 |
22 namespace { | 25 namespace { |
23 | 26 |
24 void NotifyHistoryOfRemovedURLs(Profile* profile, | 27 void NotifyHistoryOfRemovedURLs(Profile* profile, |
25 const std::set<GURL>& removed_urls) { | 28 const std::set<GURL>& removed_urls) { |
26 HistoryService* history_service = | 29 HistoryService* history_service = |
27 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); | 30 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); |
28 if (history_service) | 31 if (history_service) |
29 history_service->URLsNoLongerBookmarked(removed_urls); | 32 history_service->URLsNoLongerBookmarked(removed_urls); |
30 } | 33 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 102 } |
100 } | 103 } |
101 | 104 |
102 void ChromeBookmarkClient::RecordAction(const base::UserMetricsAction& action) { | 105 void ChromeBookmarkClient::RecordAction(const base::UserMetricsAction& action) { |
103 content::RecordAction(action); | 106 content::RecordAction(action); |
104 } | 107 } |
105 | 108 |
106 bool ChromeBookmarkClient::IsPermanentNodeVisible(int node_type) { | 109 bool ChromeBookmarkClient::IsPermanentNodeVisible(int node_type) { |
107 DCHECK(node_type == BookmarkNode::BOOKMARK_BAR || | 110 DCHECK(node_type == BookmarkNode::BOOKMARK_BAR || |
108 node_type == BookmarkNode::OTHER_NODE || | 111 node_type == BookmarkNode::OTHER_NODE || |
109 node_type == BookmarkNode::MOBILE); | 112 node_type == BookmarkNode::MOBILE || |
| 113 node_type == BookmarkNode::MANAGED); |
| 114 if (node_type == BookmarkNode::MANAGED) |
| 115 return false; |
110 #if !defined(OS_IOS) | 116 #if !defined(OS_IOS) |
111 return node_type != BookmarkNode::MOBILE; | 117 return node_type != BookmarkNode::MOBILE; |
112 #else | 118 #else |
113 return node_type == BookmarkNode::MOBILE; | 119 return node_type == BookmarkNode::MOBILE; |
114 #endif | 120 #endif |
115 } | 121 } |
116 | 122 |
| 123 std::string ChromeBookmarkClient::GetManagedBookmarksDomain() { |
| 124 policy::ProfilePolicyConnector* connector = |
| 125 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); |
| 126 if (connector->IsPolicyFromCloudPolicy(policy::key::kManagedBookmarks)) |
| 127 return connector->GetManagementDomain(); |
| 128 return std::string(); |
| 129 } |
| 130 |
117 void ChromeBookmarkClient::Observe( | 131 void ChromeBookmarkClient::Observe( |
118 int type, | 132 int type, |
119 const content::NotificationSource& source, | 133 const content::NotificationSource& source, |
120 const content::NotificationDetails& details) { | 134 const content::NotificationDetails& details) { |
121 switch (type) { | 135 switch (type) { |
122 case chrome::NOTIFICATION_FAVICON_CHANGED: { | 136 case chrome::NOTIFICATION_FAVICON_CHANGED: { |
123 content::Details<FaviconChangedDetails> favicon_details(details); | 137 content::Details<FaviconChangedDetails> favicon_details(details); |
124 model_->OnFaviconChanged(favicon_details->urls); | 138 model_->OnFaviconChanged(favicon_details->urls); |
125 break; | 139 break; |
126 } | 140 } |
(...skipping 18 matching lines...) Expand all Loading... |
145 const BookmarkNode* node, | 159 const BookmarkNode* node, |
146 const std::set<GURL>& removed_urls) { | 160 const std::set<GURL>& removed_urls) { |
147 NotifyHistoryOfRemovedURLs(profile_, removed_urls); | 161 NotifyHistoryOfRemovedURLs(profile_, removed_urls); |
148 } | 162 } |
149 | 163 |
150 void ChromeBookmarkClient::BookmarkAllNodesRemoved( | 164 void ChromeBookmarkClient::BookmarkAllNodesRemoved( |
151 BookmarkModel* model, | 165 BookmarkModel* model, |
152 const std::set<GURL>& removed_urls) { | 166 const std::set<GURL>& removed_urls) { |
153 NotifyHistoryOfRemovedURLs(profile_, removed_urls); | 167 NotifyHistoryOfRemovedURLs(profile_, removed_urls); |
154 } | 168 } |
OLD | NEW |