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 30 matching lines...) Expand all Loading... |
41 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
42 #include "chrome/test/base/in_process_browser_test.h" | 42 #include "chrome/test/base/in_process_browser_test.h" |
43 #include "chrome/test/base/ui_test_utils.h" | 43 #include "chrome/test/base/ui_test_utils.h" |
44 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
45 #include "net/cookies/cookie_store.h" | 45 #include "net/cookies/cookie_store.h" |
46 #include "sql/connection.h" | 46 #include "sql/connection.h" |
47 #include "sql/statement.h" | 47 #include "sql/statement.h" |
48 #include "testing/gmock/include/gmock/gmock.h" | 48 #include "testing/gmock/include/gmock/gmock.h" |
49 | 49 |
50 #if defined(OS_CHROMEOS) | 50 #if defined(OS_CHROMEOS) |
| 51 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
51 #include "chromeos/chromeos_switches.h" | 52 #include "chromeos/chromeos_switches.h" |
52 #endif | 53 #endif |
53 | 54 |
54 using content::BrowserThread; | 55 using content::BrowserThread; |
55 using content::InterstitialPage; | 56 using content::InterstitialPage; |
56 using content::WebContents; | 57 using content::WebContents; |
57 using ::testing::_; | 58 using ::testing::_; |
58 using ::testing::Mock; | 59 using ::testing::Mock; |
59 using ::testing::StrictMock; | 60 using ::testing::StrictMock; |
60 | 61 |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 | 1022 |
1022 // Change one of the prefs. SBS should keep running. | 1023 // Change one of the prefs. SBS should keep running. |
1023 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false); | 1024 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
1024 WaitForIOThread(); | 1025 WaitForIOThread(); |
1025 EXPECT_TRUE(sb_service->enabled()); | 1026 EXPECT_TRUE(sb_service->enabled()); |
1026 EXPECT_TRUE(csd_service->enabled()); | 1027 EXPECT_TRUE(csd_service->enabled()); |
1027 | 1028 |
1028 // Change the other pref. SBS should stop now. | 1029 // Change the other pref. SBS should stop now. |
1029 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false); | 1030 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
1030 WaitForIOThread(); | 1031 WaitForIOThread(); |
| 1032 |
| 1033 // TODO(mattm): Remove this when crbug.com/461493 is fixed. |
| 1034 #if defined(OS_CHROMEOS) |
| 1035 // On Chrome OS we should disable safe browsing for signin profile. |
| 1036 EXPECT_TRUE(sb_service->enabled()); |
| 1037 EXPECT_TRUE(csd_service->enabled()); |
| 1038 chromeos::ProfileHelper::GetSigninProfile() |
| 1039 ->GetOriginalProfile() |
| 1040 ->GetPrefs() |
| 1041 ->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
| 1042 WaitForIOThread(); |
| 1043 #endif |
1031 EXPECT_FALSE(sb_service->enabled()); | 1044 EXPECT_FALSE(sb_service->enabled()); |
1032 EXPECT_FALSE(csd_service->enabled()); | 1045 EXPECT_FALSE(csd_service->enabled()); |
1033 | 1046 |
1034 // Turn it back on. SBS comes back. | 1047 // Turn it back on. SBS comes back. |
1035 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true); | 1048 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true); |
1036 WaitForIOThread(); | 1049 WaitForIOThread(); |
1037 EXPECT_TRUE(sb_service->enabled()); | 1050 EXPECT_TRUE(sb_service->enabled()); |
1038 EXPECT_TRUE(csd_service->enabled()); | 1051 EXPECT_TRUE(csd_service->enabled()); |
1039 | 1052 |
1040 // Delete the Profile. SBS stops again. | 1053 // Delete the Profile. SBS stops again. |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 content::WindowedNotificationObserver observer( | 1250 content::WindowedNotificationObserver observer( |
1238 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 1251 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
1239 content::Source<SafeBrowsingDatabaseManager>( | 1252 content::Source<SafeBrowsingDatabaseManager>( |
1240 sb_service_->database_manager().get())); | 1253 sb_service_->database_manager().get())); |
1241 BrowserThread::PostTask( | 1254 BrowserThread::PostTask( |
1242 BrowserThread::IO, | 1255 BrowserThread::IO, |
1243 FROM_HERE, | 1256 FROM_HERE, |
1244 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 1257 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
1245 observer.Wait(); | 1258 observer.Wait(); |
1246 } | 1259 } |
OLD | NEW |