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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2919593007: Always update the omnibox URL when cancelling via onbeforeunload (Closed)
Patch Set: Test tweaking Created 3 years, 6 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
OLDNEW
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 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 4722 matching lines...) Expand 10 before | Expand all | Expand 10 after
4733 return GetContentClient()->browser()->CreateThrottlesForNavigation( 4733 return GetContentClient()->browser()->CreateThrottlesForNavigation(
4734 navigation_handle); 4734 navigation_handle);
4735 } 4735 }
4736 4736
4737 std::unique_ptr<NavigationUIData> WebContentsImpl::GetNavigationUIData( 4737 std::unique_ptr<NavigationUIData> WebContentsImpl::GetNavigationUIData(
4738 NavigationHandle* navigation_handle) { 4738 NavigationHandle* navigation_handle) {
4739 DCHECK(IsBrowserSideNavigationEnabled()); 4739 DCHECK(IsBrowserSideNavigationEnabled());
4740 return GetContentClient()->browser()->GetNavigationUIData(navigation_handle); 4740 return GetContentClient()->browser()->GetNavigationUIData(navigation_handle);
4741 } 4741 }
4742 4742
4743 void WebContentsImpl::DidCancelLoading() {
4744 controller_.DiscardNonCommittedEntries();
4745
4746 // Update the URL display.
4747 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
4748 }
4749
4750 void WebContentsImpl::DidAccessInitialDocument() { 4743 void WebContentsImpl::DidAccessInitialDocument() {
4751 has_accessed_initial_document_ = true; 4744 has_accessed_initial_document_ = true;
4752 4745
4753 // We may have left a failed browser-initiated navigation in the address bar 4746 // We may have left a failed browser-initiated navigation in the address bar
4754 // to let the user edit it and try again. Clear it now that content might 4747 // to let the user edit it and try again. Clear it now that content might
4755 // show up underneath it. 4748 // show up underneath it.
4756 if (!IsLoading() && controller_.GetPendingEntry()) 4749 if (!IsLoading() && controller_.GetPendingEntry())
4757 controller_.DiscardPendingEntry(false); 4750 controller_.DiscardPendingEntry(false);
4758 4751
4759 // Update the URL display. 4752 // Update the URL display.
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
5287 const base::string16& user_input) { 5280 const base::string16& user_input) {
5288 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id, 5281 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id,
5289 render_frame_id); 5282 render_frame_id);
5290 last_dialog_suppressed_ = dialog_was_suppressed; 5283 last_dialog_suppressed_ = dialog_was_suppressed;
5291 5284
5292 if (is_showing_before_unload_dialog_ && !success) { 5285 if (is_showing_before_unload_dialog_ && !success) {
5293 // It is possible for the current RenderFrameHost to have changed in the 5286 // It is possible for the current RenderFrameHost to have changed in the
5294 // meantime. Do not reset the navigation state in that case. 5287 // meantime. Do not reset the navigation state in that case.
5295 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) { 5288 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) {
5296 rfh->frame_tree_node()->BeforeUnloadCanceled(); 5289 rfh->frame_tree_node()->BeforeUnloadCanceled();
5290
5291 // Remove the entry for the navigation that's being cancelled, and notify
5292 // the WebContentsDelegate that the visible URL has changed.
5297 controller_.DiscardNonCommittedEntries(); 5293 controller_.DiscardNonCommittedEntries();
5298 } 5294 }
5299 5295
5300 for (auto& observer : observers_) 5296 for (auto& observer : observers_)
5301 observer.BeforeUnloadDialogCancelled(); 5297 observer.BeforeUnloadDialogCancelled();
5302 } 5298 }
5303 5299
5304 if (rfh) { 5300 if (rfh) {
5305 rfh->JavaScriptDialogClosed(reply_msg, success, user_input); 5301 rfh->JavaScriptDialogClosed(reply_msg, success, user_input);
5306 } else { 5302 } else {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
5621 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); 5617 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host);
5622 if (!render_view_host) 5618 if (!render_view_host)
5623 continue; 5619 continue;
5624 render_view_host_set.insert(render_view_host); 5620 render_view_host_set.insert(render_view_host);
5625 } 5621 }
5626 for (RenderViewHost* render_view_host : render_view_host_set) 5622 for (RenderViewHost* render_view_host : render_view_host_set)
5627 render_view_host->OnWebkitPreferencesChanged(); 5623 render_view_host->OnWebkitPreferencesChanged();
5628 } 5624 }
5629 5625
5630 } // namespace content 5626 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698