OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 5 |
6 #include "chrome/browser/prefs/pref_service.h" | 6 #include "chrome/browser/prefs/pref_service.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/safe_browsing/malware_details.h" | 8 #include "chrome/browser/safe_browsing/malware_details.h" |
9 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
12 #include "content/browser/tab_contents/test_tab_contents.h" | 12 #include "content/browser/tab_contents/test_tab_contents.h" |
13 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
14 #include "content/test/test_browser_thread.h" | 14 #include "content/test/test_browser_thread.h" |
15 | 15 |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
| 17 using content::NavigationEntry; |
17 | 18 |
18 static const char* kGoogleURL = "http://www.google.com/"; | 19 static const char* kGoogleURL = "http://www.google.com/"; |
19 static const char* kGoodURL = "http://www.goodguys.com/"; | 20 static const char* kGoodURL = "http://www.goodguys.com/"; |
20 static const char* kBadURL = "http://www.badguys.com/"; | 21 static const char* kBadURL = "http://www.badguys.com/"; |
21 static const char* kBadURL2 = "http://www.badguys2.com/"; | 22 static const char* kBadURL2 = "http://www.badguys2.com/"; |
22 static const char* kBadURL3 = "http://www.badguys3.com/"; | 23 static const char* kBadURL3 = "http://www.badguys3.com/"; |
23 | 24 |
24 // A SafeBrowingBlockingPage class that does not create windows. | 25 // A SafeBrowingBlockingPage class that does not create windows. |
25 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { | 26 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { |
26 public: | 27 public: |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 user_response_ = CANCEL; | 109 user_response_ = CANCEL; |
109 } | 110 } |
110 | 111 |
111 void Navigate(const char* url, int page_id) { | 112 void Navigate(const char* url, int page_id) { |
112 contents()->TestDidNavigate( | 113 contents()->TestDidNavigate( |
113 contents()->GetRenderViewHost(), page_id, GURL(url), | 114 contents()->GetRenderViewHost(), page_id, GURL(url), |
114 content::PAGE_TRANSITION_TYPED); | 115 content::PAGE_TRANSITION_TYPED); |
115 } | 116 } |
116 | 117 |
117 void GoBack(bool is_cross_site) { | 118 void GoBack(bool is_cross_site) { |
118 content::NavigationEntry* entry = | 119 NavigationEntry* entry = contents()->GetController().GetEntryAtOffset(-1); |
119 contents()->GetController().GetEntryAtOffset(-1); | |
120 ASSERT_TRUE(entry); | 120 ASSERT_TRUE(entry); |
121 contents()->GetController().GoBack(); | 121 contents()->GetController().GoBack(); |
122 | 122 |
123 // The pending RVH should commit for cross-site navigations. | 123 // The pending RVH should commit for cross-site navigations. |
124 RenderViewHost* rvh = is_cross_site ? | 124 RenderViewHost* rvh = is_cross_site ? |
125 contents()->pending_rvh() : | 125 contents()->pending_rvh() : |
126 contents()->GetRenderViewHost(); | 126 contents()->GetRenderViewHost(); |
127 contents()->TestDidNavigate(rvh, entry->GetPageID(), GURL(entry->GetURL()), | 127 contents()->TestDidNavigate(rvh, entry->GetPageID(), GURL(entry->GetURL()), |
128 content::PAGE_TRANSITION_TYPED); | 128 content::PAGE_TRANSITION_TYPED); |
129 } | 129 } |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 615 |
616 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( | 616 EXPECT_TRUE(profile->GetPrefs()->GetBoolean( |
617 prefs::kSafeBrowsingReportingEnabled)); | 617 prefs::kSafeBrowsingReportingEnabled)); |
618 | 618 |
619 // Simulate the user uncheck the report agreement checkbox. | 619 // Simulate the user uncheck the report agreement checkbox. |
620 sb_interstitial->SetReportingPreference(false); | 620 sb_interstitial->SetReportingPreference(false); |
621 | 621 |
622 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( | 622 EXPECT_FALSE(profile->GetPrefs()->GetBoolean( |
623 prefs::kSafeBrowsingReportingEnabled)); | 623 prefs::kSafeBrowsingReportingEnabled)); |
624 } | 624 } |
OLD | NEW |