Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc

Issue 6720050: Make contents settable in RVHTH. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 virtual void OnBlockingPageComplete(bool proceed) { 94 virtual void OnBlockingPageComplete(bool proceed) {
95 if (proceed) 95 if (proceed)
96 user_response_ = OK; 96 user_response_ = OK;
97 else 97 else
98 user_response_ = CANCEL; 98 user_response_ = CANCEL;
99 } 99 }
100 100
101 void Navigate(const char* url, int page_id) { 101 void Navigate(const char* url, int page_id) {
102 ViewHostMsg_FrameNavigate_Params params; 102 ViewHostMsg_FrameNavigate_Params params;
103 InitNavigateParams(&params, page_id, GURL(url), PageTransition::TYPED); 103 InitNavigateParams(&params, page_id, GURL(url), PageTransition::TYPED);
104 contents()->TestDidNavigate(contents_->render_view_host(), params); 104 contents()->TestDidNavigate(contents()->render_view_host(), params);
105 } 105 }
106 106
107 void GoBackCrossSite() { 107 void GoBackCrossSite() {
108 NavigationEntry* entry = contents()->controller().GetEntryAtOffset(-1); 108 NavigationEntry* entry = contents()->controller().GetEntryAtOffset(-1);
109 ASSERT_TRUE(entry); 109 ASSERT_TRUE(entry);
110 contents()->controller().GoBack(); 110 contents()->controller().GoBack();
111 111
112 // The navigation should commit in the pending RVH. 112 // The navigation should commit in the pending RVH.
113 ViewHostMsg_FrameNavigate_Params params; 113 ViewHostMsg_FrameNavigate_Params params;
114 InitNavigateParams(&params, entry->page_id(), GURL(entry->url()), 114 InitNavigateParams(&params, entry->page_id(), GURL(entry->url()),
115 PageTransition::TYPED); 115 PageTransition::TYPED);
116 contents()->TestDidNavigate(contents_->pending_rvh(), params); 116 contents()->TestDidNavigate(contents()->pending_rvh(), params);
117 } 117 }
118 118
119 void ShowInterstitial(ResourceType::Type resource_type, 119 void ShowInterstitial(ResourceType::Type resource_type,
120 const char* url) { 120 const char* url) {
121 SafeBrowsingService::UnsafeResource resource; 121 SafeBrowsingService::UnsafeResource resource;
122 InitResource(&resource, resource_type, GURL(url)); 122 InitResource(&resource, resource_type, GURL(url));
123 SafeBrowsingBlockingPage::ShowBlockingPage(service_, resource); 123 SafeBrowsingBlockingPage::ShowBlockingPage(service_, resource);
124 } 124 }
125 125
126 // Returns the SafeBrowsingBlockingPage currently showing or NULL if none is 126 // Returns the SafeBrowsingBlockingPage currently showing or NULL if none is
(...skipping 26 matching lines...) Expand all
153 scoped_refptr<TestSafeBrowsingService> service_; 153 scoped_refptr<TestSafeBrowsingService> service_;
154 154
155 private: 155 private:
156 void InitResource(SafeBrowsingService::UnsafeResource* resource, 156 void InitResource(SafeBrowsingService::UnsafeResource* resource,
157 ResourceType::Type resource_type, 157 ResourceType::Type resource_type,
158 const GURL& url) { 158 const GURL& url) {
159 resource->client = this; 159 resource->client = this;
160 resource->url = url; 160 resource->url = url;
161 resource->resource_type = resource_type; 161 resource->resource_type = resource_type;
162 resource->threat_type = SafeBrowsingService::URL_MALWARE; 162 resource->threat_type = SafeBrowsingService::URL_MALWARE;
163 resource->render_process_host_id = contents_->GetRenderProcessHost()->id(); 163 resource->render_process_host_id = contents()->GetRenderProcessHost()->id();
164 resource->render_view_id = contents_->render_view_host()->routing_id(); 164 resource->render_view_id = contents()->render_view_host()->routing_id();
165 } 165 }
166 166
167 UserResponse user_response_; 167 UserResponse user_response_;
168 TestSafeBrowsingBlockingPageFactory factory_; 168 TestSafeBrowsingBlockingPageFactory factory_;
169 BrowserThread ui_thread_; 169 BrowserThread ui_thread_;
170 BrowserThread io_thread_; 170 BrowserThread io_thread_;
171 }; 171 };
172 172
173 // Tests showing a blocking page for a malware page and not proceeding. 173 // Tests showing a blocking page for a malware page and not proceeding.
174 TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) { 174 TEST_F(SafeBrowsingBlockingPageTest, MalwarePageDontProceed) {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 577
578 EXPECT_TRUE(contents()->profile()->GetPrefs()->GetBoolean( 578 EXPECT_TRUE(contents()->profile()->GetPrefs()->GetBoolean(
579 prefs::kSafeBrowsingReportingEnabled)); 579 prefs::kSafeBrowsingReportingEnabled));
580 580
581 // Simulate the user uncheck the report agreement checkbox. 581 // Simulate the user uncheck the report agreement checkbox.
582 sb_interstitial->SetReportingPreference(false); 582 sb_interstitial->SetReportingPreference(false);
583 583
584 EXPECT_FALSE(contents()->profile()->GetPrefs()->GetBoolean( 584 EXPECT_FALSE(contents()->profile()->GetPrefs()->GetBoolean(
585 prefs::kSafeBrowsingReportingEnabled)); 585 prefs::kSafeBrowsingReportingEnabled));
586 } 586 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698