| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 engagement_info.push_back(std::move(origin_info)); | 48 engagement_info.push_back(std::move(origin_info)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 callback.Run(std::move(engagement_info)); | 51 callback.Run(std::move(engagement_info)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SetSiteEngagementScoreForOrigin(const mojo::String& origin, | 54 void SetSiteEngagementScoreForOrigin(const mojo::String& origin, |
| 55 double score) override { | 55 double score) override { |
| 56 GURL origin_gurl(origin.get()); | 56 GURL origin_gurl(origin.get()); |
| 57 if (!origin_gurl.is_valid() || score < 0 || | 57 if (!origin_gurl.is_valid() || score < 0 || |
| 58 score > SiteEngagementScore::kMaxPoints || isnan(score)) { | 58 score > SiteEngagementScore::kMaxPoints || std::isnan(score)) { |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 | 61 |
| 62 SiteEngagementService* service = SiteEngagementService::Get(profile_); | 62 SiteEngagementService* service = SiteEngagementService::Get(profile_); |
| 63 service->ResetScoreForURL(origin_gurl, score); | 63 service->ResetScoreForURL(origin_gurl, score); |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // The Profile* handed to us in our constructor. | 67 // The Profile* handed to us in our constructor. |
| 68 Profile* profile_; | 68 Profile* profile_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 92 content::WebUIDataSource::Add(profile, source.release()); | 92 content::WebUIDataSource::Add(profile, source.release()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 SiteEngagementUI::~SiteEngagementUI() {} | 95 SiteEngagementUI::~SiteEngagementUI() {} |
| 96 | 96 |
| 97 void SiteEngagementUI::BindUIHandler( | 97 void SiteEngagementUI::BindUIHandler( |
| 98 mojo::InterfaceRequest<SiteEngagementUIHandler> request) { | 98 mojo::InterfaceRequest<SiteEngagementUIHandler> request) { |
| 99 ui_handler_.reset(new SiteEngagementUIHandlerImpl( | 99 ui_handler_.reset(new SiteEngagementUIHandlerImpl( |
| 100 Profile::FromWebUI(web_ui()), std::move(request))); | 100 Profile::FromWebUI(web_ui()), std::move(request))); |
| 101 } | 101 } |
| OLD | NEW |