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

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

Issue 1975723002: Reduce the site engagement service public interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Push messaging now uses engagement Created 4 years, 7 months 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/tab_helpers.cc ('k') | chrome/chrome_browser.gypi » ('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 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 engagement_info.push_back(std::move(origin_info)); 50 engagement_info.push_back(std::move(origin_info));
51 } 51 }
52 52
53 callback.Run(std::move(engagement_info)); 53 callback.Run(std::move(engagement_info));
54 } 54 }
55 55
56 void SetSiteEngagementScoreForOrigin(const mojo::String& origin, 56 void SetSiteEngagementScoreForOrigin(const mojo::String& origin,
57 double score) override { 57 double score) override {
58 GURL origin_gurl(origin.get()); 58 GURL origin_gurl(origin.get());
59 if (!origin_gurl.is_valid() || score < 0 || 59 if (!origin_gurl.is_valid() || score < 0 ||
60 score > SiteEngagementScore::kMaxPoints || std::isnan(score)) { 60 score > SiteEngagementService::GetMaxPoints() || std::isnan(score)) {
61 return; 61 return;
62 } 62 }
63 63
64 SiteEngagementService* service = SiteEngagementService::Get(profile_); 64 SiteEngagementService* service = SiteEngagementService::Get(profile_);
65 service->ResetScoreForURL(origin_gurl, score); 65 service->ResetScoreForURL(origin_gurl, score);
66 } 66 }
67 67
68 private: 68 private:
69 // The Profile* handed to us in our constructor. 69 // The Profile* handed to us in our constructor.
70 Profile* profile_; 70 Profile* profile_;
(...skipping 23 matching lines...) Expand all
94 content::WebUIDataSource::Add(profile, source.release()); 94 content::WebUIDataSource::Add(profile, source.release());
95 } 95 }
96 96
97 SiteEngagementUI::~SiteEngagementUI() {} 97 SiteEngagementUI::~SiteEngagementUI() {}
98 98
99 void SiteEngagementUI::BindUIHandler( 99 void SiteEngagementUI::BindUIHandler(
100 mojo::InterfaceRequest<mojom::SiteEngagementUIHandler> request) { 100 mojo::InterfaceRequest<mojom::SiteEngagementUIHandler> request) {
101 ui_handler_.reset(new SiteEngagementUIHandlerImpl( 101 ui_handler_.reset(new SiteEngagementUIHandlerImpl(
102 Profile::FromWebUI(web_ui()), std::move(request))); 102 Profile::FromWebUI(web_ui()), std::move(request)));
103 } 103 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_helpers.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698