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

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: rebase 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 case CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED: 116 case CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED:
114 return "ALL_SUGGESTIONS_EXPLICITLY_DISABLED"; 117 return "ALL_SUGGESTIONS_EXPLICITLY_DISABLED";
115 case CategoryStatus::CATEGORY_EXPLICITLY_DISABLED: 118 case CategoryStatus::CATEGORY_EXPLICITLY_DISABLED:
116 return "CATEGORY_EXPLICITLY_DISABLED"; 119 return "CATEGORY_EXPLICITLY_DISABLED";
117 case CategoryStatus::LOADING_ERROR: 120 case CategoryStatus::LOADING_ERROR:
118 return "LOADING_ERROR"; 121 return "LOADING_ERROR";
119 } 122 }
120 return std::string(); 123 return std::string();
121 } 124 }
122 125
126 std::set<variations::VariationID> SnippetsExperiments() {
127 std::set<variations::VariationID> result;
128 for (const base::Feature* const* feature = ntp_snippets::kAllFeatures;
129 *feature; ++feature) {
130 base::FieldTrial* trial = base::FeatureList::GetFieldTrial(**feature);
131 if (!trial) {
132 continue;
133 }
134 if (trial->GetGroupNameWithoutActivation().empty()) {
135 continue;
136 }
137 for (variations::IDCollectionKey key :
138 {variations::GOOGLE_WEB_PROPERTIES,
139 variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN,
140 variations::GOOGLE_WEB_PROPERTIES_TRIGGER}) {
141 const variations::VariationID id = variations::GetGoogleVariationID(
142 key, trial->trial_name(), trial->group_name());
143 if (id != variations::EMPTY_ID) {
144 result.insert(id);
145 }
146 }
147 }
148 return result;
149 }
150
123 } // namespace 151 } // namespace
124 152
125 SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler( 153 SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler(
126 ntp_snippets::ContentSuggestionsService* content_suggestions_service, 154 ntp_snippets::ContentSuggestionsService* content_suggestions_service,
127 PrefService* pref_service) 155 PrefService* pref_service)
128 : content_suggestions_service_observer_(this), 156 : content_suggestions_service_observer_(this),
129 dom_loaded_(false), 157 dom_loaded_(false),
130 content_suggestions_service_(content_suggestions_service), 158 content_suggestions_service_(content_suggestions_service),
131 remote_suggestions_provider_( 159 remote_suggestions_provider_(
132 content_suggestions_service_ 160 content_suggestions_service_
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 379
352 if (remote_suggestions_provider_) { 380 if (remote_suggestions_provider_) {
353 const ntp_snippets::RemoteSuggestionsFetcher* fetcher = 381 const ntp_snippets::RemoteSuggestionsFetcher* fetcher =
354 remote_suggestions_provider_->suggestions_fetcher_for_debugging(); 382 remote_suggestions_provider_->suggestions_fetcher_for_debugging();
355 SendString("switch-fetch-url", fetcher->fetch_url().spec()); 383 SendString("switch-fetch-url", fetcher->fetch_url().spec());
356 web_ui()->CallJavascriptFunctionUnsafe( 384 web_ui()->CallJavascriptFunctionUnsafe(
357 "chrome.SnippetsInternals.receiveJson", 385 "chrome.SnippetsInternals.receiveJson",
358 base::Value(fetcher->last_json())); 386 base::Value(fetcher->last_json()));
359 } 387 }
360 388
389 std::set<variations::VariationID> ids = SnippetsExperiments();
390 std::vector<std::string> string_ids;
391 for (auto id : ids) {
392 string_ids.push_back(base::IntToString(id));
393 }
394 SendString("experiment-ids", base::JoinString(string_ids, ", "));
395
361 SendContentSuggestions(); 396 SendContentSuggestions();
362 } 397 }
363 398
364 void SnippetsInternalsMessageHandler::SendClassification() { 399 void SnippetsInternalsMessageHandler::SendClassification() {
365 web_ui()->CallJavascriptFunctionUnsafe( 400 web_ui()->CallJavascriptFunctionUnsafe(
366 "chrome.SnippetsInternals.receiveClassification", 401 "chrome.SnippetsInternals.receiveClassification",
367 base::Value(content_suggestions_service_->user_classifier() 402 base::Value(content_suggestions_service_->user_classifier()
368 ->GetUserClassDescriptionForDebugging()), 403 ->GetUserClassDescriptionForDebugging()),
369 base::Value( 404 base::Value(
370 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( 405 content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded( 491 void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded(
457 Category category, 492 Category category,
458 std::vector<ContentSuggestion> dismissed_suggestions) { 493 std::vector<ContentSuggestion> dismissed_suggestions) {
459 if (dismissed_state_[category] == DismissedState::HIDDEN) { 494 if (dismissed_state_[category] == DismissedState::HIDDEN) {
460 return; 495 return;
461 } 496 }
462 dismissed_suggestions_[category] = std::move(dismissed_suggestions); 497 dismissed_suggestions_[category] = std::move(dismissed_suggestions);
463 dismissed_state_[category] = DismissedState::VISIBLE; 498 dismissed_state_[category] = DismissedState::VISIBLE;
464 SendContentSuggestions(); 499 SendContentSuggestions();
465 } 500 }
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