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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 std::string GetCategoryTitle(Category category) { | 52 std::string GetCategoryTitle(Category category) { |
53 if (category.IsKnownCategory(KnownCategories::ARTICLES)) { | 53 if (category.IsKnownCategory(KnownCategories::ARTICLES)) { |
54 return "Articles"; | 54 return "Articles"; |
55 } | 55 } |
56 if (category.IsKnownCategory(KnownCategories::OFFLINE_PAGES)) { | 56 if (category.IsKnownCategory(KnownCategories::OFFLINE_PAGES)) { |
57 return "Offline pages (continue browsing)"; | 57 return "Offline pages (continue browsing)"; |
58 } | 58 } |
59 if (category.IsKnownCategory(KnownCategories::BOOKMARKS)) { | 59 if (category.IsKnownCategory(KnownCategories::BOOKMARKS)) { |
60 return "Recently visited bookmarks"; | 60 return "Recently visited bookmarks"; |
61 } | 61 } |
| 62 if (category.IsKnownCategory(KnownCategories::PHYSICAL_WEB_PAGES)) { |
| 63 return "Physical Web pages (in the vicinity)"; |
| 64 } |
62 return std::string(); | 65 return std::string(); |
63 } | 66 } |
64 | 67 |
65 std::string GetCategoryStatusName(CategoryStatus status) { | 68 std::string GetCategoryStatusName(CategoryStatus status) { |
66 switch (status) { | 69 switch (status) { |
67 case CategoryStatus::INITIALIZING: | 70 case CategoryStatus::INITIALIZING: |
68 return "INITIALIZING"; | 71 return "INITIALIZING"; |
69 case CategoryStatus::AVAILABLE: | 72 case CategoryStatus::AVAILABLE: |
70 return "AVAILABLE"; | 73 return "AVAILABLE"; |
71 case CategoryStatus::AVAILABLE_LOADING: | 74 case CategoryStatus::AVAILABLE_LOADING: |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void SnippetsInternalsMessageHandler::SendAllContent() { | 203 void SnippetsInternalsMessageHandler::SendAllContent() { |
201 SendHosts(); | 204 SendHosts(); |
202 | 205 |
203 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( | 206 SendBoolean("flag-snippets", base::FeatureList::IsEnabled( |
204 ntp_snippets::kContentSuggestionsFeature)); | 207 ntp_snippets::kContentSuggestionsFeature)); |
205 | 208 |
206 SendBoolean("flag-offline-page-suggestions", | 209 SendBoolean("flag-offline-page-suggestions", |
207 base::FeatureList::IsEnabled( | 210 base::FeatureList::IsEnabled( |
208 ntp_snippets::kOfflinePageSuggestionsFeature)); | 211 ntp_snippets::kOfflinePageSuggestionsFeature)); |
209 | 212 |
| 213 SendBoolean("flag-physical-web-page-suggestions", |
| 214 base::FeatureList::IsEnabled( |
| 215 chrome::android::kNTPPhysicalWebPageSuggestionsFeature)); |
| 216 |
210 web_ui()->CallJavascriptFunctionUnsafe( | 217 web_ui()->CallJavascriptFunctionUnsafe( |
211 "chrome.SnippetsInternals.setHostRestricted", | 218 "chrome.SnippetsInternals.setHostRestricted", |
212 base::FundamentalValue( | 219 base::FundamentalValue( |
213 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); | 220 ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions())); |
214 | 221 |
215 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { | 222 switch (ntp_snippets_service_->snippets_fetcher()->personalization()) { |
216 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: | 223 case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal: |
217 SendString("switch-personalized", "Only personalized"); | 224 SendString("switch-personalized", "Only personalized"); |
218 break; | 225 break; |
219 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth: | 226 case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth: |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 308 } |
302 | 309 |
303 void SnippetsInternalsMessageHandler::SendString(const std::string& name, | 310 void SnippetsInternalsMessageHandler::SendString(const std::string& name, |
304 const std::string& value) { | 311 const std::string& value) { |
305 base::StringValue string_name(name); | 312 base::StringValue string_name(name); |
306 base::StringValue string_value(value); | 313 base::StringValue string_value(value); |
307 | 314 |
308 web_ui()->CallJavascriptFunctionUnsafe( | 315 web_ui()->CallJavascriptFunctionUnsafe( |
309 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); | 316 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); |
310 } | 317 } |
OLD | NEW |