| 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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 | 1021 |
| 1021 // Change one of the prefs. SBS should keep running. | 1022 // Change one of the prefs. SBS should keep running. |
| 1022 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false); | 1023 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
| 1023 WaitForIOThread(); | 1024 WaitForIOThread(); |
| 1024 EXPECT_TRUE(sb_service->enabled()); | 1025 EXPECT_TRUE(sb_service->enabled()); |
| 1025 EXPECT_TRUE(csd_service->enabled()); | 1026 EXPECT_TRUE(csd_service->enabled()); |
| 1026 | 1027 |
| 1027 // Change the other pref. SBS should stop now. | 1028 // Change the other pref. SBS should stop now. |
| 1028 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false); | 1029 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
| 1029 WaitForIOThread(); | 1030 WaitForIOThread(); |
| 1031 #if defined(OS_CHROMEOS) |
| 1032 // On Chrome OS we should disable safe browsing for signin profile. |
| 1033 EXPECT_TRUE(sb_service->enabled()); |
| 1034 EXPECT_TRUE(csd_service->enabled()); |
| 1035 chromeos::ProfileHelper::GetSigninProfile() |
| 1036 ->GetOriginalProfile() |
| 1037 ->GetPrefs() |
| 1038 ->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
| 1039 WaitForIOThread(); |
| 1040 #endif |
| 1030 EXPECT_FALSE(sb_service->enabled()); | 1041 EXPECT_FALSE(sb_service->enabled()); |
| 1031 EXPECT_FALSE(csd_service->enabled()); | 1042 EXPECT_FALSE(csd_service->enabled()); |
| 1032 | 1043 |
| 1033 // Turn it back on. SBS comes back. | 1044 // Turn it back on. SBS comes back. |
| 1034 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true); | 1045 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true); |
| 1035 WaitForIOThread(); | 1046 WaitForIOThread(); |
| 1036 EXPECT_TRUE(sb_service->enabled()); | 1047 EXPECT_TRUE(sb_service->enabled()); |
| 1037 EXPECT_TRUE(csd_service->enabled()); | 1048 EXPECT_TRUE(csd_service->enabled()); |
| 1038 | 1049 |
| 1039 // Delete the Profile. SBS stops again. | 1050 // Delete the Profile. SBS stops again. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 content::WindowedNotificationObserver observer( | 1247 content::WindowedNotificationObserver observer( |
| 1237 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 1248 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
| 1238 content::Source<SafeBrowsingDatabaseManager>( | 1249 content::Source<SafeBrowsingDatabaseManager>( |
| 1239 sb_service_->database_manager().get())); | 1250 sb_service_->database_manager().get())); |
| 1240 BrowserThread::PostTask( | 1251 BrowserThread::PostTask( |
| 1241 BrowserThread::IO, | 1252 BrowserThread::IO, |
| 1242 FROM_HERE, | 1253 FROM_HERE, |
| 1243 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 1254 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
| 1244 observer.Wait(); | 1255 observer.Wait(); |
| 1245 } | 1256 } |
| OLD | NEW |