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

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

Issue 2317563004: Change blink::WebScreenInfo to content::ScreenInfo (Closed)
Patch Set: Fix Windows compile Created 4 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 18 matching lines...) Expand all
29 #include "base/values.h" 29 #include "base/values.h"
30 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" 30 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/font_list_async.h" 32 #include "content/public/browser/font_list_async.h"
33 #include "content/public/browser/gpu_data_manager.h" 33 #include "content/public/browser/gpu_data_manager.h"
34 #include "content/public/browser/gpu_data_manager_observer.h" 34 #include "content/public/browser/gpu_data_manager_observer.h"
35 #include "content/public/browser/plugin_service.h" 35 #include "content/public/browser/plugin_service.h"
36 #include "content/public/browser/render_widget_host.h" 36 #include "content/public/browser/render_widget_host.h"
37 #include "content/public/browser/render_widget_host_view.h" 37 #include "content/public/browser/render_widget_host_view.h"
38 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
39 #include "content/public/common/screen_info.h"
39 #include "content/public/common/webplugininfo.h" 40 #include "content/public/common/webplugininfo.h"
40 #include "device/geolocation/geolocation_provider.h" 41 #include "device/geolocation/geolocation_provider.h"
41 #include "device/geolocation/geoposition.h" 42 #include "device/geolocation/geoposition.h"
42 #include "gpu/config/gpu_info.h" 43 #include "gpu/config/gpu_info.h"
43 #include "third_party/WebKit/public/platform/WebRect.h" 44 #include "third_party/WebKit/public/platform/WebRect.h"
44 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
45 #include "ui/display/display.h" 45 #include "ui/display/display.h"
46 #include "ui/display/screen.h" 46 #include "ui/display/screen.h"
47 #include "ui/gfx/geometry/rect.h" 47 #include "ui/gfx/geometry/rect.h"
48 48
49 using blink::WebScreenInfo;
50
51 namespace autofill { 49 namespace autofill {
52 namespace risk { 50 namespace risk {
53 51
54 namespace { 52 namespace {
55 53
56 const int32_t kFingerprinterVersion = 1; 54 const int32_t kFingerprinterVersion = 1;
57 55
58 // Maximum amount of time, in seconds, to wait for loading asynchronous 56 // Maximum amount of time, in seconds, to wait for loading asynchronous
59 // fingerprint data. 57 // fingerprint data.
60 const int kTimeoutSeconds = 4; 58 const int kTimeoutSeconds = 4;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 machine->add_requested_language(lang); 120 machine->add_requested_language(lang);
123 } 121 }
124 122
125 // This function writes 123 // This function writes
126 // (a) the number of screens, 124 // (a) the number of screens,
127 // (b) the primary display's screen size, 125 // (b) the primary display's screen size,
128 // (c) the screen's color depth, and 126 // (c) the screen's color depth, and
129 // (d) the size of the screen unavailable to web page content, 127 // (d) the size of the screen unavailable to web page content,
130 // i.e. the Taskbar size on Windows 128 // i.e. the Taskbar size on Windows
131 // into the |machine|. 129 // into the |machine|.
132 void AddScreenInfoToFingerprint(const WebScreenInfo& screen_info, 130 void AddScreenInfoToFingerprint(const content::ScreenInfo& screen_info,
133 Fingerprint::MachineCharacteristics* machine) { 131 Fingerprint::MachineCharacteristics* machine) {
134 machine->set_screen_count(display::Screen::GetScreen()->GetNumDisplays()); 132 machine->set_screen_count(display::Screen::GetScreen()->GetNumDisplays());
135 133
136 const gfx::Size screen_size = 134 const gfx::Size screen_size =
137 display::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel(); 135 display::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel();
138 machine->mutable_screen_size()->set_width(screen_size.width()); 136 machine->mutable_screen_size()->set_width(screen_size.width());
139 machine->mutable_screen_size()->set_height(screen_size.height()); 137 machine->mutable_screen_size()->set_height(screen_size.height());
140 138
141 machine->set_screen_color_depth(screen_info.depth); 139 machine->set_screen_color_depth(screen_info.depth);
142 140
143 const gfx::Rect screen_rect(screen_info.rect); 141 const gfx::Rect screen_rect(screen_info.rect);
144 const gfx::Rect available_rect(screen_info.availableRect); 142 const gfx::Rect available_rect(screen_info.available_rect);
145 const gfx::Rect unavailable_rect = 143 const gfx::Rect unavailable_rect =
146 gfx::SubtractRects(screen_rect, available_rect); 144 gfx::SubtractRects(screen_rect, available_rect);
147 machine->mutable_unavailable_screen_size()->set_width( 145 machine->mutable_unavailable_screen_size()->set_width(
148 unavailable_rect.width()); 146 unavailable_rect.width());
149 machine->mutable_unavailable_screen_size()->set_height( 147 machine->mutable_unavailable_screen_size()->set_height(
150 unavailable_rect.height()); 148 unavailable_rect.height());
151 } 149 }
152 150
153 // Writes info about the machine's CPU into the |machine|. 151 // Writes info about the machine's CPU into the |machine|.
154 void AddCpuInfoToFingerprint(Fingerprint::MachineCharacteristics* machine) { 152 void AddCpuInfoToFingerprint(Fingerprint::MachineCharacteristics* machine) {
(...skipping 19 matching lines...) Expand all
174 } 172 }
175 173
176 // Waits for all asynchronous data required for the fingerprint to be loaded, 174 // Waits for all asynchronous data required for the fingerprint to be loaded,
177 // then fills out the fingerprint. 175 // then fills out the fingerprint.
178 class FingerprintDataLoader : public content::GpuDataManagerObserver { 176 class FingerprintDataLoader : public content::GpuDataManagerObserver {
179 public: 177 public:
180 FingerprintDataLoader( 178 FingerprintDataLoader(
181 uint64_t obfuscated_gaia_id, 179 uint64_t obfuscated_gaia_id,
182 const gfx::Rect& window_bounds, 180 const gfx::Rect& window_bounds,
183 const gfx::Rect& content_bounds, 181 const gfx::Rect& content_bounds,
184 const WebScreenInfo& screen_info, 182 const content::ScreenInfo& screen_info,
185 const std::string& version, 183 const std::string& version,
186 const std::string& charset, 184 const std::string& charset,
187 const std::string& accept_languages, 185 const std::string& accept_languages,
188 const base::Time& install_time, 186 const base::Time& install_time,
189 const std::string& app_locale, 187 const std::string& app_locale,
190 const std::string& user_agent, 188 const std::string& user_agent,
191 const base::TimeDelta& timeout, 189 const base::TimeDelta& timeout,
192 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback); 190 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback);
193 191
194 private: 192 private:
(...skipping 20 matching lines...) Expand all
215 213
216 // Ensures that any observer registrations for the GPU data are cleaned up by 214 // Ensures that any observer registrations for the GPU data are cleaned up by
217 // the time this object is destroyed. 215 // the time this object is destroyed.
218 ScopedObserver<content::GpuDataManager, FingerprintDataLoader> gpu_observer_; 216 ScopedObserver<content::GpuDataManager, FingerprintDataLoader> gpu_observer_;
219 217
220 // Data that will be passed on to the next loading phase. See the comment for 218 // Data that will be passed on to the next loading phase. See the comment for
221 // GetFingerprint() for a description of these variables. 219 // GetFingerprint() for a description of these variables.
222 const uint64_t obfuscated_gaia_id_; 220 const uint64_t obfuscated_gaia_id_;
223 const gfx::Rect window_bounds_; 221 const gfx::Rect window_bounds_;
224 const gfx::Rect content_bounds_; 222 const gfx::Rect content_bounds_;
225 const WebScreenInfo screen_info_; 223 const content::ScreenInfo screen_info_;
226 const std::string version_; 224 const std::string version_;
227 const std::string charset_; 225 const std::string charset_;
228 const std::string accept_languages_; 226 const std::string accept_languages_;
229 const std::string app_locale_; 227 const std::string app_locale_;
230 const std::string user_agent_; 228 const std::string user_agent_;
231 const base::Time install_time_; 229 const base::Time install_time_;
232 230
233 // Data that will be loaded asynchronously. 231 // Data that will be loaded asynchronously.
234 std::unique_ptr<base::ListValue> fonts_; 232 std::unique_ptr<base::ListValue> fonts_;
235 std::vector<content::WebPluginInfo> plugins_; 233 std::vector<content::WebPluginInfo> plugins_;
(...skipping 15 matching lines...) Expand all
251 // instance is destroyed. 249 // instance is destroyed.
252 base::WeakPtrFactory<FingerprintDataLoader> weak_ptr_factory_; 250 base::WeakPtrFactory<FingerprintDataLoader> weak_ptr_factory_;
253 251
254 DISALLOW_COPY_AND_ASSIGN(FingerprintDataLoader); 252 DISALLOW_COPY_AND_ASSIGN(FingerprintDataLoader);
255 }; 253 };
256 254
257 FingerprintDataLoader::FingerprintDataLoader( 255 FingerprintDataLoader::FingerprintDataLoader(
258 uint64_t obfuscated_gaia_id, 256 uint64_t obfuscated_gaia_id,
259 const gfx::Rect& window_bounds, 257 const gfx::Rect& window_bounds,
260 const gfx::Rect& content_bounds, 258 const gfx::Rect& content_bounds,
261 const WebScreenInfo& screen_info, 259 const content::ScreenInfo& screen_info,
262 const std::string& version, 260 const std::string& version,
263 const std::string& charset, 261 const std::string& charset,
264 const std::string& accept_languages, 262 const std::string& accept_languages,
265 const base::Time& install_time, 263 const base::Time& install_time,
266 const std::string& app_locale, 264 const std::string& app_locale,
267 const std::string& user_agent, 265 const std::string& user_agent,
268 const base::TimeDelta& timeout, 266 const base::TimeDelta& timeout,
269 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback) 267 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback)
270 : gpu_data_manager_(content::GpuDataManager::GetInstance()), 268 : gpu_data_manager_(content::GpuDataManager::GetInstance()),
271 gpu_observer_(this), 269 gpu_observer_(this),
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 429 }
432 430
433 } // namespace 431 } // namespace
434 432
435 namespace internal { 433 namespace internal {
436 434
437 void GetFingerprintInternal( 435 void GetFingerprintInternal(
438 uint64_t obfuscated_gaia_id, 436 uint64_t obfuscated_gaia_id,
439 const gfx::Rect& window_bounds, 437 const gfx::Rect& window_bounds,
440 const gfx::Rect& content_bounds, 438 const gfx::Rect& content_bounds,
441 const blink::WebScreenInfo& screen_info, 439 const content::ScreenInfo& screen_info,
442 const std::string& version, 440 const std::string& version,
443 const std::string& charset, 441 const std::string& charset,
444 const std::string& accept_languages, 442 const std::string& accept_languages,
445 const base::Time& install_time, 443 const base::Time& install_time,
446 const std::string& app_locale, 444 const std::string& app_locale,
447 const std::string& user_agent, 445 const std::string& user_agent,
448 const base::TimeDelta& timeout, 446 const base::TimeDelta& timeout,
449 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback) { 447 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback) {
450 // Begin loading all of the data that we need to load asynchronously. 448 // Begin loading all of the data that we need to load asynchronously.
451 // This class is responsible for freeing its own memory. 449 // This class is responsible for freeing its own memory.
(...skipping 11 matching lines...) Expand all
463 content::WebContents* web_contents, 461 content::WebContents* web_contents,
464 const std::string& version, 462 const std::string& version,
465 const std::string& charset, 463 const std::string& charset,
466 const std::string& accept_languages, 464 const std::string& accept_languages,
467 const base::Time& install_time, 465 const base::Time& install_time,
468 const std::string& app_locale, 466 const std::string& app_locale,
469 const std::string& user_agent, 467 const std::string& user_agent,
470 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback) { 468 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback) {
471 gfx::Rect content_bounds = web_contents->GetContainerBounds(); 469 gfx::Rect content_bounds = web_contents->GetContainerBounds();
472 470
473 blink::WebScreenInfo screen_info; 471 content::ScreenInfo screen_info;
474 const content::RenderWidgetHostView* host_view = 472 const content::RenderWidgetHostView* host_view =
475 web_contents->GetRenderWidgetHostView(); 473 web_contents->GetRenderWidgetHostView();
476 if (host_view) 474 if (host_view)
477 host_view->GetRenderWidgetHost()->GetWebScreenInfo(&screen_info); 475 host_view->GetRenderWidgetHost()->GetScreenInfo(&screen_info);
478 476
479 internal::GetFingerprintInternal( 477 internal::GetFingerprintInternal(
480 obfuscated_gaia_id, window_bounds, content_bounds, screen_info, version, 478 obfuscated_gaia_id, window_bounds, content_bounds, screen_info, version,
481 charset, accept_languages, install_time, app_locale, user_agent, 479 charset, accept_languages, install_time, app_locale, user_agent,
482 base::TimeDelta::FromSeconds(kTimeoutSeconds), callback); 480 base::TimeDelta::FromSeconds(kTimeoutSeconds), callback);
483 } 481 }
484 482
485 } // namespace risk 483 } // namespace risk
486 } // namespace autofill 484 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698