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 "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 10 |
9 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <utility> |
10 | 13 |
11 #include "base/bind.h" | 14 #include "base/bind.h" |
12 #include "base/command_line.h" | 15 #include "base/command_line.h" |
13 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
14 #include "base/files/scoped_temp_dir.h" | 17 #include "base/files/scoped_temp_dir.h" |
15 #include "base/macros.h" | 18 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
17 #include "base/metrics/field_trial.h" | 20 #include "base/metrics/field_trial.h" |
18 #include "base/path_service.h" | 21 #include "base/path_service.h" |
19 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
20 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
21 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
23 #include "base/test/thread_test_helper.h" | 26 #include "base/test/thread_test_helper.h" |
24 #include "base/time/time.h" | 27 #include "base/time/time.h" |
25 #include "build/build_config.h" | 28 #include "build/build_config.h" |
26 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" | 29 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" |
27 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.h" |
29 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 32 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
30 #include "chrome/browser/prerender/prerender_manager.h" | 33 #include "chrome/browser/prerender/prerender_manager.h" |
31 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/profiles/profile_manager.h" | 35 #include "chrome/browser/profiles/profile_manager.h" |
33 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 36 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
34 #include "chrome/browser/safe_browsing/database_manager.h" | 37 #include "chrome/browser/safe_browsing/database_manager.h" |
35 #include "chrome/browser/safe_browsing/local_database_manager.h" | 38 #include "chrome/browser/safe_browsing/local_database_manager.h" |
36 #include "chrome/browser/safe_browsing/metadata.pb.h" | 39 #include "chrome/browser/safe_browsing/metadata.pb.h" |
37 #include "chrome/browser/safe_browsing/protocol_manager.h" | 40 #include "chrome/browser/safe_browsing/protocol_manager.h" |
38 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 41 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
39 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | |
40 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 42 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
41 #include "chrome/browser/safe_browsing/ui_manager.h" | 43 #include "chrome/browser/safe_browsing/ui_manager.h" |
42 #include "chrome/browser/ui/browser.h" | 44 #include "chrome/browser/ui/browser.h" |
43 #include "chrome/browser/ui/browser_navigator_params.h" | 45 #include "chrome/browser/ui/browser_navigator_params.h" |
44 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 46 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
45 #include "chrome/common/chrome_paths.h" | 47 #include "chrome/common/chrome_paths.h" |
46 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
47 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
48 #include "chrome/test/base/in_process_browser_test.h" | 50 #include "chrome/test/base/in_process_browser_test.h" |
49 #include "chrome/test/base/ui_test_utils.h" | 51 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 ADD_FAILURE() << "bad cookie " << cookie.first << "=" << cookie.second; | 1610 ADD_FAILURE() << "bad cookie " << cookie.first << "=" << cookie.second; |
1609 return nullptr; | 1611 return nullptr; |
1610 } | 1612 } |
1611 | 1613 |
1612 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 1614 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
1613 new net::test_server::BasicHttpResponse()); | 1615 new net::test_server::BasicHttpResponse()); |
1614 http_response->set_content("foo"); | 1616 http_response->set_content("foo"); |
1615 http_response->set_content_type("text/plain"); | 1617 http_response->set_content_type("text/plain"); |
1616 http_response->AddCustomHeader( | 1618 http_response->AddCustomHeader( |
1617 "Set-Cookie", "c=d; Expires=Fri, 01 Jan 2038 01:01:01 GMT"); | 1619 "Set-Cookie", "c=d; Expires=Fri, 01 Jan 2038 01:01:01 GMT"); |
1618 return http_response.Pass(); | 1620 return std::move(http_response); |
1619 } | 1621 } |
1620 | 1622 |
1621 scoped_ptr<TestSafeBrowsingServiceFactory> sb_factory_; | 1623 scoped_ptr<TestSafeBrowsingServiceFactory> sb_factory_; |
1622 | 1624 |
1623 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseManagerCookieTest); | 1625 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseManagerCookieTest); |
1624 }; | 1626 }; |
1625 | 1627 |
1626 // Test that a Local Safe Browsing database update request both sends cookies | 1628 // Test that a Local Safe Browsing database update request both sends cookies |
1627 // and can save cookies. | 1629 // and can save cookies. |
1628 IN_PROC_BROWSER_TEST_F(SafeBrowsingDatabaseManagerCookieTest, | 1630 IN_PROC_BROWSER_TEST_F(SafeBrowsingDatabaseManagerCookieTest, |
1629 TestSBUpdateCookies) { | 1631 TestSBUpdateCookies) { |
1630 content::WindowedNotificationObserver observer( | 1632 content::WindowedNotificationObserver observer( |
1631 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 1633 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
1632 content::Source<SafeBrowsingDatabaseManager>( | 1634 content::Source<SafeBrowsingDatabaseManager>( |
1633 sb_service_->database_manager().get())); | 1635 sb_service_->database_manager().get())); |
1634 BrowserThread::PostTask( | 1636 BrowserThread::PostTask( |
1635 BrowserThread::IO, FROM_HERE, | 1637 BrowserThread::IO, FROM_HERE, |
1636 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 1638 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
1637 observer.Wait(); | 1639 observer.Wait(); |
1638 } | 1640 } |
1639 | 1641 |
1640 } // namespace safe_browsing | 1642 } // namespace safe_browsing |
OLD | NEW |