| 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 // This test creates a safebrowsing service using test safebrowsing database | 5 // This test creates a safebrowsing service using test safebrowsing database |
| 6 // and a test protocol manager. It is used to test logics in safebrowsing | 6 // and a test protocol manager. It is used to test logics in safebrowsing |
| 7 // service. | 7 // service. |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 16 #include "base/scoped_temp_dir.h" | |
| 17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 18 #include "base/test/thread_test_helper.h" | 18 #include "base/test/thread_test_helper.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/prerender/prerender_manager.h" | 21 #include "chrome/browser/prerender/prerender_manager.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 24 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 25 #include "chrome/browser/safe_browsing/protocol_manager.h" | 25 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 26 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 26 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 425 } |
| 426 | 426 |
| 427 protected: | 427 protected: |
| 428 StrictMock<MockObserver> observer_; | 428 StrictMock<MockObserver> observer_; |
| 429 | 429 |
| 430 // Temporary profile dir for test cases that create a second profile. This is | 430 // Temporary profile dir for test cases that create a second profile. This is |
| 431 // owned by the SafeBrowsingServiceTest object so that it will not get | 431 // owned by the SafeBrowsingServiceTest object so that it will not get |
| 432 // destructed until after the test Browser has been torn down, since the | 432 // destructed until after the test Browser has been torn down, since the |
| 433 // ImportantFileWriter may still be modifying it after the Profile object has | 433 // ImportantFileWriter may still be modifying it after the Profile object has |
| 434 // been destroyed. | 434 // been destroyed. |
| 435 ScopedTempDir temp_profile_dir_; | 435 base::ScopedTempDir temp_profile_dir_; |
| 436 | 436 |
| 437 // Waits for pending tasks on the IO thread to complete. This is useful | 437 // Waits for pending tasks on the IO thread to complete. This is useful |
| 438 // to wait for the SafeBrowsingService to finish loading/stopping. | 438 // to wait for the SafeBrowsingService to finish loading/stopping. |
| 439 void WaitForIOThread() { | 439 void WaitForIOThread() { |
| 440 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( | 440 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( |
| 441 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 441 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 442 ASSERT_TRUE(io_helper->Run()); | 442 ASSERT_TRUE(io_helper->Run()); |
| 443 } | 443 } |
| 444 | 444 |
| 445 private: | 445 private: |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 // save cookies. | 976 // save cookies. |
| 977 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceCookieTest, TestSBUpdateCookies) { | 977 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceCookieTest, TestSBUpdateCookies) { |
| 978 content::WindowedNotificationObserver observer( | 978 content::WindowedNotificationObserver observer( |
| 979 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 979 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
| 980 content::Source<SafeBrowsingService>(sb_service_.get())); | 980 content::Source<SafeBrowsingService>(sb_service_.get())); |
| 981 BrowserThread::PostTask( | 981 BrowserThread::PostTask( |
| 982 BrowserThread::IO, FROM_HERE, | 982 BrowserThread::IO, FROM_HERE, |
| 983 base::Bind(&SafeBrowsingServiceCookieTest::ForceUpdate, this)); | 983 base::Bind(&SafeBrowsingServiceCookieTest::ForceUpdate, this)); |
| 984 observer.Wait(); | 984 observer.Wait(); |
| 985 } | 985 } |
| OLD | NEW |