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

Side by Side Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 14283005: Allow showing pending URL for new tab navigations, but only if safe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 | Annotate | Revision Log
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/renderer_host/render_view_host_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 bool swapped_out, 163 bool swapped_out,
164 SessionStorageNamespace* session_storage) 164 SessionStorageNamespace* session_storage)
165 : RenderWidgetHostImpl(widget_delegate, instance->GetProcess(), routing_id), 165 : RenderWidgetHostImpl(widget_delegate, instance->GetProcess(), routing_id),
166 delegate_(delegate), 166 delegate_(delegate),
167 instance_(static_cast<SiteInstanceImpl*>(instance)), 167 instance_(static_cast<SiteInstanceImpl*>(instance)),
168 waiting_for_drag_context_response_(false), 168 waiting_for_drag_context_response_(false),
169 enabled_bindings_(0), 169 enabled_bindings_(0),
170 pending_request_id_(-1), 170 pending_request_id_(-1),
171 navigations_suspended_(false), 171 navigations_suspended_(false),
172 suspended_nav_params_(NULL), 172 suspended_nav_params_(NULL),
173 has_accessed_initial_document_(false),
173 is_swapped_out_(swapped_out), 174 is_swapped_out_(swapped_out),
174 is_subframe_(false), 175 is_subframe_(false),
175 main_frame_id_(-1), 176 main_frame_id_(-1),
176 run_modal_reply_msg_(NULL), 177 run_modal_reply_msg_(NULL),
177 run_modal_opener_id_(MSG_ROUTING_NONE), 178 run_modal_opener_id_(MSG_ROUTING_NONE),
178 is_waiting_for_beforeunload_ack_(false), 179 is_waiting_for_beforeunload_ack_(false),
179 is_waiting_for_unload_ack_(false), 180 is_waiting_for_unload_ack_(false),
180 has_timed_out_on_unload_(false), 181 has_timed_out_on_unload_(false),
181 unload_ack_is_for_cross_site_transition_(false), 182 unload_ack_is_for_cross_site_transition_(false),
182 are_javascript_messages_suppressed_(false), 183 are_javascript_messages_suppressed_(false),
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, 993 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
993 OnRequestDesktopNotificationPermission) 994 OnRequestDesktopNotificationPermission)
994 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, 995 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
995 OnShowDesktopNotification) 996 OnShowDesktopNotification)
996 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, 997 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
997 OnCancelDesktopNotification) 998 OnCancelDesktopNotification)
998 #if defined(OS_MACOSX) || defined(OS_ANDROID) 999 #if defined(OS_MACOSX) || defined(OS_ANDROID)
999 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) 1000 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
1000 #endif 1001 #endif
1001 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) 1002 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser)
1003 IPC_MESSAGE_HANDLER(ViewHostMsg_DidAccessInitialDocument,
1004 OnDidAccessInitialDocument)
1002 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, 1005 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse,
1003 OnDomOperationResponse) 1006 OnDomOperationResponse)
1004 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Notifications, 1007 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Notifications,
1005 OnAccessibilityNotifications) 1008 OnAccessibilityNotifications)
1006 // Have the super handle all other messages. 1009 // Have the super handle all other messages.
1007 IPC_MESSAGE_UNHANDLED( 1010 IPC_MESSAGE_UNHANDLED(
1008 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) 1011 handled = RenderWidgetHostImpl::OnMessageReceived(msg))
1009 IPC_END_MESSAGE_MAP_EX() 1012 IPC_END_MESSAGE_MAP_EX()
1010 1013
1011 if (!msg_is_ok) { 1014 if (!msg_is_ok) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 // than our FilterURL checks below. If a renderer violates this policy, it 1218 // than our FilterURL checks below. If a renderer violates this policy, it
1216 // should be killed. 1219 // should be killed.
1217 if (!CanCommitURL(validated_params.url)) { 1220 if (!CanCommitURL(validated_params.url)) {
1218 VLOG(1) << "Blocked URL " << validated_params.url.spec(); 1221 VLOG(1) << "Blocked URL " << validated_params.url.spec();
1219 validated_params.url = GURL(kAboutBlankURL); 1222 validated_params.url = GURL(kAboutBlankURL);
1220 RecordAction(UserMetricsAction("CanCommitURL_BlockedAndKilled")); 1223 RecordAction(UserMetricsAction("CanCommitURL_BlockedAndKilled"));
1221 // Kills the process. 1224 // Kills the process.
1222 process->ReceivedBadMessage(); 1225 process->ReceivedBadMessage();
1223 } 1226 }
1224 1227
1228 // Now that something has committed, we don't need to track whether the
1229 // initial page has been accessed.
1230 has_accessed_initial_document_ = false;
1231
1225 ChildProcessSecurityPolicyImpl* policy = 1232 ChildProcessSecurityPolicyImpl* policy =
1226 ChildProcessSecurityPolicyImpl::GetInstance(); 1233 ChildProcessSecurityPolicyImpl::GetInstance();
1227 // Without this check, an evil renderer can trick the browser into creating 1234 // Without this check, an evil renderer can trick the browser into creating
1228 // a navigation entry for a banned URL. If the user clicks the back button 1235 // a navigation entry for a banned URL. If the user clicks the back button
1229 // followed by the forward button (or clicks reload, or round-trips through 1236 // followed by the forward button (or clicks reload, or round-trips through
1230 // session restore, etc), we'll think that the browser commanded the 1237 // session restore, etc), we'll think that the browser commanded the
1231 // renderer to load the URL and grant the renderer the privileges to request 1238 // renderer to load the URL and grant the renderer the privileges to request
1232 // the URL. To prevent this attack, we block the renderer from inserting 1239 // the URL. To prevent this attack, we block the renderer from inserting
1233 // banned URLs into the navigation controller in the first place. 1240 // banned URLs into the navigation controller in the first place.
1234 FilterURL(policy, process, false, &validated_params.url); 1241 FilterURL(policy, process, false, &validated_params.url);
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 2018
2012 void RenderViewHostImpl::OnCancelDesktopNotification(int notification_id) { 2019 void RenderViewHostImpl::OnCancelDesktopNotification(int notification_id) {
2013 GetContentClient()->browser()->CancelDesktopNotification( 2020 GetContentClient()->browser()->CancelDesktopNotification(
2014 GetProcess()->GetID(), GetRoutingID(), notification_id); 2021 GetProcess()->GetID(), GetRoutingID(), notification_id);
2015 } 2022 }
2016 2023
2017 void RenderViewHostImpl::OnRunFileChooser(const FileChooserParams& params) { 2024 void RenderViewHostImpl::OnRunFileChooser(const FileChooserParams& params) {
2018 delegate_->RunFileChooser(this, params); 2025 delegate_->RunFileChooser(this, params);
2019 } 2026 }
2020 2027
2028 void RenderViewHostImpl::OnDidAccessInitialDocument() {
2029 has_accessed_initial_document_ = true;
2030 delegate_->DidAccessInitialDocument();
2031 }
2032
2021 void RenderViewHostImpl::OnDomOperationResponse( 2033 void RenderViewHostImpl::OnDomOperationResponse(
2022 const std::string& json_string, int automation_id) { 2034 const std::string& json_string, int automation_id) {
2023 DomOperationNotificationDetails details(json_string, automation_id); 2035 DomOperationNotificationDetails details(json_string, automation_id);
2024 NotificationService::current()->Notify( 2036 NotificationService::current()->Notify(
2025 NOTIFICATION_DOM_OPERATION_RESPONSE, 2037 NOTIFICATION_DOM_OPERATION_RESPONSE,
2026 Source<RenderViewHost>(this), 2038 Source<RenderViewHost>(this),
2027 Details<DomOperationNotificationDetails>(&details)); 2039 Details<DomOperationNotificationDetails>(&details));
2028 } 2040 }
2029 2041
2030 void RenderViewHostImpl::OnGetWindowSnapshot(const int snapshot_id) { 2042 void RenderViewHostImpl::OnGetWindowSnapshot(const int snapshot_id) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); 2101 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
2090 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); 2102 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin();
2091 file != file_paths.end(); ++file) { 2103 file != file_paths.end(); ++file) {
2092 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) 2104 if (!policy->CanReadFile(GetProcess()->GetID(), *file))
2093 return false; 2105 return false;
2094 } 2106 }
2095 return true; 2107 return true;
2096 } 2108 }
2097 2109
2098 } // namespace content 2110 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698