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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature)); | 289 base::FeatureList::IsEnabled(ntp_snippets::kBookmarkSuggestionsFeature)); |
290 | 290 |
291 SendBoolean("flag-physical-web-page-suggestions", | 291 SendBoolean("flag-physical-web-page-suggestions", |
292 base::FeatureList::IsEnabled( | 292 base::FeatureList::IsEnabled( |
293 ntp_snippets::kPhysicalWebPageSuggestionsFeature)); | 293 ntp_snippets::kPhysicalWebPageSuggestionsFeature)); |
294 | 294 |
295 SendClassification(); | 295 SendClassification(); |
296 SendLastRemoteSuggestionsBackgroundFetchTime(); | 296 SendLastRemoteSuggestionsBackgroundFetchTime(); |
297 | 297 |
298 if (remote_suggestions_provider_) { | 298 if (remote_suggestions_provider_) { |
299 switch ( | 299 // TODO(fhorschig): Read this string from variations directly. |
300 remote_suggestions_provider_->snippets_fetcher()->personalization()) { | 300 SendString("switch-personalized", |
301 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: | 301 remote_suggestions_provider_->snippets_fetcher() |
302 SendString("switch-personalized", "Only personalized"); | 302 ->PersonalizationModeString()); |
303 break; | |
304 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth: | |
305 SendString("switch-personalized", | |
306 "Both personalized and non-personalized"); | |
307 break; | |
308 case ntp_snippets::NTPSnippetsFetcher::Personalization::kNonPersonal: | |
309 SendString("switch-personalized", "Only non-personalized"); | |
310 break; | |
311 } | |
312 | 303 |
313 SendString( | 304 SendString( |
314 "switch-fetch-url", | 305 "switch-fetch-url", |
315 remote_suggestions_provider_->snippets_fetcher()->fetch_url().spec()); | 306 remote_suggestions_provider_->snippets_fetcher()->fetch_url().spec()); |
316 web_ui()->CallJavascriptFunctionUnsafe( | 307 web_ui()->CallJavascriptFunctionUnsafe( |
317 "chrome.SnippetsInternals.receiveJson", | 308 "chrome.SnippetsInternals.receiveJson", |
318 base::StringValue( | 309 base::StringValue( |
319 remote_suggestions_provider_->snippets_fetcher()->last_json())); | 310 remote_suggestions_provider_->snippets_fetcher()->last_json())); |
320 } | 311 } |
321 | 312 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 405 |
415 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( | 406 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( |
416 Category category, | 407 Category category, |
417 std::vector<ContentSuggestion> dismissed_suggestions) { | 408 std::vector<ContentSuggestion> dismissed_suggestions) { |
418 if (dismissed_state_[category] == DismissedState::HIDDEN) | 409 if (dismissed_state_[category] == DismissedState::HIDDEN) |
419 return; | 410 return; |
420 dismissed_suggestions_[category] = std::move(dismissed_suggestions); | 411 dismissed_suggestions_[category] = std::move(dismissed_suggestions); |
421 dismissed_state_[category] = DismissedState::VISIBLE; | 412 dismissed_state_[category] = DismissedState::VISIBLE; |
422 SendContentSuggestions(); | 413 SendContentSuggestions(); |
423 } | 414 } |
OLD | NEW |