| 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 <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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |