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

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

Issue 479: DidNavigate refactor of doom (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Implementation of the SafeBrowsingBlockingPage class. 5 // Implementation of the SafeBrowsingBlockingPage class.
6 6
7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
8 8
9 #include "chrome/app/locales/locale_settings.h" 9 #include "chrome/app/locales/locale_settings.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 164
165 std::string html_page(jstemplate_builder::GetTemplateHtml(html, 165 std::string html_page(jstemplate_builder::GetTemplateHtml(html,
166 &strings, 166 &strings,
167 "template_root")); 167 "template_root"));
168 168
169 // If the malware is the actual main frame and we have no pending entry 169 // If the malware is the actual main frame and we have no pending entry
170 // (typically the navigation was initiated by the page), we create a fake 170 // (typically the navigation was initiated by the page), we create a fake
171 // navigation entry (so the location bar shows the page's URL). 171 // navigation entry (so the location bar shows the page's URL).
172 if (is_main_frame_ && tab_->controller()->GetPendingEntryIndex() == -1) { 172 if (is_main_frame_ && tab_->controller()->GetPendingEntryIndex() == -1) {
173 // New navigation. 173 NavigationEntry new_entry(TAB_CONTENTS_WEB);
174 NavigationEntry* nav_entry = new NavigationEntry(TAB_CONTENTS_WEB); 174 new_entry.set_url(url_);
175 175 new_entry.set_page_type(NavigationEntry::INTERSTITIAL_PAGE);
176 // We set the page ID to max page id so to ensure the controller considers 176 tab_->controller()->AddDummyEntryForInterstitial(new_entry);
177 // this dummy entry a new one. Because we'll remove the entry when the
178 // interstitial is going away, it will not conflict with any future
179 // navigations.
180 nav_entry->set_page_id(tab_->GetMaxPageID() + 1);
181 nav_entry->set_page_type(NavigationEntry::INTERSTITIAL_PAGE);
182 nav_entry->set_url(url_);
183
184 // The default details is "new navigation", and that's OK with us.
185 NavigationController::LoadCommittedDetails details;
186 tab_->controller()->DidNavigateToEntry(nav_entry, &details);
187 created_temporary_entry_ = true; 177 created_temporary_entry_ = true;
188 } 178 }
189 179
190 // Show the interstitial page. 180 // Show the interstitial page.
191 web_contents->ShowInterstitialPage(html_page, this); 181 web_contents->ShowInterstitialPage(html_page, this);
192 } 182 }
193 183
194 void SafeBrowsingBlockingPage::Observe(NotificationType type, 184 void SafeBrowsingBlockingPage::Observe(NotificationType type,
195 const NotificationSource& source, 185 const NotificationSource& source,
196 const NotificationDetails& details) { 186 const NotificationDetails& details) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // and show the page the user was on before. 228 // and show the page the user was on before.
239 web_contents->HideInterstitialPage(false, false); 229 web_contents->HideInterstitialPage(false, false);
240 } 230 }
241 231
242 // WARNING: at this point we are now either deleted or pending deletion from 232 // WARNING: at this point we are now either deleted or pending deletion from
243 // the IO thread. 233 // the IO thread.
244 234
245 // Remove the navigation entry for the malware page. Note that we always 235 // Remove the navigation entry for the malware page. Note that we always
246 // remove the entry even if we did not create it as it has been flagged as 236 // remove the entry even if we did not create it as it has been flagged as
247 // malware and we don't want the user navigating back to it. 237 // malware and we don't want the user navigating back to it.
248 web_contents->controller()->RemoveLastEntry(); 238 web_contents->controller()->RemoveLastEntryForInterstitial();
249 239
250 return true; 240 return true;
251 } 241 }
252 242
253 void SafeBrowsingBlockingPage::Continue(const std::string& user_action) { 243 void SafeBrowsingBlockingPage::Continue(const std::string& user_action) {
254 TabContents* tab = tab_util::GetTabContentsByID(render_process_host_id_, 244 TabContents* tab = tab_util::GetTabContentsByID(render_process_host_id_,
255 render_view_id_); 245 render_view_id_);
256 DCHECK(tab); 246 DCHECK(tab);
257 WebContents* web = tab->AsWebContents(); 247 WebContents* web = tab->AsWebContents();
258 if (user_action == "2") { 248 if (user_action == "2") {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 web->OpenURL(diagnostic_url, CURRENT_TAB, PageTransition::LINK); 280 web->OpenURL(diagnostic_url, CURRENT_TAB, PageTransition::LINK);
291 return; 281 return;
292 } 282 }
293 283
294 proceed_ = user_action == "1"; 284 proceed_ = user_action == "1";
295 285
296 if (proceed_) { 286 if (proceed_) {
297 // We are continuing, if we have created a temporary navigation entry, 287 // We are continuing, if we have created a temporary navigation entry,
298 // delete it as a new will be created on navigation. 288 // delete it as a new will be created on navigation.
299 if (created_temporary_entry_) 289 if (created_temporary_entry_)
300 web->controller()->RemoveLastEntry(); 290 web->controller()->RemoveLastEntryForInterstitial();
301 if (is_main_frame_) 291 if (is_main_frame_)
302 web->HideInterstitialPage(true, true); 292 web->HideInterstitialPage(true, true);
303 else 293 else
304 web->HideInterstitialPage(false, false); 294 web->HideInterstitialPage(false, false);
305 } else { 295 } else {
306 GoBack(); 296 GoBack();
307 } 297 }
308 298
309 NotifyDone(); 299 NotifyDone();
310 } 300 }
(...skipping 24 matching lines...) Expand all
335 base::Thread* io_thread = g_browser_process->io_thread(); 325 base::Thread* io_thread = g_browser_process->io_thread();
336 if (!io_thread) 326 if (!io_thread)
337 return; 327 return;
338 328
339 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 329 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
340 sb_service_, 330 sb_service_,
341 &SafeBrowsingService::OnBlockingPageDone, 331 &SafeBrowsingService::OnBlockingPageDone,
342 this, client_, proceed_)); 332 this, client_, proceed_));
343 } 333 }
344 334
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698