| 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 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 // TODO(pke): Replace this as soon as the service delivers the title directly. | 77 // TODO(pke): Replace this as soon as the service delivers the title directly. |
| 78 std::string GetCategoryTitle(Category category) { | 78 std::string GetCategoryTitle(Category category) { |
| 79 if (category.IsKnownCategory(KnownCategories::ARTICLES)) { | 79 if (category.IsKnownCategory(KnownCategories::ARTICLES)) { |
| 80 return "Articles"; | 80 return "Articles"; |
| 81 } | 81 } |
| 82 if (category.IsKnownCategory(KnownCategories::OFFLINE_PAGES)) { | 82 if (category.IsKnownCategory(KnownCategories::OFFLINE_PAGES)) { |
| 83 return "Offline pages (continue browsing)"; | 83 return "Offline pages (continue browsing)"; |
| 84 } | 84 } |
| 85 if (category.IsKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES)) { |
| 86 return "Physical Web pages (in the vicinity)"; |
| 87 } |
| 85 return std::string(); | 88 return std::string(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 std::string GetCategoryStatusName(CategoryStatus status) { | 91 std::string GetCategoryStatusName(CategoryStatus status) { |
| 89 switch (status) { | 92 switch (status) { |
| 90 case CategoryStatus::INITIALIZING: | 93 case CategoryStatus::INITIALIZING: |
| 91 return "INITIALIZING"; | 94 return "INITIALIZING"; |
| 92 case CategoryStatus::AVAILABLE: | 95 case CategoryStatus::AVAILABLE: |
| 93 return "AVAILABLE"; | 96 return "AVAILABLE"; |
| 94 case CategoryStatus::AVAILABLE_LOADING: | 97 case CategoryStatus::AVAILABLE_LOADING: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 void SnippetsInternalsMessageHandler::SendAllContent() { | 232 void SnippetsInternalsMessageHandler::SendAllContent() { |
| 230 SendHosts(); | 233 SendHosts(); |
| 231 | 234 |
| 232 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( | 235 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( |
| 233 chrome::android::kNTPSnippetsFeature)); | 236 chrome::android::kNTPSnippetsFeature)); |
| 234 | 237 |
| 235 SendBoolean("flag-offline-page-suggestions", | 238 SendBoolean("flag-offline-page-suggestions", |
| 236 base::FeatureList::IsEnabled( | 239 base::FeatureList::IsEnabled( |
| 237 chrome::android::kNTPOfflinePageSuggestionsFeature)); | 240 chrome::android::kNTPOfflinePageSuggestionsFeature)); |
| 238 | 241 |
| 242 SendBoolean("flag-physical-web-page-suggestions", |
| 243 base::FeatureList::IsEnabled( |
| 244 chrome::android::kNTPPhysicalWebPageSuggestionsFeature)); |
| 245 |
| 239 web_ui()->CallJavascriptFunctionUnsafe( | 246 web_ui()->CallJavascriptFunctionUnsafe( |
| 240 "chrome.SnippetsInternals.setHostRestricted", | 247 "chrome.SnippetsInternals.setHostRestricted", |
| 241 base::FundamentalValue( | 248 base::FundamentalValue( |
| 242 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); | 249 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); |
| 243 | 250 |
| 244 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { | 251 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { |
| 245 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: | 252 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: |
| 246 SendString("switch-personalized", "Only personalized"); | 253 SendString("switch-personalized", "Only personalized"); |
| 247 break; | 254 break; |
| 248 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth: | 255 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth: |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 358 } |
| 352 | 359 |
| 353 void SnippetsInternalsMessageHandler::SendString(const std::string& name, | 360 void SnippetsInternalsMessageHandler::SendString(const std::string& name, |
| 354 const std::string& value) { | 361 const std::string& value) { |
| 355 base::StringValue string_name(name); | 362 base::StringValue string_name(name); |
| 356 base::StringValue string_value(value); | 363 base::StringValue string_value(value); |
| 357 | 364 |
| 358 web_ui()->CallJavascriptFunctionUnsafe( | 365 web_ui()->CallJavascriptFunctionUnsafe( |
| 359 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); | 366 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); |
| 360 } | 367 } |
| OLD | NEW |