| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/feature_list.h" | 15 #include "base/feature_list.h" |
| 16 #include "base/i18n/time_formatting.h" | 16 #include "base/i18n/time_formatting.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "base/optional.h" | 19 #include "base/optional.h" |
| 20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/values.h" | 23 #include "base/values.h" |
| 24 #include "chrome/browser/android/chrome_feature_list.h" |
| 24 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" | 25 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/common/chrome_features.h" | 27 #include "chrome/common/chrome_features.h" |
| 27 #include "components/ntp_snippets/category.h" | 28 #include "components/ntp_snippets/category.h" |
| 28 #include "components/ntp_snippets/category_info.h" | 29 #include "components/ntp_snippets/category_info.h" |
| 29 #include "components/ntp_snippets/features.h" | 30 #include "components/ntp_snippets/features.h" |
| 30 #include "components/ntp_snippets/pref_names.h" | 31 #include "components/ntp_snippets/pref_names.h" |
| 31 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" | 32 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" |
| 32 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" | 33 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" |
| 33 #include "components/ntp_snippets/switches.h" | 34 #include "components/ntp_snippets/switches.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 base::FeatureList::IsEnabled( | 292 base::FeatureList::IsEnabled( |
| 292 features::kOfflinePageDownloadSuggestionsFeature)); | 293 features::kOfflinePageDownloadSuggestionsFeature)); |
| 293 SendBoolean( | 294 SendBoolean( |
| 294 "flag-bookmark-suggestions", | 295 "flag-bookmark-suggestions", |
| 295 base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature)); | 296 base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature)); |
| 296 | 297 |
| 297 SendBoolean("flag-physical-web-page-suggestions", | 298 SendBoolean("flag-physical-web-page-suggestions", |
| 298 base::FeatureList::IsEnabled( | 299 base::FeatureList::IsEnabled( |
| 299 ntp_snippets::kPhysicalWebPageSuggestionsFeature)); | 300 ntp_snippets::kPhysicalWebPageSuggestionsFeature)); |
| 300 | 301 |
| 302 SendBoolean("flag-physical-web", base::FeatureList::IsEnabled( |
| 303 chrome::android::kPhysicalWebFeature)); |
| 304 |
| 301 SendClassification(); | 305 SendClassification(); |
| 302 SendLastRemoteSuggestionsBackgroundFetchTime(); | 306 SendLastRemoteSuggestionsBackgroundFetchTime(); |
| 303 | 307 |
| 304 if (remote_suggestions_provider_) { | 308 if (remote_suggestions_provider_) { |
| 305 const ntp_snippets::NTPSnippetsFetcher* fetcher = | 309 const ntp_snippets::NTPSnippetsFetcher* fetcher = |
| 306 remote_suggestions_provider_ | 310 remote_suggestions_provider_ |
| 307 ->snippets_fetcher_for_testing_and_debugging(); | 311 ->snippets_fetcher_for_testing_and_debugging(); |
| 308 // TODO(fhorschig): Read this string from variations directly. | 312 // TODO(fhorschig): Read this string from variations directly. |
| 309 SendString("switch-personalized", fetcher->PersonalizationModeString()); | 313 SendString("switch-personalized", fetcher->PersonalizationModeString()); |
| 310 | 314 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 415 |
| 412 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( | 416 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( |
| 413 Category category, | 417 Category category, |
| 414 std::vector<ContentSuggestion> dismissed_suggestions) { | 418 std::vector<ContentSuggestion> dismissed_suggestions) { |
| 415 if (dismissed_state_[category] == DismissedState::HIDDEN) | 419 if (dismissed_state_[category] == DismissedState::HIDDEN) |
| 416 return; | 420 return; |
| 417 dismissed_suggestions_[category] = std::move(dismissed_suggestions); | 421 dismissed_suggestions_[category] = std::move(dismissed_suggestions); |
| 418 dismissed_state_[category] = DismissedState::VISIBLE; | 422 dismissed_state_[category] = DismissedState::VISIBLE; |
| 419 SendContentSuggestions(); | 423 SendContentSuggestions(); |
| 420 } | 424 } |
| OLD | NEW |