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

Side by Side Diff: chrome/browser/tab_contents/interstitial_page.cc

Issue 100002: Fix for interstitial reload bug (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « chrome/browser/tab_contents/interstitial_page.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/tab_contents/interstitial_page.h" 5 #include "chrome/browser/tab_contents/interstitial_page.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/thread.h" 9 #include "base/thread.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // static 99 // static
100 InterstitialPage::InterstitialPageMap* 100 InterstitialPage::InterstitialPageMap*
101 InterstitialPage::tab_to_interstitial_page_ = NULL; 101 InterstitialPage::tab_to_interstitial_page_ = NULL;
102 102
103 InterstitialPage::InterstitialPage(WebContents* tab, 103 InterstitialPage::InterstitialPage(WebContents* tab,
104 bool new_navigation, 104 bool new_navigation,
105 const GURL& url) 105 const GURL& url)
106 : tab_(tab), 106 : tab_(tab),
107 url_(url), 107 url_(url),
108 new_navigation_(new_navigation), 108 new_navigation_(new_navigation),
109 should_discard_pending_nav_entry_(new_navigation),
109 enabled_(true), 110 enabled_(true),
110 action_taken_(false), 111 action_taken_(false),
111 render_view_host_(NULL), 112 render_view_host_(NULL),
112 original_rvh_process_id_(tab->render_view_host()->process()->pid()), 113 original_rvh_process_id_(tab->render_view_host()->process()->pid()),
113 original_rvh_id_(tab->render_view_host()->routing_id()), 114 original_rvh_id_(tab->render_view_host()->routing_id()),
114 should_revert_tab_title_(false), 115 should_revert_tab_title_(false),
115 resource_dispatcher_host_notified_(false), 116 resource_dispatcher_host_notified_(false),
116 ui_loop_(MessageLoop::current()), 117 ui_loop_(MessageLoop::current()),
117 ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_( 118 ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_(
118 new InterstitialPageRVHViewDelegate(this))) { 119 new InterstitialPageRVHViewDelegate(this))) {
(...skipping 12 matching lines...) Expand all
131 "http://crbug.com/9442 with the URL you were visiting"; 132 "http://crbug.com/9442 with the URL you were visiting";
132 if (iter != tab_to_interstitial_page_->end()) 133 if (iter != tab_to_interstitial_page_->end())
133 tab_to_interstitial_page_->erase(iter); 134 tab_to_interstitial_page_->erase(iter);
134 DCHECK(!render_view_host_); 135 DCHECK(!render_view_host_);
135 } 136 }
136 137
137 void InterstitialPage::Show() { 138 void InterstitialPage::Show() {
138 // If an interstitial is already showing, close it before showing the new one. 139 // If an interstitial is already showing, close it before showing the new one.
139 // Be careful not to take an action on the old interstitial more than once. 140 // Be careful not to take an action on the old interstitial more than once.
140 if (tab_->interstitial_page()) { 141 if (tab_->interstitial_page()) {
141 if (tab_->interstitial_page()->action_taken()) 142 if (tab_->interstitial_page()->action_taken()) {
142 tab_->interstitial_page()->Hide(); 143 tab_->interstitial_page()->Hide();
143 else 144 } else {
145 // If we are currently showing an interstitial page for which we created
146 // a transient entry and a new interstitial is shown as the result of a
147 // new browser initiated navigation, then that transient entry has already
148 // been discarded and a new pending navigation entry created.
149 // So we should not discard that new pending navigation entry.
150 // See http://crbug.com/9791
151 if (new_navigation_ && tab_->interstitial_page()->new_navigation_)
152 tab_->interstitial_page()->should_discard_pending_nav_entry_= false;
144 tab_->interstitial_page()->DontProceed(); 153 tab_->interstitial_page()->DontProceed();
154 }
145 } 155 }
146 156
147 // Block the resource requests for the render view host while it is hidden. 157 // Block the resource requests for the render view host while it is hidden.
148 TakeActionOnResourceDispatcher(BLOCK); 158 TakeActionOnResourceDispatcher(BLOCK);
149 // We need to be notified when the RenderViewHost is destroyed so we can 159 // We need to be notified when the RenderViewHost is destroyed so we can
150 // cancel the blocked requests. We cannot do that on 160 // cancel the blocked requests. We cannot do that on
151 // NOTIFY_TAB_CONTENTS_DESTROYED as at that point the RenderViewHost has 161 // NOTIFY_TAB_CONTENTS_DESTROYED as at that point the RenderViewHost has
152 // already been destroyed. 162 // already been destroyed.
153 notification_registrar_.Add( 163 notification_registrar_.Add(
154 this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, 164 this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // If this is a new navigation, we are returning to the original page, so we 319 // If this is a new navigation, we are returning to the original page, so we
310 // resume blocked requests for it. If it is not a new navigation, then it 320 // resume blocked requests for it. If it is not a new navigation, then it
311 // means the interstitial was shown as a result of a resource loading in the 321 // means the interstitial was shown as a result of a resource loading in the
312 // page and we won't return to the original page, so we cancel blocked 322 // page and we won't return to the original page, so we cancel blocked
313 // requests in that case. 323 // requests in that case.
314 if (new_navigation_) 324 if (new_navigation_)
315 TakeActionOnResourceDispatcher(RESUME); 325 TakeActionOnResourceDispatcher(RESUME);
316 else 326 else
317 TakeActionOnResourceDispatcher(CANCEL); 327 TakeActionOnResourceDispatcher(CANCEL);
318 328
319 if (new_navigation_) { 329 if (should_discard_pending_nav_entry_) {
320 // Since no navigation happens we have to discard the transient entry 330 // Since no navigation happens we have to discard the transient entry
321 // explicitely. Note that by calling DiscardNonCommittedEntries() we also 331 // explicitely. Note that by calling DiscardNonCommittedEntries() we also
322 // discard the pending entry, which is what we want, since the navigation is 332 // discard the pending entry, which is what we want, since the navigation is
323 // cancelled. 333 // cancelled.
324 tab_->controller().DiscardNonCommittedEntries(); 334 tab_->controller().DiscardNonCommittedEntries();
325 } 335 }
326 336
327 Hide(); 337 Hide();
328 // WARNING: we are now deleted! 338 // WARNING: we are now deleted!
329 } 339 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent( 505 void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent(
496 const NativeWebKeyboardEvent& event) { 506 const NativeWebKeyboardEvent& event) {
497 if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) 507 if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate())
498 interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event); 508 interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event);
499 } 509 }
500 510
501 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( 511 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply(
502 int request_id, int number_of_matches, const gfx::Rect& selection_rect, 512 int request_id, int number_of_matches, const gfx::Rect& selection_rect,
503 int active_match_ordinal, bool final_update) { 513 int active_match_ordinal, bool final_update) {
504 } 514 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/interstitial_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698