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

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

Issue 1832913003: Don't focus the location bar in a phishy situation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 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
« no previous file with comments | « chrome/browser/ui/browser_focus_uitest.cc ('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) 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 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. 2916 // Resume blocked requests for both the RenderViewHost and RenderFrameHost.
2917 // TODO(brettw): It seems bogus to reach into here and initialize the host. 2917 // TODO(brettw): It seems bogus to reach into here and initialize the host.
2918 if (is_resume_pending_) { 2918 if (is_resume_pending_) {
2919 is_resume_pending_ = false; 2919 is_resume_pending_ = false;
2920 GetRenderViewHost()->GetWidget()->Init(); 2920 GetRenderViewHost()->GetWidget()->Init();
2921 GetMainFrame()->Init(); 2921 GetMainFrame()->Init();
2922 } 2922 }
2923 } 2923 }
2924 2924
2925 bool WebContentsImpl::FocusLocationBarByDefault() { 2925 bool WebContentsImpl::FocusLocationBarByDefault() {
2926 NavigationEntry* entry = controller_.GetVisibleEntry(); 2926 // When the browser is started with about:blank as the startup URL, focus
2927 if (entry && entry->GetURL() == GURL(url::kAboutBlankURL)) 2927 // the location bar (which will also select its contents) so people can
2928 // simply begin typing to navigate elsewhere.
2929 //
2930 // We need to be careful not to trigger this for anything other than the
2931 // startup navigation. In particular, if we allow an attacker to open a
2932 // popup to about:blank, then navigate, focusing the Omnibox will cause the
2933 // end of the new URL to be scrolled into view instead of the start,
2934 // allowing the attacker to spoof other URLs. The conditions checked here
2935 // are all aimed at ensuring no such attacker-controlled navigation can
2936 // trigger this.
2937 //
2938 // Note that we check the pending entry instead of the visible one; for the
2939 // startup URL case these are the same, but for the attacker-controlled
2940 // navigation case the visible entry is the committed "about:blank" URL and
2941 // the pending entry is the problematic navigation elsewhere.
2942 NavigationEntryImpl* entry = controller_.GetPendingEntry();
2943 if (controller_.IsInitialNavigation() && entry &&
2944 !entry->is_renderer_initiated() &&
2945 entry->GetURL() == GURL(url::kAboutBlankURL)) {
2928 return true; 2946 return true;
2947 }
2929 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); 2948 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this);
2930 } 2949 }
2931 2950
2932 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { 2951 void WebContentsImpl::SetFocusToLocationBar(bool select_all) {
2933 if (delegate_) 2952 if (delegate_)
2934 delegate_->SetFocusToLocationBar(select_all); 2953 delegate_->SetFocusToLocationBar(select_all);
2935 } 2954 }
2936 2955
2937 void WebContentsImpl::DidStartNavigation(NavigationHandle* navigation_handle) { 2956 void WebContentsImpl::DidStartNavigation(NavigationHandle* navigation_handle) {
2938 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2957 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after
4788 const WebContentsObserver::MediaPlayerId& id) { 4807 const WebContentsObserver::MediaPlayerId& id) {
4789 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); 4808 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id));
4790 } 4809 }
4791 4810
4792 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 4811 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
4793 JavaScriptDialogManager* dialog_manager) { 4812 JavaScriptDialogManager* dialog_manager) {
4794 dialog_manager_ = dialog_manager; 4813 dialog_manager_ = dialog_manager;
4795 } 4814 }
4796 4815
4797 } // namespace content 4816 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_focus_uitest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698