OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/snippets_internals_message_handler.h" | 5 #include "chrome/browser/ui/webui/snippets_internals_message_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 | 313 |
314 SendContentSuggestions(); | 314 SendContentSuggestions(); |
315 } | 315 } |
316 | 316 |
317 void SnippetsInternalsMessageHandler::SendClassification() { | 317 void SnippetsInternalsMessageHandler::SendClassification() { |
318 web_ui()->CallJavascriptFunctionUnsafe( | 318 web_ui()->CallJavascriptFunctionUnsafe( |
319 "chrome.SnippetsInternals.receiveClassification", | 319 "chrome.SnippetsInternals.receiveClassification", |
320 base::StringValue(content_suggestions_service_->user_classifier() | 320 base::StringValue(content_suggestions_service_->user_classifier() |
321 ->GetUserClassDescriptionForDebugging()), | 321 ->GetUserClassDescriptionForDebugging()), |
322 base::FundamentalValue( | 322 base::Value( |
323 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( | 323 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( |
324 UserClassifier::Metric::NTP_OPENED)), | 324 UserClassifier::Metric::NTP_OPENED)), |
325 base::FundamentalValue( | 325 base::Value( |
326 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( | 326 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( |
327 UserClassifier::Metric::SUGGESTIONS_SHOWN)), | 327 UserClassifier::Metric::SUGGESTIONS_SHOWN)), |
328 base::FundamentalValue( | 328 base::Value( |
329 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( | 329 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( |
330 UserClassifier::Metric::SUGGESTIONS_USED))); | 330 UserClassifier::Metric::SUGGESTIONS_USED))); |
331 } | 331 } |
332 | 332 |
333 void SnippetsInternalsMessageHandler::SendContentSuggestions() { | 333 void SnippetsInternalsMessageHandler::SendContentSuggestions() { |
334 std::unique_ptr<base::ListValue> categories_list(new base::ListValue); | 334 std::unique_ptr<base::ListValue> categories_list(new base::ListValue); |
335 | 335 |
336 int index = 0; | 336 int index = 0; |
337 for (Category category : content_suggestions_service_->GetCategories()) { | 337 for (Category category : content_suggestions_service_->GetCategories()) { |
338 CategoryStatus status = | 338 CategoryStatus status = |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 396 |
397 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( | 397 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( |
398 Category category, | 398 Category category, |
399 std::vector<ContentSuggestion> dismissed_suggestions) { | 399 std::vector<ContentSuggestion> dismissed_suggestions) { |
400 if (dismissed_state_[category] == DismissedState::HIDDEN) | 400 if (dismissed_state_[category] == DismissedState::HIDDEN) |
401 return; | 401 return; |
402 dismissed_suggestions_[category] = std::move(dismissed_suggestions); | 402 dismissed_suggestions_[category] = std::move(dismissed_suggestions); |
403 dismissed_state_[category] = DismissedState::VISIBLE; | 403 dismissed_state_[category] = DismissedState::VISIBLE; |
404 SendContentSuggestions(); | 404 SendContentSuggestions(); |
405 } | 405 } |
OLD | NEW |