Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/ui/webui/engagement/site_engagement_ui.cc

Issue 2481483002: Mojo C++ bindings: make chrome/browser/ui/webui mojom target use STL types. (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/engagement/BUILD.gn ('k') | chrome/browser/ui/webui/omnibox/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <cmath> 7 #include <cmath>
8 #include <utility> 8 #include <utility>
9 #include <vector>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "chrome/browser/engagement/site_engagement_service.h" 12 #include "chrome/browser/engagement/site_engagement_service.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 #include "chrome/grit/browser_resources.h" 15 #include "chrome/grit/browser_resources.h"
15 #include "content/public/browser/web_ui.h" 16 #include "content/public/browser/web_ui.h"
16 #include "content/public/browser/web_ui_controller.h" 17 #include "content/public/browser/web_ui_controller.h"
17 #include "content/public/browser/web_ui_data_source.h" 18 #include "content/public/browser/web_ui_data_source.h"
18 #include "mojo/public/cpp/bindings/binding.h" 19 #include "mojo/public/cpp/bindings/binding.h"
(...skipping 11 matching lines...) Expand all
30 mojo::InterfaceRequest<mojom::SiteEngagementUIHandler> request) 31 mojo::InterfaceRequest<mojom::SiteEngagementUIHandler> request)
31 : profile_(profile), binding_(this, std::move(request)) { 32 : profile_(profile), binding_(this, std::move(request)) {
32 DCHECK(profile_); 33 DCHECK(profile_);
33 } 34 }
34 35
35 ~SiteEngagementUIHandlerImpl() override {} 36 ~SiteEngagementUIHandlerImpl() override {}
36 37
37 // mojom::SiteEngagementUIHandler overrides: 38 // mojom::SiteEngagementUIHandler overrides:
38 void GetSiteEngagementInfo( 39 void GetSiteEngagementInfo(
39 const GetSiteEngagementInfoCallback& callback) override { 40 const GetSiteEngagementInfoCallback& callback) override {
40 mojo::Array<mojom::SiteEngagementInfoPtr> engagement_info; 41 SiteEngagementService* service = SiteEngagementService::Get(profile_);
42 std::map<GURL, double> score_map = service->GetScoreMap();
41 43
42 SiteEngagementService* service = SiteEngagementService::Get(profile_); 44 std::vector<mojom::SiteEngagementInfoPtr> engagement_info;
43 45 engagement_info.reserve(score_map.size());
44 for (const std::pair<GURL, double>& info : service->GetScoreMap()) { 46 for (const auto& info : score_map) {
45 mojom::SiteEngagementInfoPtr origin_info( 47 mojom::SiteEngagementInfoPtr origin_info(
46 mojom::SiteEngagementInfo::New()); 48 mojom::SiteEngagementInfo::New());
47 origin_info->origin = info.first; 49 origin_info->origin = info.first;
48 origin_info->score = info.second; 50 origin_info->score = info.second;
49 engagement_info.push_back(std::move(origin_info)); 51 engagement_info.push_back(std::move(origin_info));
50 } 52 }
51 53
52 callback.Run(std::move(engagement_info)); 54 callback.Run(std::move(engagement_info));
53 } 55 }
54 56
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source.release()); 91 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source.release());
90 } 92 }
91 93
92 SiteEngagementUI::~SiteEngagementUI() {} 94 SiteEngagementUI::~SiteEngagementUI() {}
93 95
94 void SiteEngagementUI::BindUIHandler( 96 void SiteEngagementUI::BindUIHandler(
95 mojo::InterfaceRequest<mojom::SiteEngagementUIHandler> request) { 97 mojo::InterfaceRequest<mojom::SiteEngagementUIHandler> request) {
96 ui_handler_.reset(new SiteEngagementUIHandlerImpl( 98 ui_handler_.reset(new SiteEngagementUIHandlerImpl(
97 Profile::FromWebUI(web_ui()), std::move(request))); 99 Profile::FromWebUI(web_ui()), std::move(request)));
98 } 100 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/engagement/BUILD.gn ('k') | chrome/browser/ui/webui/omnibox/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698