1e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "components/autofill/content/browser/risk/fingerprint.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/bind.h"
89ab5563a3196760eb381d102cbb2bc0f7abc6a50Ben Murdoch#include "base/message_loop/message_loop.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/port.h"
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "content/public/browser/geolocation_provider.h"
12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "content/public/browser/gpu_data_manager.h"
1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "content/public/common/geoposition.h"
14e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "content/public/test/content_browser_test.h"
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "content/public/test/test_utils.h"
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "testing/gmock/include/gmock/gmock.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h"
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "third_party/WebKit/public/platform/WebRect.h"
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "third_party/WebKit/public/platform/WebScreenInfo.h"
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/rect.h"
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)using testing::ElementsAre;
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace autofill {
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace risk {
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace internal {
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Defined in the implementation file corresponding to this test.
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void GetFingerprintInternal(
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    uint64 obfuscated_gaia_id,
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const gfx::Rect& window_bounds,
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const gfx::Rect& content_bounds,
34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    const blink::WebScreenInfo& screen_info,
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const std::string& version,
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const std::string& charset,
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const std::string& accept_languages,
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const base::Time& install_time,
39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const std::string& app_locale,
40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const std::string& user_agent,
41d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    const base::TimeDelta& timeout,
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const base::Callback<void(scoped_ptr<Fingerprint>)>& callback);
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}  // namespace internal
45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Constants that are passed verbatim to the fingerprinter code and should be
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// serialized into the resulting protocol buffer.
4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)const uint64 kObfuscatedGaiaId = GG_UINT64_C(16571487432910023183);
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char kCharset[] = "UTF-8";
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const char kAcceptLanguages[] = "en-US,en";
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kScreenColorDepth = 53;
52e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochconst char kLocale[] = "en-GB";
53e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochconst char kUserAgent[] = "TestUserAgent";
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Geolocation constants that are passed verbatim to the fingerprinter code and
56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// should be serialized into the resulting protocol buffer.
5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)const double kLatitude = -42.0;
5890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)const double kLongitude = 17.3;
5990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)const double kAltitude = 123.4;
6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)const double kAccuracy = 73.7;
6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)const int kGeolocationTime = 87;
6290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
63e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochclass AutofillRiskFingerprintTest : public content::ContentBrowserTest {
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  AutofillRiskFingerprintTest()
66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      : window_bounds_(2, 3, 5, 7),
67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        content_bounds_(11, 13, 17, 37),
68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        screen_bounds_(0, 0, 101, 71),
69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        available_screen_bounds_(0, 11, 101, 60),
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        unavailable_screen_bounds_(0, 0, 101, 11) {}
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void GetFingerprintTestCallback(scoped_ptr<Fingerprint> fingerprint) {
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // Verify that all fields Chrome can fill have been filled.
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(fingerprint->has_machine_characteristics());
75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const Fingerprint::MachineCharacteristics& machine =
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        fingerprint->machine_characteristics();
77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_operating_system_build());
78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_browser_install_time_hours());
79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_GT(machine.font_size(), 0);
801320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    // TODO(isherman): http://crbug.com/358548 and EXPECT_EQ.
821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    EXPECT_GE(machine.plugin_size(), 0);
831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_utc_offset_ms());
85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_browser_language());
86868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_GT(machine.requested_language_size(), 0);
87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_charset());
88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_screen_count());
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(machine.has_screen_size());
90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.screen_size().has_width());
91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.screen_size().has_height());
92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_screen_color_depth());
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(machine.has_unavailable_screen_size());
94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.unavailable_screen_size().has_width());
95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.unavailable_screen_size().has_height());
96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_user_agent());
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(machine.has_cpu());
98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.cpu().has_vendor_name());
99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.cpu().has_brand());
100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_ram());
101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_browser_build());
102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(machine.has_browser_feature());
103effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    if (content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) {
104effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      ASSERT_TRUE(machine.has_graphics_card());
105effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      EXPECT_TRUE(machine.graphics_card().has_vendor_id());
106effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      EXPECT_TRUE(machine.graphics_card().has_device_id());
107effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    } else {
108effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      EXPECT_FALSE(machine.has_graphics_card());
109effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch    }
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(fingerprint->has_transient_state());
112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const Fingerprint::TransientState& transient_state =
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        fingerprint->transient_state();
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(transient_state.has_inner_window_size());
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(transient_state.has_outer_window_size());
116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(transient_state.inner_window_size().has_width());
117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(transient_state.inner_window_size().has_height());
118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(transient_state.outer_window_size().has_width());
119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(transient_state.outer_window_size().has_height());
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
12190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    ASSERT_TRUE(fingerprint->has_user_characteristics());
122868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const Fingerprint::UserCharacteristics& user_characteristics =
12390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)        fingerprint->user_characteristics();
12490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    ASSERT_TRUE(user_characteristics.has_location());
125868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    const Fingerprint::UserCharacteristics::Location& location =
12690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)        user_characteristics.location();
127868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(location.has_altitude());
128868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(location.has_latitude());
129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(location.has_longitude());
130868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(location.has_accuracy());
131868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(location.has_time_in_ms());
13290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    ASSERT_TRUE(fingerprint->has_metadata());
134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(fingerprint->metadata().has_timestamp_ms());
135868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(fingerprint->metadata().has_obfuscated_gaia_id());
136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_TRUE(fingerprint->metadata().has_fingerprinter_version());
1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    // Some values have exact known (mocked out) values:
139868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_THAT(machine.requested_language(), ElementsAre("en-US", "en"));
140e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    EXPECT_EQ(kLocale, machine.browser_language());
141e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    EXPECT_EQ(kUserAgent, machine.user_agent());
1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EXPECT_EQ(kCharset, machine.charset());
1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EXPECT_EQ(kScreenColorDepth, machine.screen_color_depth());
144868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(unavailable_screen_bounds_.width(),
1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)              machine.unavailable_screen_size().width());
146868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(unavailable_screen_bounds_.height(),
1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)              machine.unavailable_screen_size().height());
14858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    EXPECT_EQ(Fingerprint::MachineCharacteristics::FEATURE_REQUEST_AUTOCOMPLETE,
149868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)              machine.browser_feature());
150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(content_bounds_.width(),
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)              transient_state.inner_window_size().width());
152868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(content_bounds_.height(),
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)              transient_state.inner_window_size().height());
154868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(window_bounds_.width(),
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)              transient_state.outer_window_size().width());
156868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(window_bounds_.height(),
1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)              transient_state.outer_window_size().height());
15890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    EXPECT_EQ(kObfuscatedGaiaId, fingerprint->metadata().obfuscated_gaia_id());
15990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    EXPECT_EQ(kAltitude, location.altitude());
16090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    EXPECT_EQ(kLatitude, location.latitude());
16190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    EXPECT_EQ(kLongitude, location.longitude());
16290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    EXPECT_EQ(kAccuracy, location.accuracy());
16390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    EXPECT_EQ(kGeolocationTime, location.time_in_ms());
1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    message_loop_.Quit();
1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected:
169868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Constants defining bounds in the screen coordinate system that are passed
170868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // verbatim to the fingerprinter code and should be serialized into the
171868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // resulting protocol buffer.  Declared as class members because gfx::Rect is
172868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // not a POD type, so it cannot be statically initialized.
173868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  const gfx::Rect window_bounds_;
174868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  const gfx::Rect content_bounds_;
175868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  const gfx::Rect screen_bounds_;
176868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  const gfx::Rect available_screen_bounds_;
177868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  const gfx::Rect unavailable_screen_bounds_;
178868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
179868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // A message loop to block on the asynchronous loading of the fingerprint.
1805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::MessageLoopForUI message_loop_;
1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Test that getting a fingerprint works on some basic level.
184eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen MurdochIN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, GetFingerprint) {
18590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  content::Geoposition position;
18690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  position.latitude = kLatitude;
18790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  position.longitude = kLongitude;
18890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  position.altitude = kAltitude;
18990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  position.accuracy = kAccuracy;
19090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  position.timestamp =
19190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      base::Time::UnixEpoch() +
19290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      base::TimeDelta::FromMilliseconds(kGeolocationTime);
193cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  content::GeolocationProvider::GetInstance()->OverrideLocationForTesting(
194cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)      position);
19590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
196f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  blink::WebScreenInfo screen_info;
1972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  screen_info.depth = kScreenColorDepth;
198f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  screen_info.rect = blink::WebRect(screen_bounds_);
199f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  screen_info.availableRect = blink::WebRect(available_screen_bounds_);
2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  internal::GetFingerprintInternal(
202868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      kObfuscatedGaiaId, window_bounds_, content_bounds_, screen_info,
203e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch      "25.0.0.123", kCharset, kAcceptLanguages, base::Time::Now(), kLocale,
204e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch      kUserAgent,
205d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)      base::TimeDelta::FromDays(1),  // Ought to be longer than any test run.
2062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback,
2072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                 base::Unretained(this)));
2082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Wait for the callback to be called.
2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  message_loop_.Run();
2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace risk
2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace autofill
215