Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/browser/ui/webui/snippets_internals_message_handler.cc

Issue 2826013002: List relevant IDs from Finch in snippets-internals (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/snippets_internals.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/metrics/field_trial.h"
19 #include "base/optional.h" 20 #include "base/optional.h"
20 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
23 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
23 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
24 #include "base/values.h" 26 #include "base/values.h"
25 #include "chrome/browser/android/chrome_feature_list.h" 27 #include "chrome/browser/android/chrome_feature_list.h"
26 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" 28 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
27 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/common/chrome_features.h" 30 #include "chrome/common/chrome_features.h"
29 #include "components/ntp_snippets/category.h" 31 #include "components/ntp_snippets/category.h"
30 #include "components/ntp_snippets/category_info.h" 32 #include "components/ntp_snippets/category_info.h"
31 #include "components/ntp_snippets/features.h" 33 #include "components/ntp_snippets/features.h"
32 #include "components/ntp_snippets/pref_names.h" 34 #include "components/ntp_snippets/pref_names.h"
33 #include "components/ntp_snippets/remote/remote_suggestions_fetcher.h" 35 #include "components/ntp_snippets/remote/remote_suggestions_fetcher.h"
34 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" 36 #include "components/ntp_snippets/remote/remote_suggestions_provider.h"
35 #include "components/ntp_snippets/switches.h" 37 #include "components/ntp_snippets/switches.h"
36 #include "components/offline_pages/core/offline_page_feature.h" 38 #include "components/offline_pages/core/offline_page_feature.h"
37 #include "components/prefs/pref_service.h" 39 #include "components/prefs/pref_service.h"
40 #include "components/variations/variations_associated_data.h"
38 #include "content/public/browser/web_ui.h" 41 #include "content/public/browser/web_ui.h"
39 42
40 using ntp_snippets::ContentSuggestion; 43 using ntp_snippets::ContentSuggestion;
41 using ntp_snippets::Category; 44 using ntp_snippets::Category;
42 using ntp_snippets::CategoryInfo; 45 using ntp_snippets::CategoryInfo;
43 using ntp_snippets::CategoryStatus; 46 using ntp_snippets::CategoryStatus;
44 using ntp_snippets::KnownCategories; 47 using ntp_snippets::KnownCategories;
45 using ntp_snippets::RemoteSuggestionsProvider; 48 using ntp_snippets::RemoteSuggestionsProvider;
46 using ntp_snippets::UserClassifier; 49 using ntp_snippets::UserClassifier;
47 50
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 case CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED: 115 case CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED:
113 return "ALL_SUGGESTIONS_EXPLICITLY_DISABLED"; 116 return "ALL_SUGGESTIONS_EXPLICITLY_DISABLED";
114 case CategoryStatus::CATEGORY_EXPLICITLY_DISABLED: 117 case CategoryStatus::CATEGORY_EXPLICITLY_DISABLED:
115 return "CATEGORY_EXPLICITLY_DISABLED"; 118 return "CATEGORY_EXPLICITLY_DISABLED";
116 case CategoryStatus::LOADING_ERROR: 119 case CategoryStatus::LOADING_ERROR:
117 return "LOADING_ERROR"; 120 return "LOADING_ERROR";
118 } 121 }
119 return std::string(); 122 return std::string();
120 } 123 }
121 124
125 std::set<variations::VariationID> SnippetsExperiments() {
126 std::set<variations::VariationID> result;
127 for (const base::Feature* const* feature = ntp_snippets::kAllFeatures;
128 *feature; ++feature) {
129 base::FieldTrial* trial = base::FeatureList::GetFieldTrial(**feature);
130 if (!trial) {
131 continue;
132 }
133 if (trial->GetGroupNameWithoutActivation().empty()) {
134 continue;
135 }
136 for (variations::IDCollectionKey key :
137 {variations::GOOGLE_WEB_PROPERTIES,
138 variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN,
139 variations::GOOGLE_WEB_PROPERTIES_TRIGGER}) {
140 const variations::VariationID id = variations::GetGoogleVariationID(
141 key, trial->trial_name(), trial->group_name());
jkrcal 2017/04/19 11:15:43 Just want to double check: The fact that the group
sfiera 2017/04/19 11:40:18 Yes, from my reading of the code, a non-empty grou
jkrcal 2017/04/19 11:45:17 Acknowledged.
142 if (id != variations::EMPTY_ID) {
143 result.insert(id);
144 }
145 }
146 }
147 return result;
148 }
149
122 } // namespace 150 } // namespace
123 151
124 SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler( 152 SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler(
125 ntp_snippets::ContentSuggestionsService* content_suggestions_service, 153 ntp_snippets::ContentSuggestionsService* content_suggestions_service,
126 PrefService* pref_service) 154 PrefService* pref_service)
127 : content_suggestions_service_observer_(this), 155 : content_suggestions_service_observer_(this),
128 dom_loaded_(false), 156 dom_loaded_(false),
129 content_suggestions_service_(content_suggestions_service), 157 content_suggestions_service_(content_suggestions_service),
130 remote_suggestions_provider_( 158 remote_suggestions_provider_(
131 content_suggestions_service_ 159 content_suggestions_service_
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 378
351 if (remote_suggestions_provider_) { 379 if (remote_suggestions_provider_) {
352 const ntp_snippets::RemoteSuggestionsFetcher* fetcher = 380 const ntp_snippets::RemoteSuggestionsFetcher* fetcher =
353 remote_suggestions_provider_->suggestions_fetcher_for_debugging(); 381 remote_suggestions_provider_->suggestions_fetcher_for_debugging();
354 SendString("switch-fetch-url", fetcher->fetch_url().spec()); 382 SendString("switch-fetch-url", fetcher->fetch_url().spec());
355 web_ui()->CallJavascriptFunctionUnsafe( 383 web_ui()->CallJavascriptFunctionUnsafe(
356 "chrome.SnippetsInternals.receiveJson", 384 "chrome.SnippetsInternals.receiveJson",
357 base::Value(fetcher->last_json())); 385 base::Value(fetcher->last_json()));
358 } 386 }
359 387
388 std::set<variations::VariationID> ids = SnippetsExperiments();
389 std::vector<std::string> string_ids;
390 for (auto id : ids) {
391 string_ids.push_back(base::IntToString(id));
392 }
393 SendString("experiment-ids", base::JoinString(string_ids, ", "));
394
360 SendContentSuggestions(); 395 SendContentSuggestions();
361 } 396 }
362 397
363 void SnippetsInternalsMessageHandler::SendClassification() { 398 void SnippetsInternalsMessageHandler::SendClassification() {
364 web_ui()->CallJavascriptFunctionUnsafe( 399 web_ui()->CallJavascriptFunctionUnsafe(
365 "chrome.SnippetsInternals.receiveClassification", 400 "chrome.SnippetsInternals.receiveClassification",
366 base::Value(content_suggestions_service_->user_classifier() 401 base::Value(content_suggestions_service_->user_classifier()
367 ->GetUserClassDescriptionForDebugging()), 402 ->GetUserClassDescriptionForDebugging()),
368 base::Value( 403 base::Value(
369 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( 404 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( 490 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded(
456 Category category, 491 Category category,
457 std::vector<ContentSuggestion> dismissed_suggestions) { 492 std::vector<ContentSuggestion> dismissed_suggestions) {
458 if (dismissed_state_[category] == DismissedState::HIDDEN) { 493 if (dismissed_state_[category] == DismissedState::HIDDEN) {
459 return; 494 return;
460 } 495 }
461 dismissed_suggestions_[category] = std::move(dismissed_suggestions); 496 dismissed_suggestions_[category] = std::move(dismissed_suggestions);
462 dismissed_state_[category] = DismissedState::VISIBLE; 497 dismissed_state_[category] = DismissedState::VISIBLE;
463 SendContentSuggestions(); 498 SendContentSuggestions();
464 } 499 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/snippets_internals.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698