| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/feature_list.h" | 14 #include "base/feature_list.h" |
| 15 #include "base/i18n/time_formatting.h" | 15 #include "base/i18n/time_formatting.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/browser/android/chrome_feature_list.h" | |
| 22 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" | 21 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 24 #include "components/ntp_snippets/features.h" | 23 #include "components/ntp_snippets/features.h" |
| 25 #include "components/ntp_snippets/ntp_snippet.h" | 24 #include "components/ntp_snippets/ntp_snippet.h" |
| 26 #include "components/ntp_snippets/switches.h" | 25 #include "components/ntp_snippets/switches.h" |
| 27 #include "content/public/browser/web_ui.h" | 26 #include "content/public/browser/web_ui.h" |
| 28 | 27 |
| 29 using ntp_snippets::ContentSuggestion; | 28 using ntp_snippets::ContentSuggestion; |
| 30 using ntp_snippets::Category; | 29 using ntp_snippets::Category; |
| 31 using ntp_snippets::CategoryStatus; | 30 using ntp_snippets::CategoryStatus; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } | 230 } |
| 232 | 231 |
| 233 void SnippetsInternalsMessageHandler::SendAllContent() { | 232 void SnippetsInternalsMessageHandler::SendAllContent() { |
| 234 SendHosts(); | 233 SendHosts(); |
| 235 | 234 |
| 236 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( | 235 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( |
| 237 ntp_snippets::kContentSuggestionsFeature)); | 236 ntp_snippets::kContentSuggestionsFeature)); |
| 238 | 237 |
| 239 SendBoolean("flag-offline-page-suggestions", | 238 SendBoolean("flag-offline-page-suggestions", |
| 240 base::FeatureList::IsEnabled( | 239 base::FeatureList::IsEnabled( |
| 241 chrome::android::kNTPOfflinePageSuggestionsFeature)); | 240 ntp_snippets::kOfflinePageSuggestionsFeature)); |
| 242 | 241 |
| 243 web_ui()->CallJavascriptFunctionUnsafe( | 242 web_ui()->CallJavascriptFunctionUnsafe( |
| 244 "chrome.SnippetsInternals.setHostRestricted", | 243 "chrome.SnippetsInternals.setHostRestricted", |
| 245 base::FundamentalValue( | 244 base::FundamentalValue( |
| 246 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); | 245 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); |
| 247 | 246 |
| 248 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { | 247 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { |
| 249 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: | 248 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: |
| 250 SendString("switch-personalized", "Only personalized"); | 249 SendString("switch-personalized", "Only personalized"); |
| 251 break; | 250 break; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 354 } |
| 356 | 355 |
| 357 void SnippetsInternalsMessageHandler::SendString(const std::string& name, | 356 void SnippetsInternalsMessageHandler::SendString(const std::string& name, |
| 358 const std::string& value) { | 357 const std::string& value) { |
| 359 base::StringValue string_name(name); | 358 base::StringValue string_name(name); |
| 360 base::StringValue string_value(value); | 359 base::StringValue string_value(value); |
| 361 | 360 |
| 362 web_ui()->CallJavascriptFunctionUnsafe( | 361 web_ui()->CallJavascriptFunctionUnsafe( |
| 363 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); | 362 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); |
| 364 } | 363 } |
| OLD | NEW |