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 |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
38 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
39 #include "chrome/test/base/in_process_browser_test.h" | 39 #include "chrome/test/base/in_process_browser_test.h" |
40 #include "chrome/test/base/ui_test_utils.h" | 40 #include "chrome/test/base/ui_test_utils.h" |
41 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
42 #include "net/cookies/cookie_store.h" | 42 #include "net/cookies/cookie_store.h" |
43 #include "sql/connection.h" | 43 #include "sql/connection.h" |
44 #include "sql/statement.h" | 44 #include "sql/statement.h" |
45 #include "testing/gmock/include/gmock/gmock.h" | 45 #include "testing/gmock/include/gmock/gmock.h" |
46 | 46 |
| 47 #if defined(OS_CHROMEOS) |
| 48 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 49 #endif |
| 50 |
47 using content::BrowserThread; | 51 using content::BrowserThread; |
48 using content::InterstitialPage; | 52 using content::InterstitialPage; |
49 using content::WebContents; | 53 using content::WebContents; |
50 using ::testing::_; | 54 using ::testing::_; |
51 using ::testing::Mock; | 55 using ::testing::Mock; |
52 using ::testing::StrictMock; | 56 using ::testing::StrictMock; |
53 | 57 |
54 namespace { | 58 namespace { |
55 | 59 |
56 void InvokeFullHashCallback( | 60 void InvokeFullHashCallback( |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 | 762 |
759 // Change one of the prefs. SBS should keep running. | 763 // Change one of the prefs. SBS should keep running. |
760 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false); | 764 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
761 WaitForIOThread(); | 765 WaitForIOThread(); |
762 EXPECT_TRUE(sb_service->enabled()); | 766 EXPECT_TRUE(sb_service->enabled()); |
763 EXPECT_TRUE(csd_service->enabled()); | 767 EXPECT_TRUE(csd_service->enabled()); |
764 | 768 |
765 // Change the other pref. SBS should stop now. | 769 // Change the other pref. SBS should stop now. |
766 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false); | 770 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
767 WaitForIOThread(); | 771 WaitForIOThread(); |
| 772 #if defined(CHROME_OS) |
| 773 // On Chrome OS we should disable safe browsing for signin profile. |
| 774 EXPECT_TRUE(sb_service->enabled()); |
| 775 EXPECT_TRUE(csd_service->enabled()); |
| 776 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile()-> |
| 777 GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
| 778 WaitForIOThread(); |
| 779 #endif |
768 EXPECT_FALSE(sb_service->enabled()); | 780 EXPECT_FALSE(sb_service->enabled()); |
769 EXPECT_FALSE(csd_service->enabled()); | 781 EXPECT_FALSE(csd_service->enabled()); |
770 | 782 |
771 // Turn it back on. SBS comes back. | 783 // Turn it back on. SBS comes back. |
772 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true); | 784 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true); |
773 WaitForIOThread(); | 785 WaitForIOThread(); |
774 EXPECT_TRUE(sb_service->enabled()); | 786 EXPECT_TRUE(sb_service->enabled()); |
775 EXPECT_TRUE(csd_service->enabled()); | 787 EXPECT_TRUE(csd_service->enabled()); |
776 | 788 |
777 // Delete the Profile. SBS stops again. | 789 // Delete the Profile. SBS stops again. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 content::WindowedNotificationObserver observer( | 988 content::WindowedNotificationObserver observer( |
977 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 989 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
978 content::Source<SafeBrowsingDatabaseManager>( | 990 content::Source<SafeBrowsingDatabaseManager>( |
979 sb_service_->database_manager().get())); | 991 sb_service_->database_manager().get())); |
980 BrowserThread::PostTask( | 992 BrowserThread::PostTask( |
981 BrowserThread::IO, | 993 BrowserThread::IO, |
982 FROM_HERE, | 994 FROM_HERE, |
983 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 995 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
984 observer.Wait(); | 996 observer.Wait(); |
985 } | 997 } |
OLD | NEW |