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

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

Issue 23537014: rAc: Get rid of dialog type in rAc, there is only one type left now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | Annotate | Revision Log
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return base::Time::FromUTCExploded(local) - utc; 61 return base::Time::FromUTCExploded(local) - utc;
62 } 62 }
63 63
64 // Returns the concatenation of the operating system name and version, e.g. 64 // Returns the concatenation of the operating system name and version, e.g.
65 // "Mac OS X 10.6.8". 65 // "Mac OS X 10.6.8".
66 std::string GetOperatingSystemVersion() { 66 std::string GetOperatingSystemVersion() {
67 return base::SysInfo::OperatingSystemName() + " " + 67 return base::SysInfo::OperatingSystemName() + " " +
68 base::SysInfo::OperatingSystemVersion(); 68 base::SysInfo::OperatingSystemVersion();
69 } 69 }
70 70
71 Fingerprint::MachineCharacteristics::BrowserFeature
72 DialogTypeToBrowserFeature(DialogType dialog_type) {
73 switch (dialog_type) {
74 case DIALOG_TYPE_AUTOCHECKOUT:
75 return Fingerprint::MachineCharacteristics::FEATURE_AUTOCHECKOUT;
76
77 case DIALOG_TYPE_REQUEST_AUTOCOMPLETE:
78 return Fingerprint::MachineCharacteristics::FEATURE_REQUEST_AUTOCOMPLETE;
79 }
80
81 NOTREACHED();
82 return Fingerprint::MachineCharacteristics::FEATURE_UNKNOWN;
83 }
84
85 // Adds the list of |fonts| to the |machine|. 71 // Adds the list of |fonts| to the |machine|.
86 void AddFontsToFingerprint(const base::ListValue& fonts, 72 void AddFontsToFingerprint(const base::ListValue& fonts,
87 Fingerprint::MachineCharacteristics* machine) { 73 Fingerprint::MachineCharacteristics* machine) {
88 for (base::ListValue::const_iterator it = fonts.begin(); 74 for (base::ListValue::const_iterator it = fonts.begin();
89 it != fonts.end(); ++it) { 75 it != fonts.end(); ++it) {
90 // Each item in the list is a two-element list such that the first element 76 // Each item in the list is a two-element list such that the first element
91 // is the font family and the second is the font name. 77 // is the font family and the second is the font name.
92 const base::ListValue* font_description = NULL; 78 const base::ListValue* font_description = NULL;
93 bool success = (*it)->GetAsList(&font_description); 79 bool success = (*it)->GetAsList(&font_description);
94 DCHECK(success); 80 DCHECK(success);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 public: 180 public:
195 FingerprintDataLoader( 181 FingerprintDataLoader(
196 uint64 obfuscated_gaia_id, 182 uint64 obfuscated_gaia_id,
197 const gfx::Rect& window_bounds, 183 const gfx::Rect& window_bounds,
198 const gfx::Rect& content_bounds, 184 const gfx::Rect& content_bounds,
199 const WebScreenInfo& screen_info, 185 const WebScreenInfo& screen_info,
200 const std::string& version, 186 const std::string& version,
201 const std::string& charset, 187 const std::string& charset,
202 const std::string& accept_languages, 188 const std::string& accept_languages,
203 const base::Time& install_time, 189 const base::Time& install_time,
204 DialogType dialog_type,
205 const std::string& app_locale, 190 const std::string& app_locale,
206 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback); 191 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback);
207 192
208 private: 193 private:
209 virtual ~FingerprintDataLoader() {} 194 virtual ~FingerprintDataLoader() {}
210 195
211 // content::GpuDataManagerObserver: 196 // content::GpuDataManagerObserver:
212 virtual void OnGpuInfoUpdate() OVERRIDE; 197 virtual void OnGpuInfoUpdate() OVERRIDE;
213 198
214 // Callbacks for asynchronously loaded data. 199 // Callbacks for asynchronously loaded data.
(...skipping 28 matching lines...) Expand all
243 // Data that will be passed on to the next loading phase. See the comment for 228 // Data that will be passed on to the next loading phase. See the comment for
244 // GetFingerprint() for a description of these variables. 229 // GetFingerprint() for a description of these variables.
245 const uint64 obfuscated_gaia_id_; 230 const uint64 obfuscated_gaia_id_;
246 const gfx::Rect window_bounds_; 231 const gfx::Rect window_bounds_;
247 const gfx::Rect content_bounds_; 232 const gfx::Rect content_bounds_;
248 const WebScreenInfo screen_info_; 233 const WebScreenInfo screen_info_;
249 const std::string version_; 234 const std::string version_;
250 const std::string charset_; 235 const std::string charset_;
251 const std::string accept_languages_; 236 const std::string accept_languages_;
252 const base::Time install_time_; 237 const base::Time install_time_;
253 DialogType dialog_type_;
254 238
255 // Data that will be loaded asynchronously. 239 // Data that will be loaded asynchronously.
256 scoped_ptr<base::ListValue> fonts_; 240 scoped_ptr<base::ListValue> fonts_;
257 std::vector<content::WebPluginInfo> plugins_; 241 std::vector<content::WebPluginInfo> plugins_;
258 bool waiting_on_plugins_; 242 bool waiting_on_plugins_;
259 content::Geoposition geoposition_; 243 content::Geoposition geoposition_;
260 244
261 // The current application locale. 245 // The current application locale.
262 std::string app_locale_; 246 std::string app_locale_;
263 247
264 // The callback that will be called once all the data is available. 248 // The callback that will be called once all the data is available.
265 base::Callback<void(scoped_ptr<Fingerprint>)> callback_; 249 base::Callback<void(scoped_ptr<Fingerprint>)> callback_;
266 250
267 DISALLOW_COPY_AND_ASSIGN(FingerprintDataLoader); 251 DISALLOW_COPY_AND_ASSIGN(FingerprintDataLoader);
268 }; 252 };
269 253
270 FingerprintDataLoader::FingerprintDataLoader( 254 FingerprintDataLoader::FingerprintDataLoader(
271 uint64 obfuscated_gaia_id, 255 uint64 obfuscated_gaia_id,
272 const gfx::Rect& window_bounds, 256 const gfx::Rect& window_bounds,
273 const gfx::Rect& content_bounds, 257 const gfx::Rect& content_bounds,
274 const WebScreenInfo& screen_info, 258 const WebScreenInfo& screen_info,
275 const std::string& version, 259 const std::string& version,
276 const std::string& charset, 260 const std::string& charset,
277 const std::string& accept_languages, 261 const std::string& accept_languages,
278 const base::Time& install_time, 262 const base::Time& install_time,
279 DialogType dialog_type,
280 const std::string& app_locale, 263 const std::string& app_locale,
281 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) 264 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback)
282 : gpu_data_manager_(content::GpuDataManager::GetInstance()), 265 : gpu_data_manager_(content::GpuDataManager::GetInstance()),
283 gpu_observer_(this), 266 gpu_observer_(this),
284 obfuscated_gaia_id_(obfuscated_gaia_id), 267 obfuscated_gaia_id_(obfuscated_gaia_id),
285 window_bounds_(window_bounds), 268 window_bounds_(window_bounds),
286 content_bounds_(content_bounds), 269 content_bounds_(content_bounds),
287 screen_info_(screen_info), 270 screen_info_(screen_info),
288 version_(version), 271 version_(version),
289 charset_(charset), 272 charset_(charset),
290 accept_languages_(accept_languages), 273 accept_languages_(accept_languages),
291 install_time_(install_time), 274 install_time_(install_time),
292 dialog_type_(dialog_type),
293 waiting_on_plugins_(true), 275 waiting_on_plugins_(true),
294 callback_(callback) { 276 callback_(callback) {
295 DCHECK(!install_time_.is_null()); 277 DCHECK(!install_time_.is_null());
296 278
297 // Load GPU data if needed. 279 // Load GPU data if needed.
298 if (!gpu_data_manager_->IsCompleteGpuInfoAvailable()) { 280 if (!gpu_data_manager_->IsCompleteGpuInfoAvailable()) {
299 gpu_observer_.Add(gpu_data_manager_); 281 gpu_observer_.Add(gpu_data_manager_);
300 gpu_data_manager_->RequestCompleteGpuInfoIfNeeded(); 282 gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
301 } 283 }
302 284
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 machine->set_operating_system_build(GetOperatingSystemVersion()); 379 machine->set_operating_system_build(GetOperatingSystemVersion());
398 // We use the delta between the install time and the Unix epoch, in hours. 380 // We use the delta between the install time and the Unix epoch, in hours.
399 machine->set_browser_install_time_hours( 381 machine->set_browser_install_time_hours(
400 (install_time_ - base::Time::UnixEpoch()).InHours()); 382 (install_time_ - base::Time::UnixEpoch()).InHours());
401 machine->set_utc_offset_ms(GetTimezoneOffset().InMilliseconds()); 383 machine->set_utc_offset_ms(GetTimezoneOffset().InMilliseconds());
402 machine->set_browser_language(app_locale_); 384 machine->set_browser_language(app_locale_);
403 machine->set_charset(charset_); 385 machine->set_charset(charset_);
404 machine->set_user_agent(content::GetUserAgent(GURL())); 386 machine->set_user_agent(content::GetUserAgent(GURL()));
405 machine->set_ram(base::SysInfo::AmountOfPhysicalMemory()); 387 machine->set_ram(base::SysInfo::AmountOfPhysicalMemory());
406 machine->set_browser_build(version_); 388 machine->set_browser_build(version_);
407 machine->set_browser_feature(DialogTypeToBrowserFeature(dialog_type_)); 389 machine->set_browser_feature(
390 Fingerprint::MachineCharacteristics::FEATURE_REQUEST_AUTOCOMPLETE);
408 AddFontsToFingerprint(*fonts_, machine); 391 AddFontsToFingerprint(*fonts_, machine);
409 AddPluginsToFingerprint(plugins_, machine); 392 AddPluginsToFingerprint(plugins_, machine);
410 AddAcceptLanguagesToFingerprint(accept_languages_, machine); 393 AddAcceptLanguagesToFingerprint(accept_languages_, machine);
411 AddScreenInfoToFingerprint(screen_info_, machine); 394 AddScreenInfoToFingerprint(screen_info_, machine);
412 AddCpuInfoToFingerprint(machine); 395 AddCpuInfoToFingerprint(machine);
413 AddGpuInfoToFingerprint(machine); 396 AddGpuInfoToFingerprint(machine);
414 397
415 // TODO(isherman): Record the user_and_device_name_hash. 398 // TODO(isherman): Record the user_and_device_name_hash.
416 // TODO(isherman): Record the partition size of the hard drives? 399 // TODO(isherman): Record the partition size of the hard drives?
417 400
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 439
457 void GetFingerprintInternal( 440 void GetFingerprintInternal(
458 uint64 obfuscated_gaia_id, 441 uint64 obfuscated_gaia_id,
459 const gfx::Rect& window_bounds, 442 const gfx::Rect& window_bounds,
460 const gfx::Rect& content_bounds, 443 const gfx::Rect& content_bounds,
461 const WebKit::WebScreenInfo& screen_info, 444 const WebKit::WebScreenInfo& screen_info,
462 const std::string& version, 445 const std::string& version,
463 const std::string& charset, 446 const std::string& charset,
464 const std::string& accept_languages, 447 const std::string& accept_languages,
465 const base::Time& install_time, 448 const base::Time& install_time,
466 DialogType dialog_type,
467 const std::string& app_locale, 449 const std::string& app_locale,
468 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) { 450 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) {
469 // Begin loading all of the data that we need to load asynchronously. 451 // Begin loading all of the data that we need to load asynchronously.
470 // This class is responsible for freeing its own memory. 452 // This class is responsible for freeing its own memory.
471 new FingerprintDataLoader(obfuscated_gaia_id, window_bounds, content_bounds, 453 new FingerprintDataLoader(obfuscated_gaia_id, window_bounds, content_bounds,
472 screen_info, version, charset, accept_languages, 454 screen_info, version, charset, accept_languages,
473 install_time, dialog_type, app_locale, callback); 455 install_time, app_locale, callback);
474 } 456 }
475 457
476 } // namespace internal 458 } // namespace internal
477 459
478 void GetFingerprint( 460 void GetFingerprint(
479 uint64 obfuscated_gaia_id, 461 uint64 obfuscated_gaia_id,
480 const gfx::Rect& window_bounds, 462 const gfx::Rect& window_bounds,
481 const content::WebContents& web_contents, 463 const content::WebContents& web_contents,
482 const std::string& version, 464 const std::string& version,
483 const std::string& charset, 465 const std::string& charset,
484 const std::string& accept_languages, 466 const std::string& accept_languages,
485 const base::Time& install_time, 467 const base::Time& install_time,
486 DialogType dialog_type,
487 const std::string& app_locale, 468 const std::string& app_locale,
488 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) { 469 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) {
489 gfx::Rect content_bounds; 470 gfx::Rect content_bounds;
490 web_contents.GetView()->GetContainerBounds(&content_bounds); 471 web_contents.GetView()->GetContainerBounds(&content_bounds);
491 472
492 WebKit::WebScreenInfo screen_info; 473 WebKit::WebScreenInfo screen_info;
493 content::RenderWidgetHostView* host_view = 474 content::RenderWidgetHostView* host_view =
494 web_contents.GetRenderWidgetHostView(); 475 web_contents.GetRenderWidgetHostView();
495 if (host_view) 476 if (host_view)
496 host_view->GetRenderWidgetHost()->GetWebScreenInfo(&screen_info); 477 host_view->GetRenderWidgetHost()->GetWebScreenInfo(&screen_info);
497 478
498 internal::GetFingerprintInternal( 479 internal::GetFingerprintInternal(
499 obfuscated_gaia_id, window_bounds, content_bounds, screen_info, version, 480 obfuscated_gaia_id, window_bounds, content_bounds, screen_info, version,
500 charset, accept_languages, install_time, dialog_type, app_locale, 481 charset, accept_languages, install_time, app_locale, callback);
501 callback);
502 } 482 }
503 483
504 } // namespace risk 484 } // namespace risk
505 } // namespace autofill 485 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/browser/risk/fingerprint.h ('k') | components/autofill/content/browser/wallet/wallet_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698