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

Side by Side Diff: components/autofill/content/browser/risk/fingerprint.cc

Issue 534043002: Add bits to indicate which parts of GPUInfo are collected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // Generating a fingerprint consists of two major steps: 5 // Generating a fingerprint consists of two major steps:
6 // (1) Gather all the necessary data. 6 // (1) Gather all the necessary data.
7 // (2) Write it into a protocol buffer. 7 // (2) Write it into a protocol buffer.
8 // 8 //
9 // Step (2) is as simple as it sounds -- it's really just a matter of copying 9 // Step (2) is as simple as it sounds -- it's really just a matter of copying
10 // data. Step (1) requires waiting on several asynchronous callbacks, which are 10 // data. Step (1) requires waiting on several asynchronous callbacks, which are
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 // Writes info about the machine's CPU into the |machine|. 154 // Writes info about the machine's CPU into the |machine|.
155 void AddCpuInfoToFingerprint(Fingerprint::MachineCharacteristics* machine) { 155 void AddCpuInfoToFingerprint(Fingerprint::MachineCharacteristics* machine) {
156 base::CPU cpu; 156 base::CPU cpu;
157 machine->mutable_cpu()->set_vendor_name(cpu.vendor_name()); 157 machine->mutable_cpu()->set_vendor_name(cpu.vendor_name());
158 machine->mutable_cpu()->set_brand(cpu.cpu_brand()); 158 machine->mutable_cpu()->set_brand(cpu.cpu_brand());
159 } 159 }
160 160
161 // Writes info about the machine's GPU into the |machine|. 161 // Writes info about the machine's GPU into the |machine|.
162 void AddGpuInfoToFingerprint(Fingerprint::MachineCharacteristics* machine) { 162 void AddGpuInfoToFingerprint(Fingerprint::MachineCharacteristics* machine,
163 const gpu::GPUInfo& gpu_info = 163 content::GpuDataManager* const gpu_data_manager) {
Evan Stade 2014/09/03 00:48:11 gpu_data_manager should be const ref
Zhenyao Mo 2014/09/03 01:31:23 Done. Will the ref type works the same as pointer
Evan Stade 2014/09/03 21:47:58 yep
164 content::GpuDataManager::GetInstance()->GetGPUInfo(); 164 if (!gpu_data_manager->IsCompleteGpuInfoAvailable(false))
165 if (!gpu_info.finalized)
166 return; 165 return;
167 166
167 const gpu::GPUInfo gpu_info = gpu_data_manager->GetGPUInfo();
168
168 Fingerprint::MachineCharacteristics::Graphics* graphics = 169 Fingerprint::MachineCharacteristics::Graphics* graphics =
169 machine->mutable_graphics_card(); 170 machine->mutable_graphics_card();
170 graphics->set_vendor_id(gpu_info.gpu.vendor_id); 171 graphics->set_vendor_id(gpu_info.gpu.vendor_id);
171 graphics->set_device_id(gpu_info.gpu.device_id); 172 graphics->set_device_id(gpu_info.gpu.device_id);
172 graphics->set_driver_version(gpu_info.driver_version); 173 graphics->set_driver_version(gpu_info.driver_version);
173 graphics->set_driver_date(gpu_info.driver_date); 174 graphics->set_driver_date(gpu_info.driver_date);
174 175
175 Fingerprint::MachineCharacteristics::Graphics::PerformanceStatistics* 176 Fingerprint::MachineCharacteristics::Graphics::PerformanceStatistics*
176 gpu_performance = graphics->mutable_performance_statistics(); 177 gpu_performance = graphics->mutable_performance_statistics();
177 gpu_performance->set_graphics_score(gpu_info.performance_stats.graphics); 178 gpu_performance->set_graphics_score(gpu_info.performance_stats.graphics);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 weak_ptr_factory_(this), 290 weak_ptr_factory_(this),
290 callback_(callback) { 291 callback_(callback) {
291 DCHECK(!install_time_.is_null()); 292 DCHECK(!install_time_.is_null());
292 293
293 timeout_timer_.Start(FROM_HERE, timeout, 294 timeout_timer_.Start(FROM_HERE, timeout,
294 base::Bind(&FingerprintDataLoader::MaybeFillFingerprint, 295 base::Bind(&FingerprintDataLoader::MaybeFillFingerprint,
295 weak_ptr_factory_.GetWeakPtr())); 296 weak_ptr_factory_.GetWeakPtr()));
296 297
297 // Load GPU data if needed. 298 // Load GPU data if needed.
298 if (gpu_data_manager_->GpuAccessAllowed(NULL) && 299 if (gpu_data_manager_->GpuAccessAllowed(NULL) &&
299 !gpu_data_manager_->IsCompleteGpuInfoAvailable()) { 300 !gpu_data_manager_->IsCompleteGpuInfoAvailable(false)) {
300 gpu_observer_.Add(gpu_data_manager_); 301 gpu_observer_.Add(gpu_data_manager_);
301 gpu_data_manager_->RequestCompleteGpuInfoIfNeeded(); 302 gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
302 } 303 }
303 304
304 #if defined(ENABLE_PLUGINS) 305 #if defined(ENABLE_PLUGINS)
305 // Load plugin data. 306 // Load plugin data.
306 content::PluginService::GetInstance()->GetPlugins( 307 content::PluginService::GetInstance()->GetPlugins(
307 base::Bind(&FingerprintDataLoader::OnGotPlugins, 308 base::Bind(&FingerprintDataLoader::OnGotPlugins,
308 weak_ptr_factory_.GetWeakPtr())); 309 weak_ptr_factory_.GetWeakPtr()));
309 #else 310 #else
310 waiting_on_plugins_ = false; 311 waiting_on_plugins_ = false;
311 #endif 312 #endif
312 313
313 // Load font data. 314 // Load font data.
314 content::GetFontListAsync( 315 content::GetFontListAsync(
315 base::Bind(&FingerprintDataLoader::OnGotFonts, 316 base::Bind(&FingerprintDataLoader::OnGotFonts,
316 weak_ptr_factory_.GetWeakPtr())); 317 weak_ptr_factory_.GetWeakPtr()));
317 318
318 // Load geolocation data. 319 // Load geolocation data.
319 geolocation_subscription_ = content::GeolocationProvider::GetInstance()-> 320 geolocation_subscription_ = content::GeolocationProvider::GetInstance()->
320 AddLocationUpdateCallback( 321 AddLocationUpdateCallback(
321 base::Bind(&FingerprintDataLoader::OnGotGeoposition, 322 base::Bind(&FingerprintDataLoader::OnGotGeoposition,
322 weak_ptr_factory_.GetWeakPtr()), 323 weak_ptr_factory_.GetWeakPtr()),
323 false); 324 false);
324 } 325 }
325 326
326 void FingerprintDataLoader::OnGpuInfoUpdate() { 327 void FingerprintDataLoader::OnGpuInfoUpdate() {
327 if (!gpu_data_manager_->IsCompleteGpuInfoAvailable()) 328 if (!gpu_data_manager_->IsCompleteGpuInfoAvailable(false))
328 return; 329 return;
329 330
330 gpu_observer_.Remove(gpu_data_manager_); 331 gpu_observer_.Remove(gpu_data_manager_);
331 MaybeFillFingerprint(); 332 MaybeFillFingerprint();
332 } 333 }
333 334
334 void FingerprintDataLoader::OnGotFonts(scoped_ptr<base::ListValue> fonts) { 335 void FingerprintDataLoader::OnGotFonts(scoped_ptr<base::ListValue> fonts) {
335 DCHECK(!fonts_); 336 DCHECK(!fonts_);
336 fonts_.reset(fonts.release()); 337 fonts_.reset(fonts.release());
337 MaybeFillFingerprint(); 338 MaybeFillFingerprint();
(...skipping 17 matching lines...) Expand all
355 geolocation_subscription_.reset(); 356 geolocation_subscription_.reset();
356 357
357 MaybeFillFingerprint(); 358 MaybeFillFingerprint();
358 } 359 }
359 360
360 void FingerprintDataLoader::MaybeFillFingerprint() { 361 void FingerprintDataLoader::MaybeFillFingerprint() {
361 // If all of the data has been loaded, or if the |timeout_timer_| has expired, 362 // If all of the data has been loaded, or if the |timeout_timer_| has expired,
362 // fill the fingerprint and clean up. 363 // fill the fingerprint and clean up.
363 if (!timeout_timer_.IsRunning() || 364 if (!timeout_timer_.IsRunning() ||
364 ((!gpu_data_manager_->GpuAccessAllowed(NULL) || 365 ((!gpu_data_manager_->GpuAccessAllowed(NULL) ||
365 gpu_data_manager_->IsCompleteGpuInfoAvailable()) && 366 gpu_data_manager_->IsCompleteGpuInfoAvailable(false)) &&
366 fonts_ && 367 fonts_ &&
367 !waiting_on_plugins_ && 368 !waiting_on_plugins_ &&
368 (geoposition_.Validate() || 369 (geoposition_.Validate() ||
369 geoposition_.error_code != content::Geoposition::ERROR_CODE_NONE))) { 370 geoposition_.error_code != content::Geoposition::ERROR_CODE_NONE))) {
370 FillFingerprint(); 371 FillFingerprint();
371 delete this; 372 delete this;
372 } 373 }
373 } 374 }
374 375
375 void FingerprintDataLoader::FillFingerprint() { 376 void FingerprintDataLoader::FillFingerprint() {
(...skipping 12 matching lines...) Expand all
388 machine->set_ram(base::SysInfo::AmountOfPhysicalMemory()); 389 machine->set_ram(base::SysInfo::AmountOfPhysicalMemory());
389 machine->set_browser_build(version_); 390 machine->set_browser_build(version_);
390 machine->set_browser_feature( 391 machine->set_browser_feature(
391 Fingerprint::MachineCharacteristics::FEATURE_REQUEST_AUTOCOMPLETE); 392 Fingerprint::MachineCharacteristics::FEATURE_REQUEST_AUTOCOMPLETE);
392 if (fonts_) 393 if (fonts_)
393 AddFontsToFingerprint(*fonts_, machine); 394 AddFontsToFingerprint(*fonts_, machine);
394 AddPluginsToFingerprint(plugins_, machine); 395 AddPluginsToFingerprint(plugins_, machine);
395 AddAcceptLanguagesToFingerprint(accept_languages_, machine); 396 AddAcceptLanguagesToFingerprint(accept_languages_, machine);
396 AddScreenInfoToFingerprint(screen_info_, machine); 397 AddScreenInfoToFingerprint(screen_info_, machine);
397 AddCpuInfoToFingerprint(machine); 398 AddCpuInfoToFingerprint(machine);
398 AddGpuInfoToFingerprint(machine); 399 AddGpuInfoToFingerprint(machine, gpu_data_manager_);
399 400
400 // TODO(isherman): Record the user_and_device_name_hash. 401 // TODO(isherman): Record the user_and_device_name_hash.
401 // TODO(isherman): Record the partition size of the hard drives? 402 // TODO(isherman): Record the partition size of the hard drives?
402 403
403 Fingerprint::TransientState* transient_state = 404 Fingerprint::TransientState* transient_state =
404 fingerprint->mutable_transient_state(); 405 fingerprint->mutable_transient_state();
405 Fingerprint::Dimension* inner_window_size = 406 Fingerprint::Dimension* inner_window_size =
406 transient_state->mutable_inner_window_size(); 407 transient_state->mutable_inner_window_size();
407 inner_window_size->set_width(content_bounds_.width()); 408 inner_window_size->set_width(content_bounds_.width());
408 inner_window_size->set_height(content_bounds_.height()); 409 inner_window_size->set_height(content_bounds_.height());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 host_view->GetRenderWidgetHost()->GetWebScreenInfo(&screen_info); 484 host_view->GetRenderWidgetHost()->GetWebScreenInfo(&screen_info);
484 485
485 internal::GetFingerprintInternal( 486 internal::GetFingerprintInternal(
486 obfuscated_gaia_id, window_bounds, content_bounds, screen_info, version, 487 obfuscated_gaia_id, window_bounds, content_bounds, screen_info, version,
487 charset, accept_languages, install_time, app_locale, user_agent, 488 charset, accept_languages, install_time, app_locale, user_agent,
488 base::TimeDelta::FromSeconds(kTimeoutSeconds), callback); 489 base::TimeDelta::FromSeconds(kTimeoutSeconds), callback);
489 } 490 }
490 491
491 } // namespace risk 492 } // namespace risk
492 } // namespace autofill 493 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698