| OLD | NEW |
| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 FingerprintDataLoader( | 256 FingerprintDataLoader( |
| 257 uint64 obfuscated_gaia_id, | 257 uint64 obfuscated_gaia_id, |
| 258 const gfx::Rect& window_bounds, | 258 const gfx::Rect& window_bounds, |
| 259 const gfx::Rect& content_bounds, | 259 const gfx::Rect& content_bounds, |
| 260 const WebScreenInfo& screen_info, | 260 const WebScreenInfo& screen_info, |
| 261 const std::string& version, | 261 const std::string& version, |
| 262 const std::string& charset, | 262 const std::string& charset, |
| 263 const std::string& accept_languages, | 263 const std::string& accept_languages, |
| 264 const base::Time& install_time, | 264 const base::Time& install_time, |
| 265 const std::string& app_locale, | 265 const std::string& app_locale, |
| 266 const std::string& user_agent, |
| 266 const base::TimeDelta& timeout, | 267 const base::TimeDelta& timeout, |
| 267 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback); | 268 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback); |
| 268 | 269 |
| 269 private: | 270 private: |
| 270 virtual ~FingerprintDataLoader() {} | 271 virtual ~FingerprintDataLoader() {} |
| 271 | 272 |
| 272 // content::GpuDataManagerObserver: | 273 // content::GpuDataManagerObserver: |
| 273 virtual void OnGpuInfoUpdate() OVERRIDE; | 274 virtual void OnGpuInfoUpdate() OVERRIDE; |
| 274 | 275 |
| 275 // Callbacks for asynchronously loaded data. | 276 // Callbacks for asynchronously loaded data. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 294 | 295 |
| 295 // Data that will be passed on to the next loading phase. See the comment for | 296 // Data that will be passed on to the next loading phase. See the comment for |
| 296 // GetFingerprint() for a description of these variables. | 297 // GetFingerprint() for a description of these variables. |
| 297 const uint64 obfuscated_gaia_id_; | 298 const uint64 obfuscated_gaia_id_; |
| 298 const gfx::Rect window_bounds_; | 299 const gfx::Rect window_bounds_; |
| 299 const gfx::Rect content_bounds_; | 300 const gfx::Rect content_bounds_; |
| 300 const WebScreenInfo screen_info_; | 301 const WebScreenInfo screen_info_; |
| 301 const std::string version_; | 302 const std::string version_; |
| 302 const std::string charset_; | 303 const std::string charset_; |
| 303 const std::string accept_languages_; | 304 const std::string accept_languages_; |
| 305 const std::string app_locale_; |
| 306 const std::string user_agent_; |
| 304 const base::Time install_time_; | 307 const base::Time install_time_; |
| 305 | 308 |
| 306 // Data that will be loaded asynchronously. | 309 // Data that will be loaded asynchronously. |
| 307 scoped_ptr<base::ListValue> fonts_; | 310 scoped_ptr<base::ListValue> fonts_; |
| 308 std::vector<content::WebPluginInfo> plugins_; | 311 std::vector<content::WebPluginInfo> plugins_; |
| 309 bool waiting_on_plugins_; | 312 bool waiting_on_plugins_; |
| 310 content::Geoposition geoposition_; | 313 content::Geoposition geoposition_; |
| 311 | 314 |
| 312 // Timer to enforce a maximum timeout before the |callback_| is called, even | 315 // Timer to enforce a maximum timeout before the |callback_| is called, even |
| 313 // if not all asynchronous data has been loaded. | 316 // if not all asynchronous data has been loaded. |
| 314 base::OneShotTimer<FingerprintDataLoader> timeout_timer_; | 317 base::OneShotTimer<FingerprintDataLoader> timeout_timer_; |
| 315 | 318 |
| 316 // For invalidating asynchronous callbacks that might arrive after |this| | 319 // For invalidating asynchronous callbacks that might arrive after |this| |
| 317 // instance is destroyed. | 320 // instance is destroyed. |
| 318 base::WeakPtrFactory<FingerprintDataLoader> weak_ptr_factory_; | 321 base::WeakPtrFactory<FingerprintDataLoader> weak_ptr_factory_; |
| 319 | 322 |
| 320 // The current application locale. | |
| 321 std::string app_locale_; | |
| 322 | |
| 323 // The callback that will be called once all the data is available. | 323 // The callback that will be called once all the data is available. |
| 324 base::Callback<void(scoped_ptr<Fingerprint>)> callback_; | 324 base::Callback<void(scoped_ptr<Fingerprint>)> callback_; |
| 325 | 325 |
| 326 DISALLOW_COPY_AND_ASSIGN(FingerprintDataLoader); | 326 DISALLOW_COPY_AND_ASSIGN(FingerprintDataLoader); |
| 327 }; | 327 }; |
| 328 | 328 |
| 329 FingerprintDataLoader::FingerprintDataLoader( | 329 FingerprintDataLoader::FingerprintDataLoader( |
| 330 uint64 obfuscated_gaia_id, | 330 uint64 obfuscated_gaia_id, |
| 331 const gfx::Rect& window_bounds, | 331 const gfx::Rect& window_bounds, |
| 332 const gfx::Rect& content_bounds, | 332 const gfx::Rect& content_bounds, |
| 333 const WebScreenInfo& screen_info, | 333 const WebScreenInfo& screen_info, |
| 334 const std::string& version, | 334 const std::string& version, |
| 335 const std::string& charset, | 335 const std::string& charset, |
| 336 const std::string& accept_languages, | 336 const std::string& accept_languages, |
| 337 const base::Time& install_time, | 337 const base::Time& install_time, |
| 338 const std::string& app_locale, | 338 const std::string& app_locale, |
| 339 const std::string& user_agent, |
| 339 const base::TimeDelta& timeout, | 340 const base::TimeDelta& timeout, |
| 340 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) | 341 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) |
| 341 : gpu_data_manager_(content::GpuDataManager::GetInstance()), | 342 : gpu_data_manager_(content::GpuDataManager::GetInstance()), |
| 342 gpu_observer_(this), | 343 gpu_observer_(this), |
| 343 obfuscated_gaia_id_(obfuscated_gaia_id), | 344 obfuscated_gaia_id_(obfuscated_gaia_id), |
| 344 window_bounds_(window_bounds), | 345 window_bounds_(window_bounds), |
| 345 content_bounds_(content_bounds), | 346 content_bounds_(content_bounds), |
| 346 screen_info_(screen_info), | 347 screen_info_(screen_info), |
| 347 version_(version), | 348 version_(version), |
| 348 charset_(charset), | 349 charset_(charset), |
| 349 accept_languages_(accept_languages), | 350 accept_languages_(accept_languages), |
| 351 app_locale_(app_locale), |
| 352 user_agent_(user_agent), |
| 350 install_time_(install_time), | 353 install_time_(install_time), |
| 351 waiting_on_plugins_(true), | 354 waiting_on_plugins_(true), |
| 352 weak_ptr_factory_(this), | 355 weak_ptr_factory_(this), |
| 353 callback_(callback) { | 356 callback_(callback) { |
| 354 DCHECK(!install_time_.is_null()); | 357 DCHECK(!install_time_.is_null()); |
| 355 | 358 |
| 356 timeout_timer_.Start(FROM_HERE, timeout, | 359 timeout_timer_.Start(FROM_HERE, timeout, |
| 357 base::Bind(&FingerprintDataLoader::MaybeFillFingerprint, | 360 base::Bind(&FingerprintDataLoader::MaybeFillFingerprint, |
| 358 weak_ptr_factory_.GetWeakPtr())); | 361 weak_ptr_factory_.GetWeakPtr())); |
| 359 | 362 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 Fingerprint::MachineCharacteristics* machine = | 441 Fingerprint::MachineCharacteristics* machine = |
| 439 fingerprint->mutable_machine_characteristics(); | 442 fingerprint->mutable_machine_characteristics(); |
| 440 | 443 |
| 441 machine->set_operating_system_build(GetOperatingSystemVersion()); | 444 machine->set_operating_system_build(GetOperatingSystemVersion()); |
| 442 // We use the delta between the install time and the Unix epoch, in hours. | 445 // We use the delta between the install time and the Unix epoch, in hours. |
| 443 machine->set_browser_install_time_hours( | 446 machine->set_browser_install_time_hours( |
| 444 (install_time_ - base::Time::UnixEpoch()).InHours()); | 447 (install_time_ - base::Time::UnixEpoch()).InHours()); |
| 445 machine->set_utc_offset_ms(GetTimezoneOffset().InMilliseconds()); | 448 machine->set_utc_offset_ms(GetTimezoneOffset().InMilliseconds()); |
| 446 machine->set_browser_language(app_locale_); | 449 machine->set_browser_language(app_locale_); |
| 447 machine->set_charset(charset_); | 450 machine->set_charset(charset_); |
| 448 machine->set_user_agent(content::GetUserAgent(GURL())); | 451 machine->set_user_agent(user_agent_); |
| 449 machine->set_ram(base::SysInfo::AmountOfPhysicalMemory()); | 452 machine->set_ram(base::SysInfo::AmountOfPhysicalMemory()); |
| 450 machine->set_browser_build(version_); | 453 machine->set_browser_build(version_); |
| 451 machine->set_browser_feature( | 454 machine->set_browser_feature( |
| 452 Fingerprint::MachineCharacteristics::FEATURE_REQUEST_AUTOCOMPLETE); | 455 Fingerprint::MachineCharacteristics::FEATURE_REQUEST_AUTOCOMPLETE); |
| 453 if (fonts_) | 456 if (fonts_) |
| 454 AddFontsToFingerprint(*fonts_, machine); | 457 AddFontsToFingerprint(*fonts_, machine); |
| 455 AddPluginsToFingerprint(plugins_, machine); | 458 AddPluginsToFingerprint(plugins_, machine); |
| 456 AddAcceptLanguagesToFingerprint(accept_languages_, machine); | 459 AddAcceptLanguagesToFingerprint(accept_languages_, machine); |
| 457 AddScreenInfoToFingerprint(screen_info_, machine); | 460 AddScreenInfoToFingerprint(screen_info_, machine); |
| 458 AddCpuInfoToFingerprint(machine); | 461 AddCpuInfoToFingerprint(machine); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 void GetFingerprintInternal( | 507 void GetFingerprintInternal( |
| 505 uint64 obfuscated_gaia_id, | 508 uint64 obfuscated_gaia_id, |
| 506 const gfx::Rect& window_bounds, | 509 const gfx::Rect& window_bounds, |
| 507 const gfx::Rect& content_bounds, | 510 const gfx::Rect& content_bounds, |
| 508 const blink::WebScreenInfo& screen_info, | 511 const blink::WebScreenInfo& screen_info, |
| 509 const std::string& version, | 512 const std::string& version, |
| 510 const std::string& charset, | 513 const std::string& charset, |
| 511 const std::string& accept_languages, | 514 const std::string& accept_languages, |
| 512 const base::Time& install_time, | 515 const base::Time& install_time, |
| 513 const std::string& app_locale, | 516 const std::string& app_locale, |
| 517 const std::string& user_agent, |
| 514 const base::TimeDelta& timeout, | 518 const base::TimeDelta& timeout, |
| 515 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) { | 519 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) { |
| 516 // Begin loading all of the data that we need to load asynchronously. | 520 // Begin loading all of the data that we need to load asynchronously. |
| 517 // This class is responsible for freeing its own memory. | 521 // This class is responsible for freeing its own memory. |
| 518 new FingerprintDataLoader(obfuscated_gaia_id, window_bounds, content_bounds, | 522 new FingerprintDataLoader(obfuscated_gaia_id, window_bounds, content_bounds, |
| 519 screen_info, version, charset, accept_languages, | 523 screen_info, version, charset, accept_languages, |
| 520 install_time, app_locale, timeout, callback); | 524 install_time, app_locale, user_agent, timeout, |
| 525 callback); |
| 521 } | 526 } |
| 522 | 527 |
| 523 } // namespace internal | 528 } // namespace internal |
| 524 | 529 |
| 525 void GetFingerprint( | 530 void GetFingerprint( |
| 526 uint64 obfuscated_gaia_id, | 531 uint64 obfuscated_gaia_id, |
| 527 const gfx::Rect& window_bounds, | 532 const gfx::Rect& window_bounds, |
| 528 const content::WebContents& web_contents, | 533 const content::WebContents& web_contents, |
| 529 const std::string& version, | 534 const std::string& version, |
| 530 const std::string& charset, | 535 const std::string& charset, |
| 531 const std::string& accept_languages, | 536 const std::string& accept_languages, |
| 532 const base::Time& install_time, | 537 const base::Time& install_time, |
| 533 const std::string& app_locale, | 538 const std::string& app_locale, |
| 539 const std::string& user_agent, |
| 534 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) { | 540 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) { |
| 535 gfx::Rect content_bounds; | 541 gfx::Rect content_bounds; |
| 536 web_contents.GetView()->GetContainerBounds(&content_bounds); | 542 web_contents.GetView()->GetContainerBounds(&content_bounds); |
| 537 | 543 |
| 538 blink::WebScreenInfo screen_info; | 544 blink::WebScreenInfo screen_info; |
| 539 content::RenderWidgetHostView* host_view = | 545 content::RenderWidgetHostView* host_view = |
| 540 web_contents.GetRenderWidgetHostView(); | 546 web_contents.GetRenderWidgetHostView(); |
| 541 if (host_view) | 547 if (host_view) |
| 542 host_view->GetRenderWidgetHost()->GetWebScreenInfo(&screen_info); | 548 host_view->GetRenderWidgetHost()->GetWebScreenInfo(&screen_info); |
| 543 | 549 |
| 544 internal::GetFingerprintInternal( | 550 internal::GetFingerprintInternal( |
| 545 obfuscated_gaia_id, window_bounds, content_bounds, screen_info, version, | 551 obfuscated_gaia_id, window_bounds, content_bounds, screen_info, version, |
| 546 charset, accept_languages, install_time, app_locale, | 552 charset, accept_languages, install_time, app_locale, user_agent, |
| 547 base::TimeDelta::FromSeconds(kTimeoutSeconds), callback); | 553 base::TimeDelta::FromSeconds(kTimeoutSeconds), callback); |
| 548 } | 554 } |
| 549 | 555 |
| 550 } // namespace risk | 556 } // namespace risk |
| 551 } // namespace autofill | 557 } // namespace autofill |
| OLD | NEW |