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

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 8443005: Don't reload into an app process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/tab_contents.h" 5 #include "content/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 FOR_EACH_OBSERVER(TabContentsObserver, observers_, 564 FOR_EACH_OBSERVER(TabContentsObserver, observers_,
565 DidOpenURL(params.url, params.referrer, 565 DidOpenURL(params.url, params.referrer,
566 params.disposition, params.transition)); 566 params.disposition, params.transition));
567 return new_contents; 567 return new_contents;
568 } 568 }
569 return NULL; 569 return NULL;
570 } 570 }
571 571
572 bool TabContents::NavigateToPendingEntry( 572 bool TabContents::NavigateToPendingEntry(
573 NavigationController::ReloadType reload_type) { 573 NavigationController::ReloadType reload_type) {
574 return NavigateToEntry(controller_.pending_entry(), reload_type); 574 return NavigateToEntry(*controller_.pending_entry(), reload_type);
575 } 575 }
576 576
577 bool TabContents::NavigateToEntry( 577 bool TabContents::NavigateToEntry(
578 NavigationEntry* entry, 578 const NavigationEntry& entry,
Charlie Reis 2011/11/03 20:47:58 These changes will be redundant with the revert.
579 NavigationController::ReloadType reload_type) { 579 NavigationController::ReloadType reload_type) {
580 // The renderer will reject IPC messages with URLs longer than 580 // The renderer will reject IPC messages with URLs longer than
581 // this limit, so don't attempt to navigate with a longer URL. 581 // this limit, so don't attempt to navigate with a longer URL.
582 if (entry->url().spec().size() > content::kMaxURLChars) 582 if (entry.url().spec().size() > content::kMaxURLChars)
583 return false; 583 return false;
584 584
585 RenderViewHost* dest_render_view_host = render_manager_.Navigate(*entry); 585 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry);
586 if (!dest_render_view_host) 586 if (!dest_render_view_host)
587 return false; // Unable to create the desired render view host. 587 return false; // Unable to create the desired render view host.
588 588
589 // If we were forced to swap the entry's existing SiteInstance, we need to
590 // update it before the navigation begins so that we can find it when the
591 // navigation commits.
592 if (entry->site_instance() &&
593 entry->site_instance() != dest_render_view_host->site_instance())
594 entry->set_site_instance(dest_render_view_host->site_instance());
595
596 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 589 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
597 // Double check that here. 590 // Double check that here.
598 int enabled_bindings = dest_render_view_host->enabled_bindings(); 591 int enabled_bindings = dest_render_view_host->enabled_bindings();
599 bool is_allowed_in_web_ui_renderer = content::GetContentClient()-> 592 bool is_allowed_in_web_ui_renderer = content::GetContentClient()->
600 browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(browser_context(), 593 browser()->GetWebUIFactory()->IsURLAcceptableForWebUI(browser_context(),
601 entry->url()); 594 entry.url());
602 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) || 595 CHECK(!(enabled_bindings & content::BINDINGS_POLICY_WEB_UI) ||
603 is_allowed_in_web_ui_renderer); 596 is_allowed_in_web_ui_renderer);
604 597
605 // Tell DevTools agent that it is attached prior to the navigation. 598 // Tell DevTools agent that it is attached prior to the navigation.
606 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); 599 DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
607 if (devtools_manager) { // NULL in unit tests. 600 if (devtools_manager) { // NULL in unit tests.
608 devtools_manager->OnNavigatingToPendingEntry(render_view_host(), 601 devtools_manager->OnNavigatingToPendingEntry(render_view_host(),
609 dest_render_view_host, 602 dest_render_view_host,
610 entry->url()); 603 entry.url());
611 } 604 }
612 605
613 // Used for page load time metrics. 606 // Used for page load time metrics.
614 current_load_start_ = base::TimeTicks::Now(); 607 current_load_start_ = base::TimeTicks::Now();
615 608
616 // Navigate in the desired RenderViewHost. 609 // Navigate in the desired RenderViewHost.
617 ViewMsg_Navigate_Params navigate_params; 610 ViewMsg_Navigate_Params navigate_params;
618 MakeNavigateParams(*entry, controller_, delegate_, reload_type, 611 MakeNavigateParams(entry, controller_, delegate_, reload_type,
619 &navigate_params); 612 &navigate_params);
620 dest_render_view_host->Navigate(navigate_params); 613 dest_render_view_host->Navigate(navigate_params);
621 614
622 if (entry->page_id() == -1) { 615 if (entry.page_id() == -1) {
623 // HACK!! This code suppresses javascript: URLs from being added to 616 // HACK!! This code suppresses javascript: URLs from being added to
624 // session history, which is what we want to do for javascript: URLs that 617 // session history, which is what we want to do for javascript: URLs that
625 // do not generate content. What we really need is a message from the 618 // do not generate content. What we really need is a message from the
626 // renderer telling us that a new page was not created. The same message 619 // renderer telling us that a new page was not created. The same message
627 // could be used for mailto: URLs and the like. 620 // could be used for mailto: URLs and the like.
628 if (entry->url().SchemeIs(chrome::kJavaScriptScheme)) 621 if (entry.url().SchemeIs(chrome::kJavaScriptScheme))
629 return false; 622 return false;
630 } 623 }
631 624
632 // Notify observers about navigation. 625 // Notify observers about navigation.
633 FOR_EACH_OBSERVER(TabContentsObserver, 626 FOR_EACH_OBSERVER(TabContentsObserver,
634 observers_, 627 observers_,
635 NavigateToPendingEntry(entry->url(), reload_type)); 628 NavigateToPendingEntry(entry.url(), reload_type));
636 629
637 if (delegate_) 630 if (delegate_)
638 delegate_->DidNavigateToPendingEntry(this); 631 delegate_->DidNavigateToPendingEntry(this);
639 632
640 return true; 633 return true;
641 } 634 }
642 635
643 void TabContents::SetHistoryLengthAndPrune(const SiteInstance* site_instance, 636 void TabContents::SetHistoryLengthAndPrune(const SiteInstance* site_instance,
644 int history_length, 637 int history_length,
645 int32 minimum_page_id) { 638 int32 minimum_page_id) {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 NavigationEntry* entry = controller_.GetEntryAtOffset(offset); 1083 NavigationEntry* entry = controller_.GetEntryAtOffset(offset);
1091 if (!entry) 1084 if (!entry)
1092 return; 1085 return;
1093 // Note that we don't call NavigationController::GotToOffset() as we don't 1086 // Note that we don't call NavigationController::GotToOffset() as we don't
1094 // want to create a pending navigation entry (it might end up lingering 1087 // want to create a pending navigation entry (it might end up lingering
1095 // http://crbug.com/51680). 1088 // http://crbug.com/51680).
1096 entry->set_transition_type( 1089 entry->set_transition_type(
1097 content::PageTransitionFromInt( 1090 content::PageTransitionFromInt(
1098 entry->transition_type() | 1091 entry->transition_type() |
1099 content::PAGE_TRANSITION_FORWARD_BACK)); 1092 content::PAGE_TRANSITION_FORWARD_BACK));
1100 NavigateToEntry(entry, NavigationController::NO_RELOAD); 1093 NavigateToEntry(*entry, NavigationController::NO_RELOAD);
1101 1094
1102 // If the entry is being restored and doesn't have a SiteInstance yet, fill 1095 // If the entry is being restored and doesn't have a SiteInstance yet, fill
1103 // it in now that we know. This allows us to find the entry when it commits. 1096 // it in now that we know. This allows us to find the entry when it commits.
1104 if (!entry->site_instance() && 1097 if (!entry->site_instance() &&
1105 entry->restore_type() != NavigationEntry::RESTORE_NONE) { 1098 entry->restore_type() != NavigationEntry::RESTORE_NONE) {
1106 entry->set_site_instance(GetPendingSiteInstance()); 1099 entry->set_site_instance(GetPendingSiteInstance());
1107 } 1100 }
1108 } 1101 }
1109 } 1102 }
1110 1103
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 2001
2009 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2002 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2010 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 2003 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
2011 rwh_view->SetSize(view()->GetContainerSize()); 2004 rwh_view->SetSize(view()->GetContainerSize());
2012 } 2005 }
2013 2006
2014 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { 2007 bool TabContents::GotResponseToLockMouseRequest(bool allowed) {
2015 return render_view_host() ? 2008 return render_view_host() ?
2016 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; 2009 render_view_host()->GotResponseToLockMouseRequest(allowed) : false;
2017 } 2010 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698