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

Side by Side Diff: chrome/browser/autofill/risk/fingerprint_browsertest.cc

Issue 12212057: [Autofill] Add ability to load Risk fingerprint data in AutofillDialogControllerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/autofill/risk/fingerprint.h" 5 #include "chrome/browser/autofill/risk/fingerprint.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/port.h" 9 #include "base/port.h"
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/public/pref_service_base.h" 11 #include "base/prefs/public/pref_service_base.h"
12 #include "chrome/browser/autofill/risk/proto/fingerprint.pb.h" 12 #include "chrome/browser/autofill/risk/proto/fingerprint.pb.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/testing_pref_service.h" 15 #include "chrome/test/base/testing_pref_service.h"
16 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/render_widget_host.h"
18 #include "content/public/browser/render_widget_host_view.h"
19 #include "content/public/browser/session_storage_namespace.h"
20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_view.h"
22 #include "net/base/load_states.h"
16 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebScreenInfo.h" 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebScreenInfo.h"
26 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "ui/gfx/rect.h" 27 #include "ui/gfx/rect.h"
20 28
21 namespace autofill { 29 namespace autofill {
22 namespace risk { 30 namespace risk {
23 31
32 namespace {
33
34 using content::BrowserContext;
35 using content::InterstitialPage;
36 using content::KeyboardListener;
37 using content::NativeWebKeyboardEvent;
38 using content::NavigationController;
39 using content::NavigationEntry;
40 using content::OpenURLParams;
41 using content::PageTransition;
42 using content::RendererPreferences;
43 using content::RenderProcessHost;
44 using content::RenderViewHost;
45 using content::RenderWidgetHost;
46 using content::RenderWidgetHostImpl;
47 using content::RenderWidgetHostView;
48 using content::Referrer;
49 using content::SavePageType;
50 using content::SessionStorageNamespace;
51 using content::SessionStorageNamespaceMap;
52 using content::SiteInstance;
53 using content::WebContents;
54 using content::WebContentsDelegate;
55 using content::WebContentsView;
56 using content::WebUI;
57
24 const int64 kGaiaId = GG_INT64_C(99194853094755497); 58 const int64 kGaiaId = GG_INT64_C(99194853094755497);
25 const char kCharset[] = "UTF-8"; 59 const char kCharset[] = "UTF-8";
26 const char kAcceptLanguages[] = "en-US,en"; 60 const char kAcceptLanguages[] = "en-US,en";
27 const int kScreenColorDepth = 53; 61 const int kScreenColorDepth = 53;
28 62
63 class TestWebContentsView : public WebContentsView {
64 public:
65 explicit TestWebContentsView(const gfx::Rect& bounds) : bounds_(bounds) {}
66 virtual ~TestWebContentsView() {}
67
68 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE {
69 *out = bounds_;
70 }
71
72 // The rest of WebContentsView:
73 virtual void CreateView(const gfx::Size& initial_size,
74 gfx::NativeView context) OVERRIDE {}
75 virtual RenderWidgetHostView* CreateViewForWidget(
76 RenderWidgetHost* render_widget_host) OVERRIDE { return NULL; }
77 virtual RenderWidgetHostView* CreateViewForPopupWidget(
78 RenderWidgetHost* render_widget_host) OVERRIDE { return NULL; }
79 virtual gfx::NativeView GetNativeView() const OVERRIDE {
80 return gfx::NativeView();
81 }
82 virtual gfx::NativeView GetContentNativeView() const OVERRIDE {
83 return gfx::NativeView();
84 }
85 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE {
86 return gfx::NativeWindow();
87 }
88 virtual void SetPageTitle(const string16& title) OVERRIDE {}
89 virtual void OnTabCrashed(base::TerminationStatus status,
90 int error_code) OVERRIDE {}
91 virtual void SizeContents(const gfx::Size& size) OVERRIDE {}
92 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE {}
93 virtual void Focus() OVERRIDE {}
94 virtual void SetInitialFocus() OVERRIDE {}
95 virtual void StoreFocus() OVERRIDE {}
96 virtual void RestoreFocus() OVERRIDE {}
97 virtual WebDropData* GetDropData() const OVERRIDE { return NULL; }
98 virtual bool IsEventTracking() const OVERRIDE { return false; }
99 virtual void CloseTabAfterEventTracking() OVERRIDE {}
100 virtual gfx::Rect GetViewBounds() const OVERRIDE { return gfx::Rect(); }
101 #if defined(OS_MACOSX)
102 virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE {}
103 #endif
104
105 private:
106 const gfx::Rect bounds_;
107
108 DISALLOW_COPY_AND_ASSIGN(TestWebContentsView);
109 };
110
111 class TestRenderWidgetHost : public RenderWidgetHost {
112 public:
113 TestRenderWidgetHost(const gfx::Rect& screen_bounds,
114 const gfx::Rect& available_screen_bounds) {
115 screen_info_.depth = kScreenColorDepth;
116 screen_info_.rect = WebKit::WebRect(screen_bounds);
117 screen_info_.availableRect = WebKit::WebRect(available_screen_bounds);
118 }
119 virtual ~TestRenderWidgetHost() {}
120
121 virtual void GetWebScreenInfo(WebKit::WebScreenInfo* result) OVERRIDE {
122 *result = screen_info_;
123 }
124
125 // The rest of RenderWidgetHost:
126 virtual void Undo() OVERRIDE {}
127 virtual void Redo() OVERRIDE {}
128 virtual void Cut() OVERRIDE {}
129 virtual void Copy() OVERRIDE {}
130 virtual void CopyToFindPboard() OVERRIDE {}
131 virtual void Paste() OVERRIDE {}
132 virtual void PasteAndMatchStyle() OVERRIDE {}
133 virtual void Delete() OVERRIDE {}
134 virtual void SelectAll() OVERRIDE {}
135 virtual void UpdateTextDirection(
136 WebKit::WebTextDirection direction) OVERRIDE {}
137 virtual void NotifyTextDirection() OVERRIDE {}
138 virtual void Focus() OVERRIDE {}
139 virtual void Blur() OVERRIDE {}
140 virtual void SetActive(bool active) OVERRIDE {}
141 virtual void CopyFromBackingStore(
142 const gfx::Rect& src_rect,
143 const gfx::Size& accelerated_dst_size,
144 const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE {}
145 #if defined(TOOLKIT_GTK)
146 virtual bool CopyFromBackingStoreToGtkWindow(const gfx::Rect& dest_rect,
147 GdkWindow* target) OVERRIDE {}
148 #elif defined(OS_MACOSX)
149 virtual gfx::Size GetBackingStoreSize() OVERRIDE { return gfx::Size(); }
150 virtual bool CopyFromBackingStoreToCGContext(const CGRect& dest_rect,
151 CGContextRef target) OVERRIDE {
152 return false;
153 }
154 #endif
155 virtual void EnableFullAccessibilityMode() OVERRIDE {}
156 virtual void ForwardMouseEvent(
157 const WebKit::WebMouseEvent& mouse_event) OVERRIDE {}
158 virtual void ForwardWheelEvent(
159 const WebKit::WebMouseWheelEvent& wheel_event) OVERRIDE {}
160 virtual void ForwardKeyboardEvent(
161 const NativeWebKeyboardEvent& key_event) OVERRIDE {}
162 virtual const gfx::Vector2d& GetLastScrollOffset() const OVERRIDE {
163 return vector_2d_;
164 }
165 virtual RenderProcessHost* GetProcess() const OVERRIDE { return NULL; }
166 virtual int GetRoutingID() const OVERRIDE { return 0; }
167 virtual RenderWidgetHostView* GetView() const OVERRIDE { return NULL; }
168 virtual bool IsLoading() const OVERRIDE { return false; }
169 virtual bool IsRenderView() const OVERRIDE { return false; }
170 virtual void PaintAtSize(TransportDIB::Handle dib_handle,
171 int tag,
172 const gfx::Size& page_size,
173 const gfx::Size& desired_size) OVERRIDE {}
174 virtual void Replace(const string16& word) OVERRIDE {}
175 virtual void ReplaceMisspelling(const string16& word) OVERRIDE {}
176 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE {}
177 virtual void RestartHangMonitorTimeout() OVERRIDE {}
178 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE {}
179 virtual void Stop() OVERRIDE {}
180 virtual void WasResized() OVERRIDE {}
181 virtual void AddKeyboardListener(KeyboardListener* listener) OVERRIDE {}
182 virtual void RemoveKeyboardListener(KeyboardListener* listener) OVERRIDE {}
183 virtual bool Send(IPC::Message* msg) OVERRIDE { return false; }
184 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE {
185 return NULL;
186 }
187
188 private:
189 WebKit::WebScreenInfo screen_info_;
190
191 // For const-reference return value.
192 gfx::Vector2d vector_2d_;
193
194 DISALLOW_COPY_AND_ASSIGN(TestRenderWidgetHost);
195 };
196
197 class TestRenderWidgetHostView : public RenderWidgetHostView {
198 public:
199 TestRenderWidgetHostView(const gfx::Rect& screen_bounds,
200 const gfx::Rect& available_screen_bounds)
201 : host_(screen_bounds, available_screen_bounds) {}
202 virtual ~TestRenderWidgetHostView() {}
203
204 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE {
205 return &host_;
206 }
207
208 // The rest of RenderWidgetHostView:
209 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE {}
210 virtual void SetSize(const gfx::Size& size) OVERRIDE {}
211 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE {}
212 virtual gfx::NativeView GetNativeView() const OVERRIDE {
213 return gfx::NativeView();
214 }
215 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE {
216 return gfx::NativeViewId();
217 }
218 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE {
219 return gfx::NativeViewAccessible();
220 }
221 virtual void Focus() OVERRIDE {}
222 virtual bool HasFocus() const OVERRIDE { return false; }
223 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE { return false; }
224 virtual void Show() OVERRIDE {}
225 virtual void Hide() OVERRIDE {}
226 virtual bool IsShowing() OVERRIDE { return false; }
227 virtual gfx::Rect GetViewBounds() const OVERRIDE { return gfx::Rect(); }
228 virtual bool IsShowingContextMenu() const OVERRIDE { return false; }
229 virtual void SetShowingContextMenu(bool showing) OVERRIDE {}
230 #if defined(OS_MACOSX)
231 virtual void SetActive(bool active) OVERRIDE {}
232 virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE {}
233 virtual void SetWindowVisibility(bool visible) OVERRIDE {}
234 virtual void WindowFrameChanged() OVERRIDE {}
235 virtual void ShowDefinitionForSelection() OVERRIDE {}
236 virtual bool SupportsSpeech() const OVERRIDE { return false; }
237 virtual void SpeakSelection() OVERRIDE {}
238 virtual bool IsSpeaking() const OVERRIDE { return false; }
239 virtual void StopSpeaking() OVERRIDE {}
240 #endif // defined(OS_MACOSX)
241 #if defined(TOOLKIT_GTK)
242 virtual GdkEventButton* GetLastMouseDown() OVERRIDE { return NULL; }
243 virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE {
244 return gfx::NativeView();
245 }
246 #endif // defined(TOOLKIT_GTK)
247 #if defined(OS_ANDROID)
248 virtual void StartContentIntent(const GURL& content_url) OVERRIDE {}
249 virtual void SetCachedBackgroundColor(SkColor color) OVERRIDE {}
250 #endif
251 virtual void SetBackground(const SkBitmap& background) OVERRIDE {}
252 virtual const SkBitmap& GetBackground() OVERRIDE {
253 return sk_bitmap_;
254 }
255 #if defined(OS_WIN) && !defined(USE_AURA)
256 virtual void SetClickthroughRegion(SkRegion* region) {}
257 #endif
258 virtual bool LockMouse() OVERRIDE { return false; }
259 virtual void UnlockMouse() OVERRIDE {}
260 virtual bool IsMouseLocked() OVERRIDE { return false; }
261
262 private:
263 mutable TestRenderWidgetHost host_;
264
265 // For const-reference return value.
266 SkBitmap sk_bitmap_;
267
268 DISALLOW_COPY_AND_ASSIGN(TestRenderWidgetHostView);
269 };
270
271 class MockNavigationController : public NavigationController {
272 public:
273 MockNavigationController() {}
274 virtual ~MockNavigationController() {}
275
276 // NavigationController:
277 virtual WebContents* GetWebContents() const OVERRIDE { return NULL; }
278 virtual BrowserContext* GetBrowserContext() const OVERRIDE { return NULL; }
279 virtual void SetBrowserContext(BrowserContext* browser_context) OVERRIDE {}
280 virtual void Restore(int selected_navigation,
281 RestoreType type,
282 std::vector<NavigationEntry*>* entries) OVERRIDE {}
283 virtual NavigationEntry* GetActiveEntry() const OVERRIDE { return NULL; }
284 virtual NavigationEntry* GetVisibleEntry() const OVERRIDE { return NULL; }
285 virtual int GetCurrentEntryIndex() const OVERRIDE { return 0; }
286 virtual NavigationEntry* GetLastCommittedEntry() const OVERRIDE {
287 return NULL;
288 }
289 virtual int GetLastCommittedEntryIndex() const OVERRIDE { return 0; }
290 virtual bool CanViewSource() const OVERRIDE { return false; }
291 virtual int GetEntryCount() const OVERRIDE { return 0; }
292 virtual NavigationEntry* GetEntryAtIndex(int index) const OVERRIDE {
293 return NULL;
294 }
295 virtual NavigationEntry* GetEntryAtOffset(int offset) const OVERRIDE {
296 return NULL;
297 }
298 virtual void DiscardNonCommittedEntries() OVERRIDE {}
299 virtual NavigationEntry* GetPendingEntry() const OVERRIDE { return NULL; }
300 virtual int GetPendingEntryIndex() const OVERRIDE { return 0; }
301 virtual NavigationEntry* GetTransientEntry() const OVERRIDE { return NULL; }
302 virtual void LoadURL(const GURL& url,
303 const Referrer& referrer,
304 PageTransition type,
305 const std::string& extra_headers) OVERRIDE {}
306 virtual void LoadURLWithParams(const LoadURLParams& params) OVERRIDE {}
307 virtual void LoadIfNecessary() OVERRIDE {}
308 virtual bool CanGoBack() const OVERRIDE { return false; }
309 virtual bool CanGoForward() const OVERRIDE { return false; }
310 virtual bool CanGoToOffset(int offset) const OVERRIDE { return false; }
311 virtual void GoBack() OVERRIDE {}
312 virtual void GoForward() OVERRIDE {}
313 virtual void GoToIndex(int index) OVERRIDE {}
314 virtual void GoToOffset(int offset) OVERRIDE {}
315 virtual void Reload(bool check_for_repost) OVERRIDE {}
316 virtual void ReloadIgnoringCache(bool check_for_repost) OVERRIDE {}
317 virtual void ReloadOriginalRequestURL(bool check_for_repost) OVERRIDE {}
318 virtual void RemoveEntryAtIndex(int index) OVERRIDE {}
319 #if !defined(OS_IOS)
320 virtual const SessionStorageNamespaceMap&
321 GetSessionStorageNamespaceMap() const OVERRIDE {
322 return session_storage_namespace_map_;
323 }
324 virtual SessionStorageNamespace*
325 GetDefaultSessionStorageNamespace() OVERRIDE { return NULL; }
326 #endif
327 virtual void SetMaxRestoredPageID(int32 max_id) OVERRIDE {}
328 virtual int32 GetMaxRestoredPageID() const OVERRIDE { return 0; }
329 virtual bool NeedsReload() const OVERRIDE { return false; }
330 virtual void CancelPendingReload() OVERRIDE {}
331 virtual void ContinuePendingReload() OVERRIDE {}
332 virtual bool IsInitialNavigation() OVERRIDE { return false; }
333 virtual void NotifyEntryChanged(const NavigationEntry* entry,
334 int index) OVERRIDE {}
335 virtual void CopyStateFrom(const NavigationController& source) OVERRIDE {}
336 virtual void CopyStateFromAndPrune(NavigationController* source) OVERRIDE {}
337 virtual void PruneAllButActive() OVERRIDE {}
338 virtual void ClearAllScreenshots() OVERRIDE {}
339
340 private:
341 // For const-reference return value.
342 SessionStorageNamespaceMap session_storage_namespace_map_;
343
344 DISALLOW_COPY_AND_ASSIGN(MockNavigationController);
345 };
346
347 class TestWebContents : public WebContents {
348 public:
349 TestWebContents(const gfx::Rect& content_bounds,
350 const gfx::Rect& screen_bounds,
351 const gfx::Rect& available_screen_bounds)
352 : view_(content_bounds),
353 host_view_(screen_bounds, available_screen_bounds) {}
354 virtual ~TestWebContents() {}
355
356 virtual WebContentsView* GetView() const OVERRIDE {
357 return &view_;
358 }
359
360 virtual RenderWidgetHostView* GetRenderWidgetHostView() const OVERRIDE {
361 return &host_view_;
362 }
363
364 // The rest of WebContents:
365 virtual WebContentsDelegate* GetDelegate() OVERRIDE { return NULL; }
366 virtual void SetDelegate(WebContentsDelegate* delegate) OVERRIDE {}
367 virtual NavigationController& GetController() OVERRIDE {
368 return navigation_controller_;
369 }
370 virtual const NavigationController& GetController() const OVERRIDE {
371 return navigation_controller_;
372 }
373 virtual BrowserContext* GetBrowserContext() const OVERRIDE { return NULL; }
374 virtual const GURL& GetURL() const OVERRIDE { return gurl_; }
375 virtual RenderProcessHost* GetRenderProcessHost() const OVERRIDE {
376 return NULL;
377 }
378 virtual RenderViewHost* GetRenderViewHost() const OVERRIDE {
379 return NULL;
380 }
381 virtual void GetRenderViewHostAtPosition(
382 int x,
383 int y,
384 const GetRenderViewHostCallback& callback) OVERRIDE {}
385 virtual WebContents* GetEmbedderWebContents() const OVERRIDE {
386 return NULL;
387 }
388 virtual int GetEmbeddedInstanceID() const OVERRIDE { return 0; }
389 virtual int GetRoutingID() const OVERRIDE { return 0; }
390 virtual WebUI* CreateWebUI(const GURL& url) OVERRIDE { return NULL; }
391 virtual WebUI* GetWebUI() const OVERRIDE { return NULL; }
392 virtual WebUI* GetCommittedWebUI() const OVERRIDE { return NULL; }
393 virtual void SetUserAgentOverride(const std::string& override) OVERRIDE {}
394 virtual const std::string& GetUserAgentOverride() const OVERRIDE {
395 return string_;
396 }
397 virtual const string16& GetTitle() const OVERRIDE { return string16_; }
398 virtual int32 GetMaxPageID() OVERRIDE { return 0; }
399 virtual int32 GetMaxPageIDForSiteInstance(
400 SiteInstance* site_instance) OVERRIDE { return 0; }
401 virtual SiteInstance* GetSiteInstance() const OVERRIDE { return NULL; }
402 virtual SiteInstance* GetPendingSiteInstance() const OVERRIDE { return NULL; }
403 virtual bool IsLoading() const OVERRIDE { return false; }
404 virtual bool IsWaitingForResponse() const OVERRIDE { return false; }
405 virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE {
406 return load_state_with_param_;
407 }
408 virtual const string16& GetLoadStateHost() const OVERRIDE {
409 return string16_;
410 }
411 virtual uint64 GetUploadSize() const OVERRIDE { return 0; }
412 virtual uint64 GetUploadPosition() const OVERRIDE { return 0; }
413 virtual const std::string& GetEncoding() const OVERRIDE { return string_; }
414 virtual bool DisplayedInsecureContent() const OVERRIDE { return false; }
415 virtual void IncrementCapturerCount() OVERRIDE {}
416 virtual void DecrementCapturerCount() OVERRIDE {}
417 virtual bool IsCrashed() const OVERRIDE { return false; }
418 virtual void SetIsCrashed(base::TerminationStatus status,
419 int error_code) OVERRIDE {}
420 virtual base::TerminationStatus GetCrashedStatus() const OVERRIDE {
421 return base::TerminationStatus();
422 }
423 virtual bool IsBeingDestroyed() const OVERRIDE { return false; }
424 virtual void NotifyNavigationStateChanged(unsigned changed_flags) OVERRIDE {}
425 virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE {
426 return base::TimeTicks();
427 }
428 virtual void WasShown() OVERRIDE {}
429 virtual void WasHidden() OVERRIDE {}
430 virtual bool NeedToFireBeforeUnload() OVERRIDE { return false; }
431 virtual void Stop() OVERRIDE {}
432 virtual WebContents* Clone() OVERRIDE { return NULL; }
433 virtual gfx::NativeView GetContentNativeView() const OVERRIDE {
434 return gfx::NativeView();
435 }
436 virtual gfx::NativeView GetNativeView() const OVERRIDE {
437 return gfx::NativeView();
438 }
439 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE {}
440 virtual void Focus() OVERRIDE {}
441 virtual void FocusThroughTabTraversal(bool reverse) OVERRIDE {}
442 virtual bool ShowingInterstitialPage() const OVERRIDE { return false; }
443 virtual InterstitialPage* GetInterstitialPage() const OVERRIDE {
444 return NULL;
445 }
446 virtual bool IsSavable() OVERRIDE { return false; }
447 virtual void OnSavePage() OVERRIDE {}
448 virtual bool SavePage(const base::FilePath& main_file,
449 const base::FilePath& dir_path,
450 SavePageType save_type) OVERRIDE { return false; }
451 virtual void GenerateMHTML(
452 const base::FilePath& file,
453 const base::Callback<void(const base::FilePath&, int64)>& callback)
454 OVERRIDE {}
455 virtual bool IsActiveEntry(int32 page_id) OVERRIDE { return false; }
456
457 virtual const std::string& GetContentsMimeType() const OVERRIDE {
458 return string_;
459 }
460 virtual bool WillNotifyDisconnection() const OVERRIDE { return false; }
461 virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE {}
462 virtual void ResetOverrideEncoding() OVERRIDE {}
463 virtual RendererPreferences* GetMutableRendererPrefs() OVERRIDE {
464 return NULL;
465 }
466 virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE {}
467 virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE {
468 return base::TimeTicks();
469 }
470 virtual void Close() OVERRIDE {}
471 virtual void OnCloseStarted() OVERRIDE {}
472 virtual bool ShouldAcceptDragAndDrop() const OVERRIDE { return false; }
473 virtual void SystemDragEnded() OVERRIDE {}
474 virtual void UserGestureDone() OVERRIDE {}
475 virtual void SetClosedByUserGesture(bool value) OVERRIDE {}
476 virtual bool GetClosedByUserGesture() const OVERRIDE { return false; }
477 virtual double GetZoomLevel() const OVERRIDE { return 0.0; }
478 virtual int GetZoomPercent(bool* enable_increment,
479 bool* enable_decrement) const OVERRIDE {
480 return 0;
481 }
482 virtual void ViewSource() OVERRIDE {}
483 virtual void ViewFrameSource(const GURL& url,
484 const std::string& content_state) OVERRIDE {}
485 virtual int GetMinimumZoomPercent() const OVERRIDE { return 0; }
486 virtual int GetMaximumZoomPercent() const OVERRIDE { return 0; }
487 virtual gfx::Size GetPreferredSize() const OVERRIDE { return gfx::Size(); }
488 virtual int GetContentRestrictions() const OVERRIDE { return 0; }
489 virtual WebUI::TypeID GetWebUITypeForCurrentState() OVERRIDE {
490 return WebUI::TypeID();
491 }
492 virtual WebUI* GetWebUIForCurrentState() OVERRIDE { return NULL; }
493 virtual bool GotResponseToLockMouseRequest(bool allowed) OVERRIDE {
494 return false;
495 }
496 virtual bool HasOpener() const OVERRIDE { return false; }
497 virtual void DidChooseColorInColorChooser(int color_chooser_id,
498 SkColor color) OVERRIDE {}
499 virtual void DidEndColorChooser(int color_chooser_id) OVERRIDE {}
500 virtual bool FocusLocationBarByDefault() OVERRIDE { return false; }
501 virtual void SetFocusToLocationBar(bool select_all) OVERRIDE {}
502 virtual int DownloadFavicon(
503 const GURL& url, int image_size,
504 const FaviconDownloadCallback& callback) OVERRIDE { return 0; }
505 virtual WebContents* OpenURL(const OpenURLParams& params) OVERRIDE {
506 return NULL;
507 }
508 virtual bool Send(IPC::Message* msg) OVERRIDE { return false; }
509
510 private:
511 mutable TestWebContentsView view_;
512 mutable TestRenderWidgetHostView host_view_;
513
514 // For const-reference return values.
515 std::string string_;
516 string16 string16_;
517 GURL gurl_;
518 net::LoadStateWithParam load_state_with_param_;
519 MockNavigationController navigation_controller_;
520
521 DISALLOW_COPY_AND_ASSIGN(TestWebContents);
522 };
523
524 } // namespace
525
29 class AutofillRiskFingerprintTest : public InProcessBrowserTest { 526 class AutofillRiskFingerprintTest : public InProcessBrowserTest {
30 public: 527 public:
31 AutofillRiskFingerprintTest() 528 AutofillRiskFingerprintTest()
32 : kWindowBounds(2, 3, 5, 7), 529 : kWindowBounds(2, 3, 5, 7),
33 kContentBounds(11, 13, 17, 37), 530 kContentBounds(11, 13, 17, 37),
34 kScreenBounds(0, 0, 101, 71), 531 kScreenBounds(0, 0, 101, 71),
35 kAvailableScreenBounds(0, 11, 101, 60), 532 kAvailableScreenBounds(0, 11, 101, 60),
36 kUnavailableScreenBounds(0, 0, 101, 11), 533 kUnavailableScreenBounds(0, 0, 101, 11),
37 message_loop_(MessageLoop::TYPE_UI) {} 534 message_loop_(MessageLoop::TYPE_UI) {}
38 535
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 618
122 #if defined(OS_WIN) || defined(OS_LINUX) 619 #if defined(OS_WIN) || defined(OS_LINUX)
123 // See http://crbug.com/174296 620 // See http://crbug.com/174296
124 #define MAYBE_GetFingerprint DISABLED_GetFingerPrint 621 #define MAYBE_GetFingerprint DISABLED_GetFingerPrint
125 #else 622 #else
126 #define MAYBE_GetFingerprint GetFingerPrint 623 #define MAYBE_GetFingerprint GetFingerPrint
127 #endif 624 #endif
128 625
129 // Test that getting a fingerprint works on some basic level. 626 // Test that getting a fingerprint works on some basic level.
130 IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, MAYBE_GetFingerprint) { 627 IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, MAYBE_GetFingerprint) {
628 TestWebContents web_contents(
629 kContentBounds, kScreenBounds, kAvailableScreenBounds);
630
131 TestingPrefServiceSimple prefs; 631 TestingPrefServiceSimple prefs;
132 prefs.registry()->RegisterStringPref(prefs::kDefaultCharset, kCharset); 632 prefs.registry()->RegisterStringPref(prefs::kDefaultCharset, kCharset);
133 prefs.registry()->RegisterStringPref(prefs::kAcceptLanguages, 633 prefs.registry()->RegisterStringPref(prefs::kAcceptLanguages,
134 kAcceptLanguages); 634 kAcceptLanguages);
135 635
136 WebKit::WebScreenInfo screen_info;
137 screen_info.depth = kScreenColorDepth;
138 screen_info.rect = WebKit::WebRect(kScreenBounds);
139 screen_info.availableRect = WebKit::WebRect(kAvailableScreenBounds);
140
141 // TODO(isherman): Investigating http://crbug.com/174296 636 // TODO(isherman): Investigating http://crbug.com/174296
142 LOG(WARNING) << "Loading fingerprint."; 637 LOG(WARNING) << "Loading fingerprint.";
143 GetFingerprint( 638 GetFingerprint(
144 kGaiaId, kWindowBounds, kContentBounds, screen_info, prefs, 639 kGaiaId, kWindowBounds, web_contents, prefs,
145 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, 640 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback,
146 base::Unretained(this))); 641 base::Unretained(this)));
147 642
148 // Wait for the callback to be called. 643 // Wait for the callback to be called.
149 // TODO(isherman): Investigating http://crbug.com/174296 644 // TODO(isherman): Investigating http://crbug.com/174296
150 LOG(WARNING) << "Waiting for the callback to be called."; 645 LOG(WARNING) << "Waiting for the callback to be called.";
151 message_loop_.Run(); 646 message_loop_.Run();
152 } 647 }
153 648
154 } // namespace risk 649 } // namespace risk
155 } // namespace autofill 650 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698