diff options
67 files changed, 271 insertions, 179 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index d567a53..7b9214c 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -826,7 +826,7 @@ void AutomationProvider::AppendTab(const IPC::Message& message, Browser* browser = browser_tracker_->GetResource(handle); observer = AddTabStripObserver(browser, message.routing_id()); TabContents* tab_contents = - browser->AddTabWithURL(url, PageTransition::TYPED, true, NULL); + browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, NULL); if (tab_contents) { append_tab_response = GetIndexForNavigationController(tab_contents->controller(), browser); @@ -866,7 +866,7 @@ void AutomationProvider::NavigateToURL(const IPC::Message& message, new AutomationMsg_NavigateToURLResponse( message.routing_id(), AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED)); // TODO(darin): avoid conversion to GURL - browser->OpenURL(url, CURRENT_TAB, PageTransition::TYPED); + browser->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); return; } } @@ -888,7 +888,7 @@ void AutomationProvider::NavigationAsync(const IPC::Message& message, if (browser) { // Don't add any listener unless a callback mechanism is desired. // TODO(vibhor): Do this if such a requirement arises in future. - browser->OpenURL(url, CURRENT_TAB, PageTransition::TYPED); + browser->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); status = true; } } @@ -2004,7 +2004,7 @@ void AutomationProvider::NavigateInExternalTab(const IPC::Message& message, if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - tab->LoadURL(url, PageTransition::TYPED); + tab->LoadURL(url, GURL(), PageTransition::TYPED); status = true; } diff --git a/chrome/browser/back_forward_menu_model_unittest.cc b/chrome/browser/back_forward_menu_model_unittest.cc index f91081d..a1d9e47 100644 --- a/chrome/browser/back_forward_menu_model_unittest.cc +++ b/chrome/browser/back_forward_menu_model_unittest.cc @@ -105,7 +105,7 @@ class BackFwdMenuModelTest : public testing::Test { void LoadURLAndUpdateState(TabContents* contents, const std::wstring& url, const std::wstring& title) { - contents->controller()->LoadURL(GURL(url), PageTransition::LINK); + contents->controller()->LoadURL(GURL(url), GURL(), PageTransition::LINK); BackFwdMenuModelTestTabContents* rsmttc = static_cast<BackFwdMenuModelTestTabContents*>(contents); rsmttc->UpdateState(title); diff --git a/chrome/browser/bookmark_bar_context_menu_controller.cc b/chrome/browser/bookmark_bar_context_menu_controller.cc index 458a5b6..975a4ec 100644 --- a/chrome/browser/bookmark_bar_context_menu_controller.cc +++ b/chrome/browser/bookmark_bar_context_menu_controller.cc @@ -53,7 +53,7 @@ void OpenAllImpl(BookmarkNode* node, disposition = NEW_BACKGROUND_TAB; else disposition = initial_disposition; - (*navigator)->OpenURL(node->GetURL(), disposition, + (*navigator)->OpenURL(node->GetURL(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); if (!*opened_url) { *opened_url = true; @@ -284,7 +284,8 @@ void BookmarkBarContextMenuController::ExecuteCommand(int id) { UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInIncognito", profile); - view_->GetPageNavigator()->OpenURL(node_->GetURL(), OFF_THE_RECORD, + view_->GetPageNavigator()->OpenURL(node_->GetURL(), GURL(), + OFF_THE_RECORD, PageTransition::AUTO_BOOKMARK); break; @@ -292,7 +293,7 @@ void BookmarkBarContextMenuController::ExecuteCommand(int id) { UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInNewWindow", profile); - view_->GetPageNavigator()->OpenURL(node_->GetURL(), NEW_WINDOW, + view_->GetPageNavigator()->OpenURL(node_->GetURL(), GURL(), NEW_WINDOW, PageTransition::AUTO_BOOKMARK); break; @@ -300,7 +301,8 @@ void BookmarkBarContextMenuController::ExecuteCommand(int id) { UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInNewTab", profile); - view_->GetPageNavigator()->OpenURL(node_->GetURL(), NEW_FOREGROUND_TAB, + view_->GetPageNavigator()->OpenURL(node_->GetURL(), GURL(), + NEW_FOREGROUND_TAB, PageTransition::AUTO_BOOKMARK); break; diff --git a/chrome/browser/bookmark_bar_context_menu_controller_test.cc b/chrome/browser/bookmark_bar_context_menu_controller_test.cc index 01d4613..58e59e3 100644 --- a/chrome/browser/bookmark_bar_context_menu_controller_test.cc +++ b/chrome/browser/bookmark_bar_context_menu_controller_test.cc @@ -19,7 +19,7 @@ namespace { // PageNavigator implementation that records the URL. class TestingPageNavigator : public PageNavigator { public: - virtual void OpenURL(const GURL& url, + virtual void OpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { urls_.push_back(url); diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 1ac1fb7..e1fab37 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -524,7 +524,7 @@ void Browser::ProcessPendingUIUpdates() { // TabContentsDelegate void Browser::OpenURLFromTab(TabContents* source, - const GURL& url, + const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { // No code for these yet @@ -573,7 +573,7 @@ void Browser::OpenURLFromTab(TabContents* source, if (b->tab_count() == 0 && disposition == NEW_BACKGROUND_TAB) disposition = NEW_FOREGROUND_TAB; - b->OpenURL(url, disposition, transition); + b->OpenURL(url, referrer, disposition, transition); b->Show(); b->MoveToFront(true); return; @@ -585,7 +585,8 @@ void Browser::OpenURLFromTab(TabContents* source, if (disposition == NEW_WINDOW) { Browser* new_browser = new Browser(gfx::Rect(), SW_SHOWNORMAL, profile_, BrowserType::TABBED_BROWSER, L""); - new_contents = new_browser->AddTabWithURL(url, transition, true, instance); + new_contents = new_browser->AddTabWithURL(url, referrer, transition, true, + instance); new_browser->Show(); } else if ((disposition == CURRENT_TAB) && current_tab) { if (transition == PageTransition::TYPED || @@ -617,7 +618,7 @@ void Browser::OpenURLFromTab(TabContents* source, tabstrip_model_.ForgetGroup(current_tab); } } - current_tab->controller()->LoadURL(url, transition); + current_tab->controller()->LoadURL(url, referrer, transition); // The TabContents might have changed as part of the navigation (ex: new tab // page can become WebContents). new_contents = current_tab->controller()->active_contents(); @@ -632,8 +633,8 @@ void Browser::OpenURLFromTab(TabContents* source, return; } else if (disposition != SUPPRESS_OPEN) { new_contents = - AddTabWithURL(url, transition, disposition != NEW_BACKGROUND_TAB, - instance); + AddTabWithURL(url, referrer, transition, + disposition != NEW_BACKGROUND_TAB, instance); } if (disposition != NEW_BACKGROUND_TAB && source_tab_was_frontmost) { @@ -1210,8 +1211,8 @@ void Browser::OnWindowClosing() { // Tab Creation Functions TabContents* Browser::AddTabWithURL( - const GURL& url, PageTransition::Type transition, bool foreground, - SiteInstance* instance) { + const GURL& url, const GURL& referrer, PageTransition::Type transition, + bool foreground, SiteInstance* instance) { if (type_ == BrowserType::APPLICATION && tabstrip_model_.count() == 1) { NOTREACHED() << "Cannot add a tab in a mono tab application."; return NULL; @@ -1221,8 +1222,8 @@ TabContents* Browser::AddTabWithURL( if (url_to_load.is_empty()) url_to_load = GetHomePage(); TabContents* contents = - CreateTabContentsForURL(url_to_load, profile_, transition, false, - instance); + CreateTabContentsForURL(url_to_load, referrer, profile_, transition, + false, instance); tabstrip_model_.AddTabContents(contents, -1, transition, foreground); // By default, content believes it is not hidden. When adding contents // in the background, tell it that it's hidden. @@ -1239,14 +1240,14 @@ TabContents* Browser::AddWebApplicationTab(Profile* profile, // TODO(acw): Do we need an "application launched" transition type? // TODO(creis): Should we reuse the current instance (ie. process) here? TabContents* contents = - CreateTabContentsForURL(web_app->url(), profile, PageTransition::LINK, - lazy, NULL); + CreateTabContentsForURL(web_app->url(), GURL(), profile, + PageTransition::LINK, lazy, NULL); if (contents->AsWebContents()) contents->AsWebContents()->SetWebApp(web_app); if (lazy) { contents->controller()->LoadURLLazily( - web_app->url(), PageTransition::LINK, web_app->name(), NULL); + web_app->url(), GURL(), PageTransition::LINK, web_app->name(), NULL); } tabstrip_model_.AddTabContents(contents, -1, PageTransition::LINK, !lazy); return contents; @@ -1333,8 +1334,9 @@ int Browser::GetDragActions() const { } TabContents* Browser::CreateTabContentsForURL( - const GURL& url, Profile* profile, PageTransition::Type transition, - bool defer_load, SiteInstance* instance) const { + const GURL& url, const GURL& referrer, Profile* profile, + PageTransition::Type transition, bool defer_load, + SiteInstance* instance) const { // Create an appropriate tab contents. GURL real_url = url; TabContentsType type = TabContents::TypeForURL(&real_url); @@ -1347,7 +1349,7 @@ TabContents* Browser::CreateTabContentsForURL( if (!defer_load) { // Load the initial URL before adding the new tab contents to the tab strip // so that the tab contents has navigation state. - contents->controller()->LoadURL(url, transition); + contents->controller()->LoadURL(url, referrer, transition); } return contents; @@ -1615,7 +1617,7 @@ void Browser::ShowNativeUI(const GURL& url) { } } - TabContents* contents = CreateTabContentsForURL(url, profile_, + TabContents* contents = CreateTabContentsForURL(url, GURL(), profile_, PageTransition::LINK, false, NULL); AddNewContents(NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), true); @@ -1639,7 +1641,7 @@ NavigationController* Browser::BuildRestoredNavigationController( } else { // No navigations. Create a tab with about:blank. TabContents* contents = - CreateTabContentsForURL(GURL("about:blank"), profile_, + CreateTabContentsForURL(GURL("about:blank"), GURL(), profile_, PageTransition::START_PAGE, false, NULL); return new NavigationController(contents, profile_); } @@ -1654,7 +1656,8 @@ void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) { browser = new Browser(gfx::Rect(), SW_SHOWNORMAL, off_the_record_profile, BrowserType::TABBED_BROWSER, L""); } - browser->AddTabWithURL(url, PageTransition::LINK, true, NULL); + // TODO(eroman): should we have referrer here? + browser->AddTabWithURL(url, GURL(), PageTransition::LINK, true, NULL); browser->Show(); browser->MoveToFront(true); } diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index e896b18..b63f540 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -193,7 +193,8 @@ class Browser : public TabStripModelDelegate, // Add a new tab with the specified URL. If instance is not null, its process // will be used to render the tab. TabContents* AddTabWithURL( - const GURL& url, PageTransition::Type transition, bool foreground, + const GURL& url, const GURL& referrer, + PageTransition::Type transition, bool foreground, SiteInstance* instance); // Add a new application tab for the specified URL. If lazy is true, the tab @@ -230,6 +231,7 @@ class Browser : public TabStripModelDelegate, // If instance is not null, its process will be used to render the tab. virtual TabContents* CreateTabContentsForURL( const GURL& url, + const GURL& referrer, Profile* profile, PageTransition::Type transition, bool defer_load, @@ -257,7 +259,7 @@ class Browser : public TabStripModelDelegate, // Overridden from TabContentsDelegate: virtual void OpenURLFromTab(TabContents* source, - const GURL& url, + const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, diff --git a/chrome/browser/browser_commands.cc b/chrome/browser/browser_commands.cc index 1945c8e..0f01548 100644 --- a/chrome/browser/browser_commands.cc +++ b/chrome/browser/browser_commands.cc @@ -358,10 +358,10 @@ void Browser::ExecuteCommand(int id) { { LocationBarView* lbv = GetLocationBarView(); if (lbv) { - OpenURL(GURL(lbv->location_input()), lbv->disposition(), + OpenURL(GURL(lbv->location_input()), GURL(), lbv->disposition(), lbv->transition()); } else { - OpenURL(GURL(), CURRENT_TAB, PageTransition::TYPED); + OpenURL(GURL(), GURL(), CURRENT_TAB, PageTransition::TYPED); } } break; @@ -447,7 +447,7 @@ void Browser::ExecuteCommand(int id) { current_tab->controller()->GetLastCommittedEntry(); if (entry) { GURL url("view-source:" + entry->url().spec()); - AddTabWithURL(url, PageTransition::LINK, true, NULL); + AddTabWithURL(url, GURL(), PageTransition::LINK, true, NULL); } break; } @@ -714,7 +714,8 @@ void Browser::ExecuteCommand(int id) { case IDC_HELPMENU: { GURL help_url(l10n_util::GetString(IDS_HELP_CONTENT_URL)); - AddTabWithURL(help_url, PageTransition::AUTO_BOOKMARK, true, NULL); + AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, true, + NULL); break; } @@ -765,7 +766,7 @@ void Browser::Reload() { if (web_contents && web_contents->showing_interstitial_page()) { NavigationEntry* entry = current_tab->controller()->GetActiveEntry(); DCHECK(entry); // Should exist if interstitial is showing. - OpenURL(entry->url(), CURRENT_TAB, PageTransition::RELOAD); + OpenURL(entry->url(), GURL(), CURRENT_TAB, PageTransition::RELOAD); return; } } @@ -780,7 +781,7 @@ void Browser::Reload() { void Browser::Home() { GURL homepage_url = GetHomePage(); GetSelectedTabContents()->controller()->LoadURL( - homepage_url, PageTransition::AUTO_BOOKMARK); + homepage_url, GURL(), PageTransition::AUTO_BOOKMARK); } void Browser::StarCurrentTabContents() { @@ -1047,6 +1048,6 @@ void Browser::DuplicateContentsAt(int index) { void Browser::FileSelected(const std::wstring& path, void* params) { GURL file_url = net::FilePathToFileURL(path); if (!file_url.is_empty()) - OpenURL(file_url, CURRENT_TAB, PageTransition::TYPED); + OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); } diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index 848688a..24918f6 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -542,7 +542,7 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser( for (size_t i = 0; i < urls.size(); ++i) { TabContents* tab = browser->AddTabWithURL( - urls[i], PageTransition::START_PAGE, (i == 0), NULL); + urls[i], GURL(), PageTransition::START_PAGE, (i == 0), NULL); if (i == 0 && process_startup) AddCrashedInfoBarIfNecessary(tab); } diff --git a/chrome/browser/constrained_window.h b/chrome/browser/constrained_window.h index 3244462..04c0af9 100644 --- a/chrome/browser/constrained_window.h +++ b/chrome/browser/constrained_window.h @@ -41,6 +41,7 @@ class ConstrainedTabContentsDelegate { // Called to open a URL in a the specified manner. virtual void OpenURL(ConstrainedWindow* window, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) = 0; diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc index 9cbe4f4..89cb4e8 100644 --- a/chrome/browser/debugger/debugger_view.cc +++ b/chrome/browser/debugger/debugger_view.cc @@ -101,7 +101,8 @@ void DebuggerView::OnInit() { web_contents_->render_view_host()->AllowDOMUIBindings(); GURL contents("chrome-resource://debugger/"); - web_contents_->controller()->LoadURL(contents, PageTransition::START_PAGE); + web_contents_->controller()->LoadURL(contents, GURL(), + PageTransition::START_PAGE); } void DebuggerView::OnShow() { @@ -123,9 +124,11 @@ void DebuggerView::SetDebuggerBreak(bool is_broken) { void DebuggerView::OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { - BrowserList::GetLastActive()->OpenURL(url, disposition, transition); + BrowserList::GetLastActive()->OpenURL(url, referrer, disposition, + transition); } void DebuggerView::ExecuteJavascript(const std::string& js) { diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h index e9e18e9..5a7f775 100644 --- a/chrome/browser/debugger/debugger_view.h +++ b/chrome/browser/debugger/debugger_view.h @@ -57,6 +57,7 @@ class DebuggerView : public views::View, // Overridden from PageNavigator (TabContentsDelegate's base interface): virtual void OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition); diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 441d8ea..ff3e997e 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -459,7 +459,7 @@ void TemplateURLHandler::HandleDoSearch(const Value* content) { // Load the URL. if (!url.empty()) { - dom_ui_host_->OpenURL(GURL(WideToUTF8(url)), CURRENT_TAB, + dom_ui_host_->OpenURL(GURL(WideToUTF8(url)), GURL(), CURRENT_TAB, PageTransition::LINK); } } @@ -673,7 +673,7 @@ HistoryHandler::HistoryHandler(DOMUIHost* dom_ui_host) void HistoryHandler::HandleShowHistoryPage(const Value*) { NavigationController* controller = dom_ui_host_->controller(); if (controller) - controller->LoadURL(HistoryTabUI::GetURL(), PageTransition::LINK); + controller->LoadURL(HistoryTabUI::GetURL(), GURL(), PageTransition::LINK); } void HistoryHandler::HandleSearchHistoryPage(const Value* content) { @@ -689,6 +689,7 @@ void HistoryHandler::HandleSearchHistoryPage(const Value* content) { NavigationController* controller = dom_ui_host_->controller(); controller->LoadURL( HistoryTabUI::GetHistoryURLWithSearchText(wstring_value), + GURL(), PageTransition::LINK); } } @@ -807,13 +808,14 @@ bool NewTabUIContents::SupportsURL(GURL* url) { } void NewTabUIContents::RequestOpenURL(const GURL& url, + const GURL& /*referrer*/, WindowOpenDisposition disposition) { // The user opened a URL on the page (including "open in new window"). // We count all such clicks as AUTO_BOOKMARK, which increments the site's // visit count (which is used for ranking the most visited entries). // Note this means we're including clicks on not only most visited thumbnails, // but also clicks on recently bookmarked. - OpenURL(url, disposition, PageTransition::AUTO_BOOKMARK); + OpenURL(url, GURL(), disposition, PageTransition::AUTO_BOOKMARK); // Figure out if this was a click on a MostVisited entry, and log it if so. if (most_visited_handler_) { diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h index 702f06e..9c18a60 100644 --- a/chrome/browser/dom_ui/new_tab_ui.h +++ b/chrome/browser/dom_ui/new_tab_ui.h @@ -300,7 +300,7 @@ class NewTabUIContents : public DOMUIHost { virtual bool ShouldDisplayURL() { return false; } virtual bool SupportsURL(GURL* url); // Clicking a URL on the page should count as an autobookmark click. - virtual void RequestOpenURL(const GURL& url, + virtual void RequestOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition); private: // The message id that should be displayed in this NewTabUIContents diff --git a/chrome/browser/download/download_request_manager_unittest.cc b/chrome/browser/download/download_request_manager_unittest.cc index 9293426..14ba6be 100644 --- a/chrome/browser/download/download_request_manager_unittest.cc +++ b/chrome/browser/download/download_request_manager_unittest.cc @@ -109,7 +109,7 @@ TEST_F(DownloadRequestManagerTest, Allow) { } TEST_F(DownloadRequestManagerTest, ResetOnNavigation) { - controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar"), 0); + controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar"), GURL(), 0); // Do two downloads, allowing the second so that we end up with allow all. CanDownload(); @@ -122,7 +122,8 @@ TEST_F(DownloadRequestManagerTest, ResetOnNavigation) { // Navigate to a new URL with the same host, which shouldn't reset the allow // all state. - controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar2"), 0); + controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar2"), + GURL(), 0); CanDownload(); ASSERT_EQ(1, continue_count_); ASSERT_EQ(0, cancel_count_); @@ -140,14 +141,14 @@ TEST_F(DownloadRequestManagerTest, ResetOnNavigation) { controller_->active_contents())); // Navigate to a completely different host, which should reset the state. - controller_->LoadURL(GURL(factory_->scheme() + "://fooey.com"), 0); + controller_->LoadURL(GURL(factory_->scheme() + "://fooey.com"), GURL(), 0); ASSERT_EQ(DownloadRequestManager::ALLOW_ONE_DOWNLOAD, download_request_manager_->GetDownloadStatus( controller_->active_contents())); } TEST_F(DownloadRequestManagerTest, ResetOnUserGesture) { - controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar"), 0); + controller_->LoadURL(GURL(factory_->scheme() + "://foo.com/bar"), GURL(), 0); // Do one download, which should change to prompt before download. CanDownload(); diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 599ce6a..c97d15d 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -135,6 +135,7 @@ LRESULT ExternalTabContainer::OnSize(UINT, WPARAM, LPARAM, BOOL& handled) { void ExternalTabContainer::OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { switch (disposition) { diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index 00a52e9..1f694a0 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -55,6 +55,7 @@ class ExternalTabContainer : public TabContentsDelegate, // Overridden from TabContentsDelegate: virtual void OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, diff --git a/chrome/browser/history_view.cc b/chrome/browser/history_view.cc index 266aa00..17a3e77 100644 --- a/chrome/browser/history_view.cc +++ b/chrome/browser/history_view.cc @@ -588,7 +588,7 @@ void HistoryItemRenderer::LinkActivated(views::Link* link, if (navigator && !url.is_empty()) { UserMetrics::RecordAction(L"Destination_History_OpenURL", model_->profile()); - navigator->OpenURL(url, + navigator->OpenURL(url, GURL(), event_utils::DispositionFromEventFlags(event_flags), PageTransition::AUTO_BOOKMARK); // WARNING: call to OpenURL likely deleted us. diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc index 2cf0572..1961e26d 100644 --- a/chrome/browser/native_ui_contents.cc +++ b/chrome/browser/native_ui_contents.cc @@ -96,7 +96,7 @@ class NativeRootView : public views::RootView { std::wstring title; if (!event.GetData().GetURLAndTitle(&url, &title) || !url.is_valid()) return DragDropTypes::DRAG_NONE; - host_->controller()->LoadURL(url, PageTransition::GENERATED); + host_->controller()->LoadURL(url, GURL(), PageTransition::GENERATED); return OnDragUpdated(event); } diff --git a/chrome/browser/navigation_controller.cc b/chrome/browser/navigation_controller.cc index c3b4304..d646bb1 100644 --- a/chrome/browser/navigation_controller.cc +++ b/chrome/browser/navigation_controller.cc @@ -146,10 +146,11 @@ static void CreateNavigationEntriesFromTabNavigations( NavigationEntry* entry = new NavigationEntry( type, - NULL, // The site instance for restored tabs is sent on naviagion + NULL, // The site instance for restored tabs is sent on naviagtion // (WebContents::GetSiteInstanceForEntry). static_cast<int>(i - navigations.begin()), real_url, + GURL(), // TODO(eroman): should pass actual referrer. navigation.title, // Use a transition type of reload so that we don't incorrectly // increase the typed count. @@ -408,7 +409,7 @@ void NavigationController::RemoveEntryAtIndex(int index, } else { // If there is nothing to show, show a default page. LoadURL(default_url.is_empty() ? GURL("about:blank") : default_url, - PageTransition::START_PAGE); + GURL(), PageTransition::START_PAGE); } } else if (last_committed_entry_index_ > index) { last_committed_entry_index_--; @@ -477,7 +478,7 @@ void NavigationController::TabContentsWasDestroyed(TabContentsType type) { } NavigationEntry* NavigationController::CreateNavigationEntry( - const GURL& url, PageTransition::Type transition) { + const GURL& url, const GURL& referrer, PageTransition::Type transition) { GURL real_url = url; TabContentsType type; @@ -490,6 +491,7 @@ NavigationEntry* NavigationController::CreateNavigationEntry( type = TabContents::TypeForURL(&real_url); NavigationEntry* entry = new NavigationEntry(type, NULL, -1, real_url, + referrer, std::wstring(), transition); entry->set_display_url(url); entry->set_user_typed_url(url); @@ -512,21 +514,22 @@ void NavigationController::AddTransientEntry(NavigationEntry* entry) { TabContents::INVALIDATE_EVERYTHING); } -void NavigationController::LoadURL(const GURL& url, +void NavigationController::LoadURL(const GURL& url, const GURL& referrer, PageTransition::Type transition) { // The user initiated a load, we don't need to reload anymore. needs_reload_ = false; - NavigationEntry* entry = CreateNavigationEntry(url, transition); + NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition); LoadEntry(entry); } void NavigationController::LoadURLLazily(const GURL& url, + const GURL& referrer, PageTransition::Type type, const std::wstring& title, SkBitmap* icon) { - NavigationEntry* entry = CreateNavigationEntry(url, type); + NavigationEntry* entry = CreateNavigationEntry(url, referrer, type); entry->set_title(title); if (icon) entry->favicon().set_bitmap(*icon); diff --git a/chrome/browser/navigation_controller.h b/chrome/browser/navigation_controller.h index cffee64..522c8b1 100644 --- a/chrome/browser/navigation_controller.h +++ b/chrome/browser/navigation_controller.h @@ -256,11 +256,13 @@ class NavigationController { // New navigations ----------------------------------------------------------- // Loads the specified URL. - void LoadURL(const GURL& url, PageTransition::Type type); + void LoadURL(const GURL& url, const GURL& referrer, + PageTransition::Type type); // Load the specified URL the next time it becomes active. - void LoadURLLazily(const GURL& url, PageTransition::Type type, - const std::wstring& title, SkBitmap* icon); + void LoadURLLazily(const GURL& url, const GURL& referrer, + PageTransition::Type type, const std::wstring& title, + SkBitmap* icon); // Loads the current page if this NavigationController was restored from // history and the current page has not loaded yet. @@ -445,7 +447,7 @@ class NavigationController { // was restored from a previous session. void set_max_restored_page_id(int max_id) { max_restored_page_id_ = max_id; } - NavigationEntry* CreateNavigationEntry(const GURL& url, + NavigationEntry* CreateNavigationEntry(const GURL& url, const GURL& referrer, PageTransition::Type transition); // Invokes ScheduleTabContentsCollection for all TabContents but the active diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index 5be123e..1c8002280 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -75,6 +75,7 @@ class NavigationControllerTest : public testing::Test, // TabContentsDelegate methods (only care about ReplaceContents): virtual void OpenURLFromTab(TabContents*, const GURL&, + const GURL&, WindowOpenDisposition, PageTransition::Type) {} virtual void NavigationStateChanged(const TabContents*, @@ -257,7 +258,7 @@ TEST_F(NavigationControllerTest, LoadURL) { const GURL url1(scheme1() + ":foo1"); const GURL url2(scheme1() + ":foo2"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); // Creating a pending notification should not have issued any of the // notifications we're listening for. EXPECT_EQ(0, notifications.size()); @@ -289,7 +290,7 @@ TEST_F(NavigationControllerTest, LoadURL) { EXPECT_EQ(contents->GetMaxPageID(), 0); // Load another... - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); // The load should now be pending. EXPECT_EQ(contents->controller()->GetEntryCount(), 1); @@ -326,12 +327,12 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) { const GURL url1(scheme1() + ":foo1"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); EXPECT_EQ(0, notifications.size()); contents->CompleteNavigationAsRenderer(0, url1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); EXPECT_EQ(0, notifications.size()); contents->CompleteNavigationAsRenderer(0, url1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); @@ -354,12 +355,12 @@ TEST_F(NavigationControllerTest, LoadURL_Discarded) { const GURL url1(scheme1() + ":foo1"); const GURL url2(scheme1() + ":foo2"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); EXPECT_EQ(0, notifications.size()); contents->CompleteNavigationAsRenderer(0, url1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); contents->controller()->DiscardNonCommittedEntries(); EXPECT_EQ(0, notifications.size()); @@ -381,7 +382,8 @@ TEST_F(NavigationControllerTest, LoadURL_NoPending) { // First make an existing committed entry. const GURL kExistingURL1(scheme1() + ":eh"); - contents->controller()->LoadURL(kExistingURL1, PageTransition::TYPED); + contents->controller()->LoadURL(kExistingURL1, GURL(), + PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, kExistingURL1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); @@ -407,13 +409,15 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) { // First make an existing committed entry. const GURL kExistingURL1(scheme1() + ":eh"); - contents->controller()->LoadURL(kExistingURL1, PageTransition::TYPED); + contents->controller()->LoadURL(kExistingURL1, GURL(), + PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, kExistingURL1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); // Make a pending entry to somewhere new. const GURL kExistingURL2(scheme1() + ":bee"); - contents->controller()->LoadURL(kExistingURL2, PageTransition::TYPED); + contents->controller()->LoadURL(kExistingURL2, GURL(), + PageTransition::TYPED); EXPECT_EQ(0, notifications.size()); // Before that commits, do a new navigation. @@ -437,12 +441,14 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) { // First make some history. const GURL kExistingURL1(scheme1() + ":eh"); - contents->controller()->LoadURL(kExistingURL1, PageTransition::TYPED); + contents->controller()->LoadURL(kExistingURL1, GURL(), + PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, kExistingURL1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); const GURL kExistingURL2(scheme1() + ":bee"); - contents->controller()->LoadURL(kExistingURL2, PageTransition::TYPED); + contents->controller()->LoadURL(kExistingURL2, GURL(), + PageTransition::TYPED); contents->CompleteNavigationAsRenderer(1, kExistingURL2); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); @@ -472,7 +478,7 @@ TEST_F(NavigationControllerTest, Reload) { const GURL url1(scheme1() + ":foo1"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); EXPECT_EQ(0, notifications.size()); contents->CompleteNavigationAsRenderer(0, url1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); @@ -510,7 +516,7 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) { const GURL url1(scheme1() + ":foo1"); const GURL url2(scheme1() + ":foo2"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, url1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); @@ -577,11 +583,11 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) { const GURL url2(scheme1() + ":foo2"); const GURL url3(scheme1() + ":foo3"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, url1); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(1, url2); EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); @@ -629,7 +635,7 @@ TEST_F(NavigationControllerTest, Back_NewPending) { EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); // Now start a new pending navigation and go back before it commits. - contents->controller()->LoadURL(kUrl3, PageTransition::TYPED); + contents->controller()->LoadURL(kUrl3, GURL(), PageTransition::TYPED); EXPECT_EQ(-1, contents->controller()->GetPendingEntryIndex()); EXPECT_EQ(kUrl3, contents->controller()->GetPendingEntry()->url()); contents->controller()->GoBack(); @@ -1015,7 +1021,7 @@ TEST_F(NavigationControllerTest, SwitchTypes) { EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); TestTabContents* initial_contents = contents; - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); // The tab contents should have been replaced ASSERT_TRUE(initial_contents != contents); @@ -1065,7 +1071,7 @@ TEST_F(NavigationControllerTest, SwitchTypes_Discard) { TestTabContents* initial_contents = contents; - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); EXPECT_EQ(0, notifications.size()); // The tab contents should have been replaced @@ -1099,11 +1105,11 @@ TEST_F(NavigationControllerTest, SwitchTypesCleanup) { // Note that we need the LoadURL calls so that pending entries and the // different tab contents types are created. "Renderer" navigations won't // actually cross tab contents boundaries without these. - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, url1); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(1, url2); - contents->controller()->LoadURL(url3, PageTransition::TYPED); + contents->controller()->LoadURL(url3, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(2, url3); // Navigate back to the start. @@ -1172,7 +1178,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { for (url_index = 0; url_index < kMaxEntryCount; url_index++) { SNPrintF(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(), url_index); GURL url(buffer); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(url_index, url); } @@ -1184,7 +1190,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { // Navigate some more. SNPrintF(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(), url_index); GURL url(buffer); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(url_index, url); url_index++; @@ -1202,7 +1208,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) { for (int i = 0; i < 3; i++) { SNPrintF(buffer, 128, (scheme1() + "://www.a.com/%d").c_str(), url_index); url = GURL(buffer); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(url_index, url); url_index++; } @@ -1266,12 +1272,12 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { TEST_F(NavigationControllerTest, Interstitial) { // First navigate somewhere normal. const GURL url1(scheme1() + ":foo"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, url1); // Now navigate somewhere with an interstitial. const GURL url2(scheme1() + ":bar"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); contents->controller()->GetPendingEntry()->set_page_type( NavigationEntry::INTERSTITIAL_PAGE); @@ -1294,15 +1300,15 @@ TEST_F(NavigationControllerTest, RemoveEntry) { const GURL pending_url(scheme1() + ":pending"); const GURL default_url(scheme1() + ":default"); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, url1); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(1, url2); - contents->controller()->LoadURL(url3, PageTransition::TYPED); + contents->controller()->LoadURL(url3, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(2, url3); - contents->controller()->LoadURL(url4, PageTransition::TYPED); + contents->controller()->LoadURL(url4, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(3, url4); - contents->controller()->LoadURL(url5, PageTransition::TYPED); + contents->controller()->LoadURL(url5, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(4, url5); // Remove the last entry. @@ -1314,7 +1320,7 @@ TEST_F(NavigationControllerTest, RemoveEntry) { EXPECT_TRUE(pending_entry && pending_entry->url() == url4); // Add a pending entry. - contents->controller()->LoadURL(pending_url, PageTransition::TYPED); + contents->controller()->LoadURL(pending_url, GURL(), PageTransition::TYPED); // Now remove the last entry. contents->controller()->RemoveEntryAtIndex( contents->controller()->GetEntryCount() - 1, default_url); @@ -1356,9 +1362,9 @@ TEST_F(NavigationControllerTest, TransientEntry) { const GURL url4(scheme1() + ":foo4"); const GURL transient_url(scheme1() + ":transient"); - contents->controller()->LoadURL(url0, PageTransition::TYPED); + contents->controller()->LoadURL(url0, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(0, url0); - contents->controller()->LoadURL(url1, PageTransition::TYPED); + contents->controller()->LoadURL(url1, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(1, url1); notifications.Reset(); @@ -1383,7 +1389,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { EXPECT_EQ(contents->GetMaxPageID(), 1); // Navigate. - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); contents->CompleteNavigationAsRenderer(2, url2); // We should have navigated, transient entry should be gone. @@ -1401,7 +1407,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { EXPECT_EQ(contents->controller()->GetEntryCount(), 4); // Initiate a navigation, add a transient then commit navigation. - contents->controller()->LoadURL(url4, PageTransition::TYPED); + contents->controller()->LoadURL(url4, GURL(), PageTransition::TYPED); transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); transient_entry->set_url(transient_url); contents->controller()->AddTransientEntry(transient_entry); @@ -1494,7 +1500,7 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) { // A basic test case. Navigates to a single url, and make sure the history // db matches. TEST_F(NavigationControllerHistoryTest, Basic) { - contents->controller()->LoadURL(url0, PageTransition::LINK); + contents->controller()->LoadURL(url0, GURL(), PageTransition::LINK); contents->CompleteNavigationAsRenderer(0, url0); GetLastSession(); diff --git a/chrome/browser/navigation_entry.cc b/chrome/browser/navigation_entry.cc index 8a24a3d..f7ed6c6 100644 --- a/chrome/browser/navigation_entry.cc +++ b/chrome/browser/navigation_entry.cc @@ -41,6 +41,7 @@ NavigationEntry::NavigationEntry(TabContentsType type, SiteInstance* instance, int page_id, const GURL& url, + const GURL& referrer, const std::wstring& title, PageTransition::Type transition_type) : unique_id_(GetUniqueID()), @@ -48,6 +49,7 @@ NavigationEntry::NavigationEntry(TabContentsType type, site_instance_(instance), page_type_(NORMAL_PAGE), url_(url), + referrer_(referrer), title_(title), page_id_(page_id), transition_type_(transition_type), diff --git a/chrome/browser/navigation_entry.h b/chrome/browser/navigation_entry.h index 1dcbe19..cce595c 100644 --- a/chrome/browser/navigation_entry.h +++ b/chrome/browser/navigation_entry.h @@ -167,6 +167,7 @@ class NavigationEntry { SiteInstance* instance, int page_id, const GURL& url, + const GURL& referrer, const std::wstring& title, PageTransition::Type transition_type); ~NavigationEntry() { @@ -225,6 +226,14 @@ class NavigationEntry { return url_; } + // The referring URL. Can be empty. + void set_referrer(const GURL& referrer) { + referrer_ = referrer; + } + const GURL& referrer() const { + return referrer_; + } + // The display URL, when nonempty, will override the actual URL of the page // when we display it to the user. This allows us to have nice and friendly // URLs that the user sees for things like about: URLs, but actually feed @@ -362,6 +371,11 @@ class NavigationEntry { scoped_refptr<SiteInstance> site_instance_; PageType page_type_; GURL url_; + + // TODO(eroman): Add referrer to session restore. + // http://code.google.com/p/chromium/issues/detail?id=3774 + GURL referrer_; + std::wstring url_as_string_; GURL display_url_; std::wstring title_; diff --git a/chrome/browser/page_navigator.h b/chrome/browser/page_navigator.h index 2e795fa..0152d39 100644 --- a/chrome/browser/page_navigator.h +++ b/chrome/browser/page_navigator.h @@ -18,7 +18,7 @@ class PageNavigator { public: // Opens a URL with the given disposition. The transition specifies how this // navigation should be recorded in the history system (for example, typed). - virtual void OpenURL(const GURL& url, + virtual void OpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) = 0; }; diff --git a/chrome/browser/profile_manager.cc b/chrome/browser/profile_manager.cc index 34ac0a6..99e09cf 100644 --- a/chrome/browser/profile_manager.cc +++ b/chrome/browser/profile_manager.cc @@ -126,7 +126,8 @@ void ProfileManager::NewWindowWithProfile(Profile* profile) { Browser* new_browser = new Browser(gfx::Rect(), SW_SHOWNORMAL, profile, BrowserType::TABBED_BROWSER, L""); - new_browser->AddTabWithURL(GURL(), PageTransition::TYPED, true, NULL); + new_browser->AddTabWithURL(GURL(), GURL(), PageTransition::TYPED, true, + NULL); new_browser->Show(); } diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc index 2cd6abb..c8dcaf3 100644 --- a/chrome/browser/render_view_context_menu_controller.cc +++ b/chrome/browser/render_view_context_menu_controller.cc @@ -47,7 +47,7 @@ void RenderViewContextMenuController::OpenURL( const GURL& url, WindowOpenDisposition disposition, PageTransition::Type transition) { - source_web_contents_->OpenURL(url, disposition, transition); + source_web_contents_->OpenURL(url, GURL(), disposition, transition); } void RenderViewContextMenuController::CopyImageAt(int x, int y) { diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc index 3474aa3..389b6f3 100644 --- a/chrome/browser/render_view_host.cc +++ b/chrome/browser/render_view_host.cc @@ -553,6 +553,7 @@ void RenderViewHost::MakeNavigateParams(const NavigationEntry& entry, ViewMsg_Navigate_Params* params) { params->page_id = entry.page_id(); params->url = entry.url(); + params->referrer = entry.referrer(); params->transition = entry.transition_type(); params->state = entry.content_state(); params->reload = reload; @@ -974,12 +975,13 @@ void RenderViewHost::OnMsgContextMenu( } void RenderViewHost::OnMsgOpenURL(const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition) { GURL validated_url(url); FilterURL(RendererSecurityPolicy::GetInstance(), process()->host_id(), &validated_url); - delegate_->RequestOpenURL(validated_url, disposition); + delegate_->RequestOpenURL(validated_url, referrer, disposition); } void RenderViewHost::OnMsgDomOperationResponse( diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h index 70214b9..e387171 100644 --- a/chrome/browser/render_view_host.h +++ b/chrome/browser/render_view_host.h @@ -437,7 +437,8 @@ class RenderViewHost : public RenderWidgetHost { bool errored, const SkBitmap& image_data); void OnMsgContextMenu(const ViewHostMsg_ContextMenu_Params& params); - void OnMsgOpenURL(const GURL& url, WindowOpenDisposition disposition); + void OnMsgOpenURL(const GURL& url, const GURL& referrer, + WindowOpenDisposition disposition); void OnMsgDomOperationResponse(const std::string& json_string, int automation_id); void OnMsgDOMUISend(const std::string& message, diff --git a/chrome/browser/render_view_host_delegate.h b/chrome/browser/render_view_host_delegate.h index 39048eb..44aa1c99 100644 --- a/chrome/browser/render_view_host_delegate.h +++ b/chrome/browser/render_view_host_delegate.h @@ -229,6 +229,7 @@ class RenderViewHostDelegate { // The page wants to open a URL with the specified disposition. virtual void RequestOpenURL(const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition) { } // A DOM automation operation completed. The result of the operation is diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index 5aa292d..6c6433a 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -150,7 +150,7 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& command) { } else { NOTREACHED(); } - web->OpenURL(url, CURRENT_TAB, PageTransition::LINK); + web->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::LINK); return; } if (command == "3") { @@ -162,7 +162,7 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& command) { safe_browsing_util::GeneratePhishingReportUrl(kSbReportPhishingUrl, url().spec()); web->HideInterstitialPage(false, false); - web->OpenURL(report_url, CURRENT_TAB, PageTransition::LINK); + web->OpenURL(report_url, GURL(), CURRENT_TAB, PageTransition::LINK); return; } if (command == "4") { @@ -174,7 +174,7 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& command) { diagnostic_url = google_util::AppendGoogleLocaleParam(diagnostic_url); DCHECK(result_ == SafeBrowsingService::URL_MALWARE); web->HideInterstitialPage(false, false); - web->OpenURL(diagnostic_url, CURRENT_TAB, PageTransition::LINK); + web->OpenURL(diagnostic_url, GURL(), CURRENT_TAB, PageTransition::LINK); return; } diff --git a/chrome/browser/session_restore.cc b/chrome/browser/session_restore.cc index 90e2599..d8fb4be 100644 --- a/chrome/browser/session_restore.cc +++ b/chrome/browser/session_restore.cc @@ -343,8 +343,8 @@ class SessionRestoreImpl { void AppendURLsToBrowser(Browser* browser, const std::vector<GURL>& urls) { for (size_t i = 0; i < urls.size(); ++i) { - browser->AddTabWithURL(urls[i], PageTransition::START_PAGE, (i == 0), - NULL); + browser->AddTabWithURL(urls[i], GURL(), PageTransition::START_PAGE, + (i == 0), NULL); } } diff --git a/chrome/browser/site_instance_unittest.cc b/chrome/browser/site_instance_unittest.cc index bd93416..69c83fa 100644 --- a/chrome/browser/site_instance_unittest.cc +++ b/chrome/browser/site_instance_unittest.cc @@ -75,6 +75,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) { EXPECT_EQ(0, siteDeleteCounter); NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, + GURL(), std::wstring(), PageTransition::LINK); @@ -84,7 +85,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) { // Add a second reference NavigationEntry* e2 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, - std::wstring(), + GURL(), std::wstring(), PageTransition::LINK); // Now delete both entries and be sure the SiteInstance goes away. @@ -135,7 +136,7 @@ TEST_F(SiteInstanceTest, CloneNavigationEntry) { &browsingDeleteCounter); NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance1, 0, - url, + url, GURL(), std::wstring(), PageTransition::LINK); // Clone the entry diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc index 1a80995..931d415 100644 --- a/chrome/browser/tab_contents.cc +++ b/chrome/browser/tab_contents.cc @@ -242,11 +242,11 @@ void TabContents::Activate() { delegate_->ActivateContents(this); } -void TabContents::OpenURL(const GURL& url, +void TabContents::OpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { if (delegate_) - delegate_->OpenURLFromTab(this, url, disposition, transition); + delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); } bool TabContents::NavigateToPendingEntry(bool reload) { @@ -454,9 +454,10 @@ void TabContents::AddNewContents(ConstrainedWindow* window, void TabContents::OpenURL(ConstrainedWindow* window, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { - OpenURL(url, disposition, transition); + OpenURL(url, referrer, disposition, transition); } void TabContents::WillClose(ConstrainedWindow* window) { diff --git a/chrome/browser/tab_contents.h b/chrome/browser/tab_contents.h index 2b55c35..54a9e45 100644 --- a/chrome/browser/tab_contents.h +++ b/chrome/browser/tab_contents.h @@ -264,7 +264,7 @@ class TabContents : public PageNavigator, // Commands ------------------------------------------------------------------ // Implementation of PageNavigator. - virtual void OpenURL(const GURL& url, + virtual void OpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition); @@ -420,6 +420,7 @@ class TabContents : public PageNavigator, bool user_gesture); virtual void OpenURL(ConstrainedWindow* window, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition); virtual void WillClose(ConstrainedWindow* window); diff --git a/chrome/browser/tab_contents_delegate.h b/chrome/browser/tab_contents_delegate.h index ae3db93..401fe9e 100644 --- a/chrome/browser/tab_contents_delegate.h +++ b/chrome/browser/tab_contents_delegate.h @@ -26,15 +26,15 @@ class TabContentsDelegate : public PageNavigator { // Opens a new URL inside the passed in TabContents, if source is 0 open // in the current front-most tab. virtual void OpenURLFromTab(TabContents* source, - const GURL& url, + const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) = 0; - virtual void OpenURL(const GURL& url, + virtual void OpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { - OpenURLFromTab(NULL, url, disposition, transition); + OpenURLFromTab(NULL, url, referrer, disposition, transition); } // Called to inform the delegate that the tab content's navigation state diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 8e320bc..40d1911 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -334,7 +334,7 @@ bool TabStripModel::ShouldResetGroupOnSelect(TabContents* contents) const { TabContents* TabStripModel::AddBlankTab(bool foreground) { DCHECK(delegate_); TabContents* contents = delegate_->CreateTabContentsForURL( - NewTabUIURL(), profile_, PageTransition::TYPED, false, NULL); + NewTabUIURL(), GURL(), profile_, PageTransition::TYPED, false, NULL); AddTabContents(contents, -1, PageTransition::TYPED, foreground); return contents; } @@ -342,7 +342,7 @@ TabContents* TabStripModel::AddBlankTab(bool foreground) { TabContents* TabStripModel::AddBlankTabAt(int index, bool foreground) { DCHECK(delegate_); TabContents* contents = delegate_->CreateTabContentsForURL( - NewTabUIURL(), profile_, PageTransition::LINK, false, NULL); + NewTabUIURL(), GURL(), profile_, PageTransition::LINK, false, NULL); AddTabContents(contents, index, PageTransition::LINK, foreground); return contents; } diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index fd3a196..4329a6e 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -118,6 +118,7 @@ class TabStripModelDelegate { // If |instance| is not null, its process is used to render the tab. virtual TabContents* CreateTabContentsForURL( const GURL& url, + const GURL& referrer, Profile* profile, PageTransition::Type transition, bool defer_load, diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index cac7612..d051bf9 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -108,7 +108,7 @@ class TabStripModelTest : public testing::Test { // Forwards a URL "load" request through to our dummy TabContents // implementation. void LoadURL(TabContents* contents, const std::wstring& url) { - contents->controller()->LoadURL(GURL(url), PageTransition::LINK); + contents->controller()->LoadURL(GURL(url), GURL(), PageTransition::LINK); } void GoBack(TabContents* contents) { @@ -997,6 +997,7 @@ class TabStripDummyDelegate : public TabStripModelDelegate { virtual int GetDragActions() const { return 0; } virtual TabContents* CreateTabContentsForURL( const GURL& url, + const GURL& referrer, Profile* profile, PageTransition::Type transition, bool defer_load, diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index 93d21bc..69cd020 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -898,7 +898,7 @@ void TaskManagerContents::LinkActivated(views::Link* source, DCHECK(source == about_memory_link_); Browser* browser = BrowserList::GetLastActive(); DCHECK(browser); - browser->OpenURL(GURL("about:memory"), NEW_FOREGROUND_TAB, + browser->OpenURL(GURL("about:memory"), GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); } diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index e0ec434..ea962ff 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -595,7 +595,7 @@ void AboutChromeView::LinkActivated(views::Link* source, NOTREACHED() << "Unknown link source"; Browser* browser = BrowserList::GetLastActive(); - browser->OpenURL(url, NEW_WINDOW, PageTransition::LINK); + browser->OpenURL(url, GURL(), NEW_WINDOW, PageTransition::LINK); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 28d6b98..70be891 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -453,7 +453,7 @@ class MenuRunner : public views::MenuDelegate, DCHECK(menu_id_to_node_map_.find(id) != menu_id_to_node_map_.end()); url = menu_id_to_node_map_[id]->GetURL(); view_->GetPageNavigator()->OpenURL( - url, event_utils::DispositionFromEventFlags(mouse_event_flags), + url, GURL(), event_utils::DispositionFromEventFlags(mouse_event_flags), PageTransition::AUTO_BOOKMARK); } @@ -1418,7 +1418,7 @@ void BookmarkBarView::ButtonPressed(views::BaseButton* sender) { DCHECK(page_navigator_); if (node->is_url()) { page_navigator_->OpenURL( - node->GetURL(), + node->GetURL(), GURL(), event_utils::DispositionFromEventFlags(sender->mouse_event_flags()), PageTransition::AUTO_BOOKMARK); } else { diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc index c242a7b..c97bf3b 100644 --- a/chrome/browser/views/bookmark_bar_view_test.cc +++ b/chrome/browser/views/bookmark_bar_view_test.cc @@ -21,7 +21,7 @@ namespace { // PageNavigator implementation that records the URL. class TestingPageNavigator : public PageNavigator { public: - virtual void OpenURL(const GURL& url, + virtual void OpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { url_ = url; diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc index d53924b..58d70aa 100644 --- a/chrome/browser/views/bug_report_view.cc +++ b/chrome/browser/views/bug_report_view.cc @@ -485,6 +485,7 @@ void BugReportView::ReportPhishing() { tab_->controller()->LoadURL( safe_browsing_util::GeneratePhishingReportUrl( kReportPhishingUrl, WideToUTF8(page_url_text_->GetText())), + GURL(), PageTransition::LINK); } diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index bdd6d0f..c687041 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -980,10 +980,11 @@ void ConstrainedWindowImpl::ActivateContents(TabContents* contents) { void ConstrainedWindowImpl::OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { // We ignore source right now. - owner_->OpenURL(this, url, disposition, transition); + owner_->OpenURL(this, url, referrer, disposition, transition); } void ConstrainedWindowImpl::LoadingStateChanged(TabContents* source) { diff --git a/chrome/browser/views/constrained_window_impl.h b/chrome/browser/views/constrained_window_impl.h index d28e9d3..479b173 100644 --- a/chrome/browser/views/constrained_window_impl.h +++ b/chrome/browser/views/constrained_window_impl.h @@ -54,6 +54,7 @@ class ConstrainedWindowImpl : public ConstrainedWindow, // Overridden from PageNavigator (TabContentsDelegate's base interface): virtual void OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition); diff --git a/chrome/browser/views/dom_view.cc b/chrome/browser/views/dom_view.cc index 5ea720e..ebb63e3 100644 --- a/chrome/browser/views/dom_view.cc +++ b/chrome/browser/views/dom_view.cc @@ -35,7 +35,7 @@ bool DOMView::Init(Profile* profile, SiteInstance* instance) { views::HWNDView::Attach(host_->GetContainerHWND()); host_->SetupController(profile); - host_->controller()->LoadURL(contents_, PageTransition::START_PAGE); + host_->controller()->LoadURL(contents_, GURL(), PageTransition::START_PAGE); return true; } diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc index 9bf42b7..ea8fd14 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -86,12 +86,14 @@ void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { // PageNavigator implementation: void HtmlDialogView::OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { // Force all links to open in a new window, ignoring the incoming // disposition. This is a tabless, modal dialog so we can't just // open it in the current frame. - parent_browser_->OpenURLFromTab(source, url, NEW_WINDOW, transition); + parent_browser_->OpenURLFromTab(source, url, referrer, NEW_WINDOW, + transition); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h index e09c968..68e09adf 100644 --- a/chrome/browser/views/html_dialog_view.h +++ b/chrome/browser/views/html_dialog_view.h @@ -56,6 +56,7 @@ class HtmlDialogView // Overridden from TabContentsDelegate: virtual void OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, diff --git a/chrome/browser/views/info_bar_alternate_nav_url_view.cc b/chrome/browser/views/info_bar_alternate_nav_url_view.cc index bb0d13f..2eaa9e02 100644 --- a/chrome/browser/views/info_bar_alternate_nav_url_view.cc +++ b/chrome/browser/views/info_bar_alternate_nav_url_view.cc @@ -60,7 +60,8 @@ void InfoBarAlternateNavURLView::LinkActivated(views::Link* source, BeginClose(); - navigator->OpenURL(gurl, event_utils::DispositionFromEventFlags(event_flags), + navigator->OpenURL(gurl, GURL(), + event_utils::DispositionFromEventFlags(event_flags), // Pretend the user typed this URL, so that navigating to // it will be the default action when it's typed again in // the future. diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index 6afc034..050d73d 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -457,6 +457,7 @@ void PrivacySection::LinkActivated(views::Link* source, int event_flags) { std::wstring()); browser->OpenURL( GURL(l10n_util::GetString(IDS_LEARN_MORE_HELPMAKECHROMEBETTER_URL)), + GURL(), NEW_WINDOW, PageTransition::LINK); } diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index c5bf55a..cf768a7 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -143,13 +143,15 @@ bool DraggedTabController::IsDragSourceTab(Tab* tab) const { void DraggedTabController::OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition) { if (original_delegate_) { if (disposition == CURRENT_TAB) disposition = NEW_WINDOW; - original_delegate_->OpenURLFromTab(source, url, disposition, transition); + original_delegate_->OpenURLFromTab(source, url, referrer, + disposition, transition); } } diff --git a/chrome/browser/views/tabs/dragged_tab_controller.h b/chrome/browser/views/tabs/dragged_tab_controller.h index 041d2337..fb367c3 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.h +++ b/chrome/browser/views/tabs/dragged_tab_controller.h @@ -80,6 +80,7 @@ class DraggedTabController : public TabContentsDelegate, // Overridden from TabContentsDelegate: virtual void OpenURLFromTab(TabContents* source, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition, PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index a1e1e41..55c4a908 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -709,14 +709,15 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) { // Insert a new tab. TabContents* contents = model_->delegate()->CreateTabContentsForURL( - url, model_->profile(), PageTransition::TYPED, false, NULL); + url, GURL(), model_->profile(), PageTransition::TYPED, false, + NULL); model_->AddTabContents(contents, drop_index, PageTransition::GENERATED, true); } else { UserMetrics::RecordAction(L"Tab_DropURLOnTab", model_->profile()); model_->GetTabContentsAt(drop_index)->controller()-> - LoadURL(url, PageTransition::GENERATED); + LoadURL(url, GURL(), PageTransition::GENERATED); model_->SelectTabContentsAt(drop_index, true); } diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index 1c27a0d..50ec3cd 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -983,9 +983,9 @@ void WebContents::DidDownloadImage( web_app_->SetImage(image_url, image); } -void WebContents::RequestOpenURL(const GURL& url, +void WebContents::RequestOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition) { - OpenURL(url, disposition, PageTransition::LINK); + OpenURL(url, referrer, disposition, PageTransition::LINK); } void WebContents::DomOperationResponse(const std::string& json_string, diff --git a/chrome/browser/web_contents.h b/chrome/browser/web_contents.h index 705d027..f907b6c 100644 --- a/chrome/browser/web_contents.h +++ b/chrome/browser/web_contents.h @@ -264,7 +264,7 @@ class WebContents : public TabContents, const GURL& image_url, bool errored, const SkBitmap& image); - virtual void RequestOpenURL(const GURL& url, + virtual void RequestOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition); virtual void DomOperationResponse(const std::string& json_string, int automation_id); diff --git a/chrome/browser/web_contents_unittest.cc b/chrome/browser/web_contents_unittest.cc index a4b57f1..5319a81 100644 --- a/chrome/browser/web_contents_unittest.cc +++ b/chrome/browser/web_contents_unittest.cc @@ -322,7 +322,7 @@ TEST_F(WebContentsTest, SimpleNavigation) { // Navigate to URL const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); EXPECT_TRUE(contents->state_is_normal()); EXPECT_TRUE(orig_rvh->is_loading); EXPECT_EQ(instance1, orig_rvh->site_instance()); @@ -355,7 +355,7 @@ TEST_F(WebContentsTest, ShowInterstitialDontProceed) { // Navigate to URL const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); EXPECT_TRUE(contents->state_is_normal()); EXPECT_TRUE(orig_rvh->is_loading); @@ -396,7 +396,7 @@ TEST_F(WebContentsTest, ShowInterstitialProceed) { // Navigate to URL const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); // Show interstitial const GURL interstitial_url("http://interstitial"); @@ -442,7 +442,7 @@ TEST_F(WebContentsTest, ShowInterstitialThenNavigate) { // Navigate to URL const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); // Show interstitial const GURL interstitial_url("http://interstitial"); @@ -459,7 +459,7 @@ TEST_F(WebContentsTest, ShowInterstitialThenNavigate) { // While interstitial showing, navigate to a new URL. const GURL url2("http://www.yahoo.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); EXPECT_TRUE(contents->state_is_leaving_interstitial()); EXPECT_EQ(interstitial_rvh, contents->render_view_host()); EXPECT_TRUE(orig_rvh->is_loading); @@ -487,7 +487,7 @@ TEST_F(WebContentsTest, ShowInterstitialIFrameNavigate) { // Navigate to URL. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); EXPECT_TRUE(contents->state_is_normal()); EXPECT_TRUE(orig_rvh->is_loading); ViewHostMsg_FrameNavigate_Params params1; @@ -529,14 +529,14 @@ TEST_F(WebContentsTest, VisitInterstitialURLTwice) { // Navigate to URL const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); // Now navigate to an interstitial-inducing URL const GURL url2("https://www.google.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); const GURL interstitial_url("http://interstitial"); InterstitialPage* interstitial = new InterstitialPage(contents, true, @@ -555,7 +555,7 @@ TEST_F(WebContentsTest, VisitInterstitialURLTwice) { EXPECT_EQ(interstitial_rvh, contents->render_view_host()); // While interstitial showing, navigate to the same URL. - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); EXPECT_TRUE(contents->state_is_leaving_interstitial()); EXPECT_EQ(interstitial_rvh, contents->render_view_host()); @@ -609,7 +609,7 @@ TEST_F(WebContentsTest, CrossSiteBoundaries) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); @@ -621,7 +621,7 @@ TEST_F(WebContentsTest, CrossSiteBoundaries) { // Navigate to new site const GURL url2("http://www.yahoo.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); EXPECT_TRUE(contents->state_is_pending()); TestRenderViewHost* pending_rvh = contents->pending_rvh(); int pending_rvh_delete_count = 0; @@ -666,7 +666,7 @@ TEST_F(WebContentsTest, CrossSiteBoundariesAfterCrash) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); @@ -681,7 +681,7 @@ TEST_F(WebContentsTest, CrossSiteBoundariesAfterCrash) { // Navigate to new site. We should not go into PENDING. const GURL url2("http://www.yahoo.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); TestRenderViewHost* new_rvh = contents->rvh(); EXPECT_TRUE(contents->state_is_normal()); EXPECT_TRUE(contents->pending_rvh() == NULL); @@ -713,7 +713,7 @@ TEST_F(WebContentsTest, CrossSiteInterstitialDontProceed) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); @@ -723,7 +723,7 @@ TEST_F(WebContentsTest, CrossSiteInterstitialDontProceed) { // Navigate to new site const GURL url2("https://www.google.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); EXPECT_TRUE(contents->state_is_pending()); TestRenderViewHost* pending_rvh = contents->pending_rvh(); @@ -768,14 +768,14 @@ TEST_F(WebContentsTest, CrossSiteInterstitialProceed) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); // Navigate to new site const GURL url2("https://www.google.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); TestRenderViewHost* pending_rvh = contents->pending_rvh(); int pending_rvh_delete_count = 0; pending_rvh->set_delete_counter(&pending_rvh_delete_count); @@ -845,7 +845,7 @@ TEST_F(WebContentsTest, CrossSiteInterstitialThenNavigate) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); @@ -869,7 +869,7 @@ TEST_F(WebContentsTest, CrossSiteInterstitialThenNavigate) { // Navigate to a new page. const GURL url2("http://www.yahoo.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); TestRenderViewHost* new_rvh = contents->pending_rvh(); ASSERT_TRUE(new_rvh != NULL); @@ -898,14 +898,14 @@ TEST_F(WebContentsTest, CrossSiteInterstitialCrashThenNavigate) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); // Navigate to new site const GURL url2("https://www.google.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); TestRenderViewHost* pending_rvh = contents->pending_rvh(); int pending_rvh_delete_count = 0; pending_rvh->set_delete_counter(&pending_rvh_delete_count); @@ -935,7 +935,7 @@ TEST_F(WebContentsTest, CrossSiteInterstitialCrashThenNavigate) { // Navigate to a new page. Since interstitial RVH is dead, we should clean // it up and go to a new PENDING state, showing the orig_rvh. const GURL url3("http://www.yahoo.com"); - contents->controller()->LoadURL(url3, PageTransition::TYPED); + contents->controller()->LoadURL(url3, GURL(), PageTransition::TYPED); TestRenderViewHost* new_rvh = contents->pending_rvh(); ASSERT_TRUE(new_rvh != NULL); EXPECT_TRUE(contents->state_is_pending()); @@ -965,14 +965,14 @@ TEST_F(WebContentsTest, CrossSiteInterstitialCrashesThenNavigate) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); // Navigate to new site const GURL url2("https://www.google.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); TestRenderViewHost* pending_rvh = contents->pending_rvh(); int pending_rvh_delete_count = 0; pending_rvh->set_delete_counter(&pending_rvh_delete_count); @@ -1003,7 +1003,7 @@ TEST_F(WebContentsTest, CrossSiteInterstitialCrashesThenNavigate) { // Navigate to a new page. Since both the interstitial and original RVHs are // dead, we should create a new RVH, jump back to NORMAL, and navigate. const GURL url3("http://www.yahoo.com"); - contents->controller()->LoadURL(url3, PageTransition::TYPED); + contents->controller()->LoadURL(url3, GURL(), PageTransition::TYPED); TestRenderViewHost* new_rvh = contents->rvh(); ASSERT_TRUE(new_rvh != NULL); EXPECT_TRUE(contents->state_is_normal()); @@ -1031,7 +1031,7 @@ TEST_F(WebContentsTest, NavigateTwoTabsCrossSite) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); @@ -1043,12 +1043,12 @@ TEST_F(WebContentsTest, NavigateTwoTabsCrossSite) { // this a new page. contents2->transition_cross_site = true; contents2->SetupController(profile.get()); - contents2->controller()->LoadURL(url, PageTransition::TYPED); + contents2->controller()->LoadURL(url, GURL(), PageTransition::TYPED); contents2->TestDidNavigate(contents2->rvh(), params1); // Navigate first tab to a new site const GURL url2a("http://www.yahoo.com"); - contents->controller()->LoadURL(url2a, PageTransition::TYPED); + contents->controller()->LoadURL(url2a, GURL(), PageTransition::TYPED); TestRenderViewHost* pending_rvh_a = contents->pending_rvh(); ViewHostMsg_FrameNavigate_Params params2a; InitNavigateParams(¶ms2a, 1, url2a); @@ -1058,7 +1058,7 @@ TEST_F(WebContentsTest, NavigateTwoTabsCrossSite) { // Navigate second tab to the same site as the first tab const GURL url2b("http://mail.yahoo.com"); - contents2->controller()->LoadURL(url2b, PageTransition::TYPED); + contents2->controller()->LoadURL(url2b, GURL(), PageTransition::TYPED); TestRenderViewHost* pending_rvh_b = contents2->pending_rvh(); EXPECT_TRUE(pending_rvh_b != NULL); EXPECT_TRUE(contents2->state_is_pending()); @@ -1088,7 +1088,7 @@ TEST_F(WebContentsTest, CrossSiteComparesAgainstCurrentPage) { // Navigate to URL. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); @@ -1098,7 +1098,7 @@ TEST_F(WebContentsTest, CrossSiteComparesAgainstCurrentPage) { contents2->transition_cross_site = true; contents2->SetupController(profile.get()); const GURL url2("http://www.yahoo.com"); - contents2->controller()->LoadURL(url2, PageTransition::TYPED); + contents2->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); // The first RVH in contents2 isn't live yet, so we shortcut the PENDING // state and go straight to NORMAL. TestRenderViewHost* rvh2 = contents2->rvh(); @@ -1122,7 +1122,7 @@ TEST_F(WebContentsTest, CrossSiteComparesAgainstCurrentPage) { // Navigate to the new site. Doesn't switch SiteInstancees, because we // compare against the current URL, not the SiteInstance's site. const GURL url3("http://mail.yahoo.com"); - contents->controller()->LoadURL(url3, PageTransition::TYPED); + contents->controller()->LoadURL(url3, GURL(), PageTransition::TYPED); EXPECT_TRUE(contents->state_is_normal()); ViewHostMsg_FrameNavigate_Params params4; InitNavigateParams(¶ms4, 3, url3); @@ -1142,7 +1142,7 @@ TEST_F(WebContentsTest, CrossSiteUnloadHandlers) { // Navigate to URL. First URL should use first RenderViewHost. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); ViewHostMsg_FrameNavigate_Params params1; InitNavigateParams(¶ms1, 1, url); contents->TestDidNavigate(orig_rvh, params1); @@ -1152,13 +1152,13 @@ TEST_F(WebContentsTest, CrossSiteUnloadHandlers) { // Navigate to new site, but simulate an onbeforeunload denial. const GURL url2("http://www.yahoo.com"); orig_rvh->immediate_before_unload = false; - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); orig_rvh->TestOnMsgShouldClose(false); EXPECT_TRUE(contents->state_is_normal()); EXPECT_EQ(orig_rvh, contents->render_view_host()); // Navigate again, but simulate an onbeforeunload approval. - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); orig_rvh->TestOnMsgShouldClose(true); EXPECT_TRUE(contents->state_is_pending()); TestRenderViewHost* pending_rvh = contents->pending_rvh(); @@ -1187,7 +1187,7 @@ TEST_F(WebContentsTest, NavigationEntryContentState) { // Navigate to URL. There should be no committed entry yet. const GURL url("http://www.google.com"); - contents->controller()->LoadURL(url, PageTransition::TYPED); + contents->controller()->LoadURL(url, GURL(), PageTransition::TYPED); NavigationEntry* entry = contents->controller()->GetLastCommittedEntry(); EXPECT_TRUE(entry == NULL); @@ -1200,7 +1200,7 @@ TEST_F(WebContentsTest, NavigationEntryContentState) { // Navigate to same site. const GURL url2("http://images.google.com"); - contents->controller()->LoadURL(url2, PageTransition::TYPED); + contents->controller()->LoadURL(url2, GURL(), PageTransition::TYPED); entry = contents->controller()->GetLastCommittedEntry(); EXPECT_FALSE(entry->content_state().empty()); diff --git a/chrome/browser/web_drop_target.cc b/chrome/browser/web_drop_target.cc index d072b72..0d451bd 100644 --- a/chrome/browser/web_drop_target.cc +++ b/chrome/browser/web_drop_target.cc @@ -58,7 +58,7 @@ class InterstitialDropTarget { std::wstring url; std::wstring title; ClipboardUtil::GetUrl(data_object, &url, &title); - web_contents_->OpenURL(GURL(url), CURRENT_TAB, + web_contents_->OpenURL(GURL(url), GURL(), CURRENT_TAB, PageTransition::AUTO_BOOKMARK); return GetPreferredDropEffect(effect); } diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 46373c5..aaa44f7 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -41,6 +41,10 @@ struct ViewMsg_Navigate_Params { // The URL to load. GURL url; + // The URL to send in the "Referer" header field. Can be empty if there is + // no referrer. + GURL referrer; + // The type of transition. PageTransition::Type transition; @@ -749,6 +753,7 @@ struct ParamTraits<ViewMsg_Navigate_Params> { static void Write(Message* m, const param_type& p) { WriteParam(m, p.page_id); WriteParam(m, p.url); + WriteParam(m, p.referrer); WriteParam(m, p.transition); WriteParam(m, p.state); WriteParam(m, p.reload); @@ -757,6 +762,7 @@ struct ParamTraits<ViewMsg_Navigate_Params> { return ReadParam(m, iter, &p->page_id) && ReadParam(m, iter, &p->url) && + ReadParam(m, iter, &p->referrer) && ReadParam(m, iter, &p->transition) && ReadParam(m, iter, &p->state) && ReadParam(m, iter, &p->reload); diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index a998b49..b191d41 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -735,8 +735,9 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) IPC_MESSAGE_ROUTED1(ViewHostMsg_ContextMenu, ViewHostMsg_ContextMenu_Params) // Request that the given URL be opened in the specified manner. - IPC_MESSAGE_ROUTED2(ViewHostMsg_OpenURL, + IPC_MESSAGE_ROUTED3(ViewHostMsg_OpenURL, GURL /* url */, + GURL /* referrer */, WindowOpenDisposition /* disposition */) // Following message is used to communicate the values received by the diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 734514b..67f816c 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -842,6 +842,11 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { if (!is_reload) request->SetHistoryState(params.state); + if (!params.referrer.is_empty()) { + request->SetHttpHeaderValue(L"Referer", + UTF8ToWide(params.referrer.spec())); + } + main_frame->LoadRequest(request.get()); } @@ -1523,7 +1528,7 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( if (enable_dom_ui_bindings_ || frame->GetInViewSourceMode() || url.SchemeIs("view-source")) { - OpenURL(webview, url, disposition); + OpenURL(webview, url, GURL(), disposition); return IGNORE_ACTION; // Suppress the load here. } } @@ -1560,7 +1565,7 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( type == WebNavigationTypeOther; if (is_fork) { // Open the URL via the browser, not via WebKit. - OpenURL(webview, url, disposition); + OpenURL(webview, url, GURL(), disposition); return IGNORE_ACTION; } @@ -1825,8 +1830,9 @@ void RenderView::OnMissingPluginStatus(WebPluginDelegate* delegate, } void RenderView::OpenURL(WebView* webview, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition) { - Send(new ViewHostMsg_OpenURL(routing_id_, url, disposition)); + Send(new ViewHostMsg_OpenURL(routing_id_, url, referrer, disposition)); } // We are supposed to get a single call to Show for a newly created RenderView diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 9c50dfe..ddfe6d3 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -206,6 +206,7 @@ class RenderView : public RenderWidget, public WebViewDelegate, std::string* actual_mime_type); virtual void OnMissingPluginStatus(WebPluginDelegate* delegate, int status); virtual void OpenURL(WebView* webview, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition); virtual void DidDownloadImage(int id, const GURL& image_url, diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc index 6829cd5..7b609e04 100644 --- a/webkit/glue/glue_util.cc +++ b/webkit/glue/glue_util.cc @@ -79,8 +79,7 @@ GURL KURLToGURL(const WebCore::KURL& url) { return GURL(); return GURL(spec.data(), spec.length(), url.parsed(), url.isValid()); #else - const WebCore::String& spec = url.string(); - return GURL(WideToUTF8(StringToStdWString(spec))); + return StringToGURL(url.string()); #endif } @@ -95,6 +94,10 @@ WebCore::KURL GURLToKURL(const GURL& url) { #endif } +GURL StringToGURL(const WebCore::String& spec) { + return GURL(WideToUTF8(StringToStdWString(spec))); +} + // Rect conversions ------------------------------------------------------------ gfx::Rect FromIntRect(const WebCore::IntRect& r) { diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h index d649ccf..ace448b 100644 --- a/webkit/glue/glue_util.h +++ b/webkit/glue/glue_util.h @@ -44,6 +44,7 @@ WebCore::String StdStringToString(const std::string& str); GURL KURLToGURL(const WebCore::KURL& url); WebCore::KURL GURLToKURL(const GURL& url); +GURL StringToGURL(const WebCore::String& spec); gfx::Rect FromIntRect(const WebCore::IntRect& r); WebCore::IntRect ToIntRect(const gfx::Rect& r); diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 81a6b06..f178554 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -917,8 +917,12 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( } else if (disposition == SAVE_TO_DISK) { policy_action = PolicyDownload; } else { + GURL referrer = webkit_glue::StringToGURL( + request.httpHeaderField("Referer")); + d->OpenURL(webframe_->webview_impl(), webkit_glue::KURLToGURL(request.url()), + referrer, disposition); policy_action = PolicyIgnore; } diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 15e93ba..c8aa405 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -133,6 +133,7 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // This method is called to open a URL in the specified manner. virtual void OpenURL(WebView* webview, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition) { } diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 07016d8..bde633b 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -112,6 +112,7 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate( } void TestWebViewDelegate::OpenURL(WebView* webview, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition) { DCHECK_NE(disposition, CURRENT_TAB); // No code for this if (disposition == SUPPRESS_OPEN) diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 0ac2c92..e1a9e74 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -75,6 +75,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, std::string* actual_mime_type); virtual void OpenURL(WebView* webview, const GURL& url, + const GURL& referrer, WindowOpenDisposition disposition); virtual void RunJavaScriptAlert(WebView* webview, const std::wstring& message); |