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