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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 321 } |
322 | 322 |
323 SendContentSuggestions(); | 323 SendContentSuggestions(); |
324 } | 324 } |
325 | 325 |
326 void SnippetsInternalsMessageHandler::SendClassification() { | 326 void SnippetsInternalsMessageHandler::SendClassification() { |
327 web_ui()->CallJavascriptFunctionUnsafe( | 327 web_ui()->CallJavascriptFunctionUnsafe( |
328 "chrome.SnippetsInternals.receiveClassification", | 328 "chrome.SnippetsInternals.receiveClassification", |
329 base::StringValue(content_suggestions_service_->user_classifier() | 329 base::StringValue(content_suggestions_service_->user_classifier() |
330 ->GetUserClassDescriptionForDebugging()), | 330 ->GetUserClassDescriptionForDebugging()), |
331 base::FundamentalValue( | 331 base::Value( |
332 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( | 332 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( |
333 UserClassifier::Metric::NTP_OPENED)), | 333 UserClassifier::Metric::NTP_OPENED)), |
334 base::FundamentalValue( | 334 base::Value( |
335 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( | 335 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( |
336 UserClassifier::Metric::SUGGESTIONS_SHOWN)), | 336 UserClassifier::Metric::SUGGESTIONS_SHOWN)), |
337 base::FundamentalValue( | 337 base::Value( |
338 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( | 338 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( |
339 UserClassifier::Metric::SUGGESTIONS_USED))); | 339 UserClassifier::Metric::SUGGESTIONS_USED))); |
340 } | 340 } |
341 | 341 |
342 void SnippetsInternalsMessageHandler:: | 342 void SnippetsInternalsMessageHandler:: |
343 SendLastRemoteSuggestionsBackgroundFetchTime() { | 343 SendLastRemoteSuggestionsBackgroundFetchTime() { |
344 base::Time time = base::Time::FromInternalValue(pref_service_->GetInt64( | 344 base::Time time = base::Time::FromInternalValue(pref_service_->GetInt64( |
345 ntp_snippets::prefs::kLastSuccessfulBackgroundFetchTime)); | 345 ntp_snippets::prefs::kLastSuccessfulBackgroundFetchTime)); |
346 web_ui()->CallJavascriptFunctionUnsafe( | 346 web_ui()->CallJavascriptFunctionUnsafe( |
347 "chrome.SnippetsInternals." | 347 "chrome.SnippetsInternals." |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( | 418 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( |
419 Category category, | 419 Category category, |
420 std::vector<ContentSuggestion> dismissed_suggestions) { | 420 std::vector<ContentSuggestion> dismissed_suggestions) { |
421 if (dismissed_state_[category] == DismissedState::HIDDEN) { | 421 if (dismissed_state_[category] == DismissedState::HIDDEN) { |
422 return; | 422 return; |
423 } | 423 } |
424 dismissed_suggestions_[category] = std::move(dismissed_suggestions); | 424 dismissed_suggestions_[category] = std::move(dismissed_suggestions); |
425 dismissed_state_[category] = DismissedState::VISIBLE; | 425 dismissed_state_[category] = DismissedState::VISIBLE; |
426 SendContentSuggestions(); | 426 SendContentSuggestions(); |
427 } | 427 } |
OLD | NEW |