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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 3174027: Clean up the way top level navigations are handled in ChromeFrame and reporte... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome_frame/test/navigation_test.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 enabled_bindings_(0), 444 enabled_bindings_(0),
445 send_preferred_size_changes_(false), 445 send_preferred_size_changes_(false),
446 script_can_close_(true), 446 script_can_close_(true),
447 is_loading_(false), 447 is_loading_(false),
448 navigation_gesture_(NavigationGestureUnknown), 448 navigation_gesture_(NavigationGestureUnknown),
449 opened_by_user_gesture_(true), 449 opened_by_user_gesture_(true),
450 opener_suppressed_(false), 450 opener_suppressed_(false),
451 page_id_(-1), 451 page_id_(-1),
452 last_page_id_sent_to_browser_(-1), 452 last_page_id_sent_to_browser_(-1),
453 last_indexed_page_id_(-1), 453 last_indexed_page_id_(-1),
454 last_top_level_navigation_page_id_(-1),
455 history_list_offset_(-1), 454 history_list_offset_(-1),
456 history_list_length_(0), 455 history_list_length_(0),
457 has_unload_listener_(false), 456 has_unload_listener_(false),
458 #if defined(OS_MACOSX) 457 #if defined(OS_MACOSX)
459 has_document_tag_(false), 458 has_document_tag_(false),
460 #endif 459 #endif
461 document_tag_(0), 460 document_tag_(0),
462 cross_origin_access_count_(0), 461 cross_origin_access_count_(0),
463 same_origin_access_count_(0), 462 same_origin_access_count_(0),
464 target_url_status_(TARGET_NONE), 463 target_url_status_(TARGET_NONE),
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after
2517 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { 2516 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) {
2518 // Webkit is asking whether to navigate to a new URL. 2517 // Webkit is asking whether to navigate to a new URL.
2519 // This is fine normally, except if we're showing UI from one security 2518 // This is fine normally, except if we're showing UI from one security
2520 // context and they're trying to navigate to a different context. 2519 // context and they're trying to navigate to a different context.
2521 const GURL& url = request.url(); 2520 const GURL& url = request.url();
2522 2521
2523 // If the browser is interested, then give it a chance to look at top level 2522 // If the browser is interested, then give it a chance to look at top level
2524 // navigations. 2523 // navigations.
2525 if (renderer_preferences_.browser_handles_top_level_requests && 2524 if (renderer_preferences_.browser_handles_top_level_requests &&
2526 IsNonLocalTopLevelNavigation(url, frame, type)) { 2525 IsNonLocalTopLevelNavigation(url, frame, type)) {
2527 last_top_level_navigation_page_id_ = page_id_;
2528 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); 2526 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer")));
2529 OpenURL(url, referrer, default_policy); 2527 OpenURL(url, referrer, default_policy);
2530 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2528 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2531 } 2529 }
2532 2530
2533 // A content initiated navigation may have originated from a link-click, 2531 // A content initiated navigation may have originated from a link-click,
2534 // script, drag-n-drop operation, etc. 2532 // script, drag-n-drop operation, etc.
2535 bool is_content_initiated = 2533 bool is_content_initiated =
2536 NavigationState::FromDataSource(frame->provisionalDataSource())-> 2534 NavigationState::FromDataSource(frame->provisionalDataSource())->
2537 is_content_initiated(); 2535 is_content_initiated();
(...skipping 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after
5491 } 5489 }
5492 5490
5493 bool RenderView::IsNonLocalTopLevelNavigation( 5491 bool RenderView::IsNonLocalTopLevelNavigation(
5494 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { 5492 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) {
5495 // Must be a top level frame. 5493 // Must be a top level frame.
5496 if (frame->parent() != NULL) 5494 if (frame->parent() != NULL)
5497 return false; 5495 return false;
5498 5496
5499 // Navigations initiated within Webkit are not sent out to the external host 5497 // Navigations initiated within Webkit are not sent out to the external host
5500 // in the following cases. 5498 // in the following cases.
5501 // 1. The url scheme or the frame url scheme is not http/https 5499 // 1. The url scheme is not http/https
5502 // 2. The origin of the url and the frame is the same in which case the 5500 // 2. There is no opener and this is not the first url being opened by this
5501 // RenderView.
5502 // 3. The origin of the url and the opener is the same in which case the
5503 // opener relationship is maintained. 5503 // opener relationship is maintained.
5504 // 3. Anchor navigation within the same page.
5505 // 4. Reloads/form submits/back forward navigations 5504 // 4. Reloads/form submits/back forward navigations
5506 if (!url.SchemeIs("http") && !url.SchemeIs("https")) 5505 if (!url.SchemeIs("http") && !url.SchemeIs("https"))
5507 return false; 5506 return false;
5508 5507
5509 GURL frame_url(frame->url());
5510 if (!frame_url.SchemeIs("http") && !frame_url.SchemeIs("https"))
5511 return false;
5512
5513 // Skip if navigation is on the same page (using '#').
5514 GURL frame_origin = frame_url.GetOrigin();
5515 if (url.GetOrigin() != frame_origin || url.ref().empty()) {
5516 // The link click could stay on the same page, in cases where it sends some
5517 // parameters to the same URL.
5518 if (type == WebKit::WebNavigationTypeLinkClicked)
5519 return true;
5520
5521 if (last_top_level_navigation_page_id_ != page_id_ &&
5522 // Not interested in reloads.
5523 type != WebKit::WebNavigationTypeReload &&
5524 type != WebKit::WebNavigationTypeFormSubmitted &&
5525 type != WebKit::WebNavigationTypeBackForward) {
5526 return true;
5527 }
5528 }
5529 // Not interested in reloads. 5508 // Not interested in reloads.
5530 if (type != WebKit::WebNavigationTypeReload && 5509 if (type != WebKit::WebNavigationTypeReload &&
5531 type != WebKit::WebNavigationTypeFormSubmitted && 5510 type != WebKit::WebNavigationTypeFormSubmitted &&
5532 type != WebKit::WebNavigationTypeBackForward) { 5511 type != WebKit::WebNavigationTypeBackForward) {
5533 // The opener relationship between the new window and the parent allows the 5512 // The opener relationship between the new window and the parent allows the
5534 // new window to script the parent and vice versa. This is not allowed if 5513 // new window to script the parent and vice versa. This is not allowed if
5535 // the origins of the two domains are different. This can be treated as a 5514 // the origins of the two domains are different. This can be treated as a
5536 // top level navigation and routed back to the host. 5515 // top level navigation and routed back to the host.
5537 WebKit::WebFrame* opener = frame->opener(); 5516 WebKit::WebFrame* opener = frame->opener();
5538 if (opener) { 5517 if (!opener) {
5539 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) 5518 // If this is the first page being loaded by this RenderView instance then
5519 // it should stay here.
5520 if (page_id_ == -1) {
5521 return false;
5522 } else {
5540 return true; 5523 return true;
5524 }
5541 } 5525 }
5526
5527 if (url.GetOrigin() != GURL(opener->url()).GetOrigin())
5528 return true;
5542 } 5529 }
5543 return false; 5530 return false;
5544 } 5531 }
5545 5532
5546 void RenderView::OnOpenFileSystemRequestComplete( 5533 void RenderView::OnOpenFileSystemRequestComplete(
5547 int request_id, bool accepted, const string16& name, 5534 int request_id, bool accepted, const string16& name,
5548 const string16& root_path) { 5535 const string16& root_path) {
5549 PendingOpenFileSystem* request = pending_file_system_requests_.Lookup( 5536 PendingOpenFileSystem* request = pending_file_system_requests_.Lookup(
5550 request_id); 5537 request_id);
5551 DCHECK(request); 5538 DCHECK(request);
5552 if (accepted) 5539 if (accepted)
5553 request->callbacks->didOpenFileSystem(name, root_path); 5540 request->callbacks->didOpenFileSystem(name, root_path);
5554 else 5541 else
5555 request->callbacks->didFail(WebKit::WebFileErrorSecurity); 5542 request->callbacks->didFail(WebKit::WebFileErrorSecurity);
5556 request->callbacks = NULL; 5543 request->callbacks = NULL;
5557 pending_file_system_requests_.Remove(request_id); 5544 pending_file_system_requests_.Remove(request_id);
5558 } 5545 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome_frame/test/navigation_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698