| 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/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/metrics/histogram.h" | |
| 16 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 17 #include "base/scoped_temp_dir.h" | 16 #include "base/scoped_temp_dir.h" |
| 18 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 19 #include "base/test/thread_test_helper.h" | 18 #include "base/test/thread_test_helper.h" |
| 20 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/prerender/prerender_manager.h" | 21 #include "chrome/browser/prerender/prerender_manager.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 23 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 25 #include "chrome/browser/safe_browsing/protocol_manager.h" | 24 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 26 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 25 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
| 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 28 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 27 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 29 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_tabstrip.h" | 29 #include "chrome/browser/ui/browser_tabstrip.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/test/base/in_process_browser_test.h" | 34 #include "chrome/test/base/in_process_browser_test.h" |
| 36 #include "chrome/test/base/ui_test_utils.h" | 35 #include "chrome/test/base/ui_test_utils.h" |
| 37 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 38 #include "content/public/browser/web_contents_view.h" | 37 #include "content/public/browser/web_contents_view.h" |
| 39 #include "crypto/sha2.h" | 38 #include "crypto/sha2.h" |
| 40 #include "net/cookies/cookie_store.h" | 39 #include "net/cookies/cookie_store.h" |
| 41 #include "sql/connection.h" | 40 #include "sql/connection.h" |
| 42 #include "sql/statement.h" | 41 #include "sql/statement.h" |
| 43 #include "testing/gmock/include/gmock/gmock.h" | 42 #include "testing/gmock/include/gmock/gmock.h" |
| 44 | 43 |
| 45 using base::Histogram; | |
| 46 using base::StatisticsRecorder; | |
| 47 using content::BrowserThread; | 44 using content::BrowserThread; |
| 48 using content::InterstitialPage; | 45 using content::InterstitialPage; |
| 49 using content::WebContents; | 46 using content::WebContents; |
| 50 using ::testing::_; | 47 using ::testing::_; |
| 51 using ::testing::Mock; | 48 using ::testing::Mock; |
| 52 using ::testing::StrictMock; | 49 using ::testing::StrictMock; |
| 53 | 50 |
| 54 // A SafeBrowingDatabase class that allows us to inject the malicious URLs. | 51 // A SafeBrowingDatabase class that allows us to inject the malicious URLs. |
| 55 class TestSafeBrowsingDatabase : public SafeBrowsingDatabase { | 52 class TestSafeBrowsingDatabase : public SafeBrowsingDatabase { |
| 56 public: | 53 public: |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 // save cookies. | 878 // save cookies. |
| 882 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceCookieTest, TestSBUpdateCookies) { | 879 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceCookieTest, TestSBUpdateCookies) { |
| 883 ui_test_utils::WindowedNotificationObserver observer( | 880 ui_test_utils::WindowedNotificationObserver observer( |
| 884 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 881 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
| 885 content::Source<SafeBrowsingService>(sb_service_.get())); | 882 content::Source<SafeBrowsingService>(sb_service_.get())); |
| 886 BrowserThread::PostTask( | 883 BrowserThread::PostTask( |
| 887 BrowserThread::IO, FROM_HERE, | 884 BrowserThread::IO, FROM_HERE, |
| 888 base::Bind(&SafeBrowsingServiceCookieTest::ForceUpdate, this)); | 885 base::Bind(&SafeBrowsingServiceCookieTest::ForceUpdate, this)); |
| 889 observer.Wait(); | 886 observer.Wait(); |
| 890 } | 887 } |
| OLD | NEW |