OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 // Without this check, an evil renderer can trick the browser into creating | 1230 // Without this check, an evil renderer can trick the browser into creating |
1231 // a navigation entry for a banned URL. If the user clicks the back button | 1231 // a navigation entry for a banned URL. If the user clicks the back button |
1232 // followed by the forward button (or clicks reload, or round-trips through | 1232 // followed by the forward button (or clicks reload, or round-trips through |
1233 // session restore, etc), we'll think that the browser commanded the | 1233 // session restore, etc), we'll think that the browser commanded the |
1234 // renderer to load the URL and grant the renderer the privileges to request | 1234 // renderer to load the URL and grant the renderer the privileges to request |
1235 // the URL. To prevent this attack, we block the renderer from inserting | 1235 // the URL. To prevent this attack, we block the renderer from inserting |
1236 // banned URLs into the navigation controller in the first place. | 1236 // banned URLs into the navigation controller in the first place. |
1237 process->FilterURL(false, &validated_params.url); | 1237 process->FilterURL(false, &validated_params.url); |
1238 process->FilterURL(true, &validated_params.referrer.url); | 1238 process->FilterURL(true, &validated_params.referrer.url); |
1239 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); | 1239 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); |
1240 it != validated_params.redirects.end(); ++it) { | 1240 it != validated_params.redirects.end(); ++it) { |
1241 process->FilterURL(false, &(*it)); | 1241 process->FilterURL(false, &(*it)); |
1242 } | 1242 } |
1243 process->FilterURL(true, &validated_params.searchable_form_url); | 1243 process->FilterURL(true, &validated_params.searchable_form_url); |
1244 | 1244 |
1245 // Without this check, the renderer can trick the browser into using | 1245 // Without this check, the renderer can trick the browser into using |
1246 // filenames it can't access in a future session restore. | 1246 // filenames it can't access in a future session restore. |
1247 if (!CanAccessFilesOfPageState(validated_params.page_state)) { | 1247 if (!CanAccessFilesOfPageState(validated_params.page_state)) { |
1248 bad_message::ReceivedBadMessage( | 1248 bad_message::ReceivedBadMessage( |
1249 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); | 1249 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); |
1250 return; | 1250 return; |
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3281 NavigationEntryImpl* pending_entry = | 3281 NavigationEntryImpl* pending_entry = |
3282 NavigationEntryImpl::FromNavigationEntry( | 3282 NavigationEntryImpl::FromNavigationEntry( |
3283 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3283 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
3284 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { | 3284 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { |
3285 pending_nav_entry_id = params.nav_entry_id; | 3285 pending_nav_entry_id = params.nav_entry_id; |
3286 is_renderer_initiated = pending_entry->is_renderer_initiated(); | 3286 is_renderer_initiated = pending_entry->is_renderer_initiated(); |
3287 } | 3287 } |
3288 | 3288 |
3289 return NavigationHandleImpl::Create( | 3289 return NavigationHandleImpl::Create( |
3290 params.url, frame_tree_node_, is_renderer_initiated, | 3290 params.url, frame_tree_node_, is_renderer_initiated, |
3291 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), | 3291 params.was_within_same_page, base::TimeTicks::Now(), |
3292 pending_nav_entry_id, false); // started_from_context_menu | 3292 pending_nav_entry_id, false); // started_from_context_menu |
3293 } | 3293 } |
3294 | 3294 |
3295 // Determine if the current NavigationHandle can be used. | 3295 // Determine if the current NavigationHandle can be used. |
3296 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { | 3296 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { |
3297 return std::move(navigation_handle_); | 3297 return std::move(navigation_handle_); |
3298 } | 3298 } |
3299 | 3299 |
3300 // If the URL does not match what the NavigationHandle expects, treat the | 3300 // If the URL does not match what the NavigationHandle expects, treat the |
3301 // commit as a new navigation. This can happen when loading a Data | 3301 // commit as a new navigation. This can happen when loading a Data |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3333 | 3333 |
3334 // Reset any existing NavigationHandle. | 3334 // Reset any existing NavigationHandle. |
3335 navigation_handle_.reset(); | 3335 navigation_handle_.reset(); |
3336 } | 3336 } |
3337 | 3337 |
3338 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3338 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3339 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3339 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3340 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3340 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3341 return NavigationHandleImpl::Create( | 3341 return NavigationHandleImpl::Create( |
3342 params.url, frame_tree_node_, is_renderer_initiated, | 3342 params.url, frame_tree_node_, is_renderer_initiated, |
3343 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), | 3343 params.was_within_same_page, base::TimeTicks::Now(), |
3344 entry_id_for_data_nav, false); // started_from_context_menu | 3344 entry_id_for_data_nav, false); // started_from_context_menu |
3345 } | 3345 } |
3346 | 3346 |
3347 } // namespace content | 3347 } // namespace content |
OLD | NEW |