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

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: Merge remote-tracking branch 'origin/master' into spoof 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 4795 matching lines...) Expand 10 before | Expand all | Expand 10 after
4806 return GetContentClient()->browser()->CreateThrottlesForNavigation( 4806 return GetContentClient()->browser()->CreateThrottlesForNavigation(
4807 navigation_handle); 4807 navigation_handle);
4808 } 4808 }
4809 4809
4810 std::unique_ptr<NavigationUIData> WebContentsImpl::GetNavigationUIData( 4810 std::unique_ptr<NavigationUIData> WebContentsImpl::GetNavigationUIData(
4811 NavigationHandle* navigation_handle) { 4811 NavigationHandle* navigation_handle) {
4812 DCHECK(IsBrowserSideNavigationEnabled()); 4812 DCHECK(IsBrowserSideNavigationEnabled());
4813 return GetContentClient()->browser()->GetNavigationUIData(navigation_handle); 4813 return GetContentClient()->browser()->GetNavigationUIData(navigation_handle);
4814 } 4814 }
4815 4815
4816 void WebContentsImpl::DidCancelLoading() {
4817 controller_.DiscardNonCommittedEntries();
4818
4819 // Update the URL display.
4820 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
4821 }
4822
4823 void WebContentsImpl::DidAccessInitialDocument() { 4816 void WebContentsImpl::DidAccessInitialDocument() {
4824 has_accessed_initial_document_ = true; 4817 has_accessed_initial_document_ = true;
4825 4818
4826 // We may have left a failed browser-initiated navigation in the address bar 4819 // We may have left a failed browser-initiated navigation in the address bar
4827 // to let the user edit it and try again. Clear it now that content might 4820 // to let the user edit it and try again. Clear it now that content might
4828 // show up underneath it. 4821 // show up underneath it.
4829 if (!IsLoading() && controller_.GetPendingEntry()) 4822 if (!IsLoading() && controller_.GetPendingEntry())
4830 controller_.DiscardPendingEntry(false); 4823 controller_.DiscardPendingEntry(false);
4831 4824
4832 // Update the URL display. 4825 // Update the URL display.
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
5363 const base::string16& user_input) { 5356 const base::string16& user_input) {
5364 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id, 5357 RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id,
5365 render_frame_id); 5358 render_frame_id);
5366 last_dialog_suppressed_ = dialog_was_suppressed; 5359 last_dialog_suppressed_ = dialog_was_suppressed;
5367 5360
5368 if (is_showing_before_unload_dialog_ && !success) { 5361 if (is_showing_before_unload_dialog_ && !success) {
5369 // It is possible for the current RenderFrameHost to have changed in the 5362 // It is possible for the current RenderFrameHost to have changed in the
5370 // meantime. Do not reset the navigation state in that case. 5363 // meantime. Do not reset the navigation state in that case.
5371 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) { 5364 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) {
5372 rfh->frame_tree_node()->BeforeUnloadCanceled(); 5365 rfh->frame_tree_node()->BeforeUnloadCanceled();
5366
5367 // Remove the entry for the navigation that's being cancelled, and notify
5368 // the WebContentsDelegate that the visible URL has changed.
5373 controller_.DiscardNonCommittedEntries(); 5369 controller_.DiscardNonCommittedEntries();
5374 } 5370 }
5375 5371
5376 for (auto& observer : observers_) 5372 for (auto& observer : observers_)
5377 observer.BeforeUnloadDialogCancelled(); 5373 observer.BeforeUnloadDialogCancelled();
5378 } 5374 }
5379 5375
5380 if (rfh) { 5376 if (rfh) {
5381 rfh->JavaScriptDialogClosed(reply_msg, success, user_input); 5377 rfh->JavaScriptDialogClosed(reply_msg, success, user_input);
5382 } else { 5378 } else {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
5748 } 5744 }
5749 5745
5750 void WebContentsImpl::MediaMutedStatusChanged( 5746 void WebContentsImpl::MediaMutedStatusChanged(
5751 const WebContentsObserver::MediaPlayerId& id, 5747 const WebContentsObserver::MediaPlayerId& id,
5752 bool muted) { 5748 bool muted) {
5753 for (auto& observer : observers_) 5749 for (auto& observer : observers_)
5754 observer.MediaMutedStatusChanged(id, muted); 5750 observer.MediaMutedStatusChanged(id, muted);
5755 } 5751 }
5756 5752
5757 } // namespace content 5753 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698