OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/engagement/site_engagement_ui_handler.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "chrome/browser/engagement/site_engagement_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "mojo/common/url_type_converters.h" |
| 12 |
| 13 // Implementation of SiteEngagementUIHandler that gets information from the |
| 14 // SiteEngagementService to provide data for the WebUI. |
| 15 SiteEngagementUIHandlerImpl::SiteEngagementUIHandlerImpl(content::WebUI* web_ui) |
| 16 : profile_(Profile::FromWebUI(web_ui)) { |
| 17 DCHECK(profile_); |
| 18 } |
| 19 |
| 20 SiteEngagementUIHandlerImpl::~SiteEngagementUIHandlerImpl() {} |
| 21 |
| 22 // SiteEngagementUIHandler overrides: |
| 23 void SiteEngagementUIHandlerImpl::GetSiteEngagementInfo( |
| 24 const GetSiteEngagementInfoCallback& callback) { |
| 25 mojo::Array<SiteEngagementInfoPtr> engagement_info(0); |
| 26 |
| 27 SiteEngagementService* service = SiteEngagementService::Get(profile_); |
| 28 |
| 29 for (const std::pair<GURL, double>& info : service->GetScoreMap()) { |
| 30 SiteEngagementInfoPtr origin_info(SiteEngagementInfo::New()); |
| 31 origin_info->origin = mojo::String::From(info.first); |
| 32 origin_info->score = info.second; |
| 33 engagement_info.push_back(std::move(origin_info)); |
| 34 } |
| 35 |
| 36 callback.Run(std::move(engagement_info)); |
| 37 } |
OLD | NEW |