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

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

Issue 1678233003: Don't focus the location bar in a phishy situation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Thanks! 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 2916 matching lines...) Expand 10 before | Expand all | Expand 10 after
2927 // Resume blocked requests for both the RenderViewHost and RenderFrameHost. 2927 // Resume blocked requests for both the RenderViewHost and RenderFrameHost.
2928 // TODO(brettw): It seems bogus to reach into here and initialize the host. 2928 // TODO(brettw): It seems bogus to reach into here and initialize the host.
2929 if (is_resume_pending_) { 2929 if (is_resume_pending_) {
2930 is_resume_pending_ = false; 2930 is_resume_pending_ = false;
2931 GetRenderViewHost()->GetWidget()->Init(); 2931 GetRenderViewHost()->GetWidget()->Init();
2932 GetMainFrame()->Init(); 2932 GetMainFrame()->Init();
2933 } 2933 }
2934 } 2934 }
2935 2935
2936 bool WebContentsImpl::FocusLocationBarByDefault() { 2936 bool WebContentsImpl::FocusLocationBarByDefault() {
2937 NavigationEntry* entry = controller_.GetVisibleEntry(); 2937 // When the browser is started with about:blank as the startup URL, focus
2938 if (entry && entry->GetURL() == GURL(url::kAboutBlankURL)) 2938 // the location bar (which will also select its contents) so people can
2939 // simply begin typing to navigate elsewhere.
2940 //
2941 // We need to be careful not to trigger this for anything other than the
2942 // startup navigation. In particular, if we allow an attacker to open a
2943 // popup to about:blank, then navigate, focusing the Omnibox will cause the
2944 // end of the new URL to be scrolled into view instead of the start,
2945 // allowing the attacker to spoof other URLs. The conditions checked here
2946 // are all aimed at ensuring no such attacker-controlled navigation can
2947 // trigger this.
2948 //
2949 // Note that we check the pending entry instead of the visible one; for the
2950 // startup URL case these are the same, but for the attacker-controlled
2951 // navigation case the visible entry is the committed "about:blank" URL and
2952 // the pending entry is the problematic navigation elsewhere.
groby-ooo-7-16 2016/03/07 20:00:37 Thank you, thank you, thank you! Future Rachel is
2953 NavigationEntryImpl* entry = controller_.GetPendingEntry();
2954 if (controller_.IsInitialNavigation() && entry &&
2955 !entry->is_renderer_initiated() &&
2956 entry->GetURL() == GURL(url::kAboutBlankURL)) {
2939 return true; 2957 return true;
2958 }
2940 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); 2959 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this);
2941 } 2960 }
2942 2961
2943 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { 2962 void WebContentsImpl::SetFocusToLocationBar(bool select_all) {
2944 if (delegate_) 2963 if (delegate_)
2945 delegate_->SetFocusToLocationBar(select_all); 2964 delegate_->SetFocusToLocationBar(select_all);
2946 } 2965 }
2947 2966
2948 void WebContentsImpl::DidStartNavigation(NavigationHandle* navigation_handle) { 2967 void WebContentsImpl::DidStartNavigation(NavigationHandle* navigation_handle) {
2949 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2968 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after
4822 else 4841 else
4823 WasHidden(); 4842 WasHidden();
4824 } 4843 }
4825 4844
4826 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 4845 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
4827 JavaScriptDialogManager* dialog_manager) { 4846 JavaScriptDialogManager* dialog_manager) {
4828 dialog_manager_ = dialog_manager; 4847 dialog_manager_ = dialog_manager;
4829 } 4848 }
4830 4849
4831 } // namespace content 4850 } // 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