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

Side by Side Diff: chrome/browser/android/data_usage/external_data_use_observer_bridge.cc

Issue 2505343002: Restrict sending GWS ID only to signed in users (Closed)
Patch Set: Added incognito check Created 4 years 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 | « no previous file | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/android/data_usage/external_data_use_observer_bridge.h" 5 #include "chrome/browser/android/data_usage/external_data_use_observer_bridge.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/android/context_utils.h" 10 #include "base/android/context_utils.h"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/android/data_usage/data_use_tab_model.h" 17 #include "chrome/browser/android/data_usage/data_use_tab_model.h"
18 #include "chrome/browser/android/data_usage/external_data_use_observer.h" 18 #include "chrome/browser/android/data_usage/external_data_use_observer.h"
19 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 19 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/signin/signin_manager_factory.h"
23 #include "components/signin/core/browser/signin_manager.h"
20 #include "components/variations/variations_associated_data.h" 24 #include "components/variations/variations_associated_data.h"
21 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
22 #include "jni/ExternalDataUseObserver_jni.h" 26 #include "jni/ExternalDataUseObserver_jni.h"
23 27
24 using base::android::ConvertUTF8ToJavaString; 28 using base::android::ConvertUTF8ToJavaString;
25 29
26 namespace { 30 namespace {
27 31
28 // Name of the external data use observer synthetic field trial, enabled and 32 // Name of the external data use observer synthetic field trial, enabled and
29 // disabled groups. 33 // disabled groups.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 bool should_register) const { 208 bool should_register) const {
205 DCHECK(thread_checker_.CalledOnValidThread()); 209 DCHECK(thread_checker_.CalledOnValidThread());
206 DCHECK(!j_external_data_use_observer_.is_null()); 210 DCHECK(!j_external_data_use_observer_.is_null());
207 211
208 io_task_runner_->PostTask( 212 io_task_runner_->PostTask(
209 FROM_HERE, 213 FROM_HERE,
210 base::Bind(&ExternalDataUseObserver::ShouldRegisterAsDataUseObserver, 214 base::Bind(&ExternalDataUseObserver::ShouldRegisterAsDataUseObserver,
211 external_data_use_observer_, should_register)); 215 external_data_use_observer_, should_register));
212 216
213 variations::VariationID variation_id = GetGoogleVariationID(); 217 variations::VariationID variation_id = GetGoogleVariationID();
214 if (variation_id != variations::EMPTY_ID) { 218 Profile* profile = ProfileManager::GetLastUsedProfile();
219 DCHECK(profile);
tbansal1 2016/12/12 18:55:23 nit: DCHECK is not required since if the |profile|
220
221 // Skip registering synthetic field trial for incognito profiles.
222 if (profile->GetProfileType() == INCOGNITO_PROFILE)
223 return;
224
225 const SigninManager* signin_manager =
226 SigninManagerFactory::GetForProfileIfExists(profile);
227 if (variation_id != variations::EMPTY_ID && signin_manager &&
228 signin_manager->IsAuthenticated()) {
215 // Set variation id for the enabled group if |should_register| is true. 229 // Set variation id for the enabled group if |should_register| is true.
216 // Otherwise clear the variation id for the enabled group by setting to 230 // Otherwise clear the variation id for the enabled group by setting to
217 // EMPTY_ID. 231 // EMPTY_ID.
218 variations::AssociateGoogleVariationID( 232 variations::AssociateGoogleVariationID(
219 variations::GOOGLE_WEB_PROPERTIES, kSyntheticFieldTrial, 233 variations::GOOGLE_WEB_PROPERTIES, kSyntheticFieldTrial,
220 kSyntheticFieldTrialEnabledGroup, 234 kSyntheticFieldTrialEnabledGroup,
221 should_register ? variation_id : variations::EMPTY_ID); 235 should_register ? variation_id : variations::EMPTY_ID);
222 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( 236 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
223 kSyntheticFieldTrial, should_register 237 kSyntheticFieldTrial, should_register
224 ? kSyntheticFieldTrialEnabledGroup 238 ? kSyntheticFieldTrialEnabledGroup
225 : kSyntheticFieldTrialDisabledGroup); 239 : kSyntheticFieldTrialDisabledGroup);
226 } 240 }
227 } 241 }
228 242
229 bool RegisterExternalDataUseObserver(JNIEnv* env) { 243 bool RegisterExternalDataUseObserver(JNIEnv* env) {
230 return RegisterNativesImpl(env); 244 return RegisterNativesImpl(env);
231 } 245 }
232 246
233 } // namespace android 247 } // namespace android
234 248
235 } // namespace chrome 249 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698