| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/ui/webui/engagement/site_engagement_ui.h" | 5 #include "chrome/browser/ui/webui/engagement/site_engagement_ui.h" |
| 6 | 6 |
| 7 #include "chrome/browser/engagement/site_engagement_service.h" | 7 #include "chrome/browser/engagement/site_engagement_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "content/public/browser/web_ui.h" | 10 #include "content/public/browser/web_ui.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 ~SiteEngagementUIHandlerImpl() override {} | 31 ~SiteEngagementUIHandlerImpl() override {} |
| 32 | 32 |
| 33 // SiteEngagementUIHandler overrides: | 33 // SiteEngagementUIHandler overrides: |
| 34 void GetSiteEngagementInfo( | 34 void GetSiteEngagementInfo( |
| 35 const GetSiteEngagementInfoCallback& callback) override { | 35 const GetSiteEngagementInfoCallback& callback) override { |
| 36 mojo::Array<SiteEngagementInfoPtr> engagement_info(0); | 36 mojo::Array<SiteEngagementInfoPtr> engagement_info(0); |
| 37 | 37 |
| 38 SiteEngagementService* service = SiteEngagementService::Get(profile_); | 38 SiteEngagementService* service = SiteEngagementService::Get(profile_); |
| 39 | 39 |
| 40 for (const std::pair<GURL, int>& info : service->GetScoreMap()) { | 40 for (const std::pair<GURL, double>& info : service->GetScoreMap()) { |
| 41 SiteEngagementInfoPtr origin_info(SiteEngagementInfo::New()); | 41 SiteEngagementInfoPtr origin_info(SiteEngagementInfo::New()); |
| 42 origin_info->origin = mojo::String::From(info.first); | 42 origin_info->origin = mojo::String::From(info.first); |
| 43 origin_info->score = info.second; | 43 origin_info->score = info.second; |
| 44 engagement_info.push_back(origin_info.Pass()); | 44 engagement_info.push_back(origin_info.Pass()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 callback.Run(engagement_info.Pass()); | 47 callback.Run(engagement_info.Pass()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 79 IDR_SITE_ENGAGEMENT_MOJO_JS); | 79 IDR_SITE_ENGAGEMENT_MOJO_JS); |
| 80 } | 80 } |
| 81 | 81 |
| 82 SiteEngagementUI::~SiteEngagementUI() {} | 82 SiteEngagementUI::~SiteEngagementUI() {} |
| 83 | 83 |
| 84 void SiteEngagementUI::BindUIHandler( | 84 void SiteEngagementUI::BindUIHandler( |
| 85 mojo::InterfaceRequest<SiteEngagementUIHandler> request) { | 85 mojo::InterfaceRequest<SiteEngagementUIHandler> request) { |
| 86 // SiteEngagementUIHandlerImpl deletes itself when the pipe is closed. | 86 // SiteEngagementUIHandlerImpl deletes itself when the pipe is closed. |
| 87 new SiteEngagementUIHandlerImpl(Profile::FromWebUI(web_ui()), request.Pass()); | 87 new SiteEngagementUIHandlerImpl(Profile::FromWebUI(web_ui()), request.Pass()); |
| 88 } | 88 } |
| OLD | NEW |