From a1be1f83509b1fcf1310bd030572202dc7c44058 Mon Sep 17 00:00:00 2001 From: "rogerta@chromium.org" Date: Fri, 2 Sep 2011 02:01:38 +0000 Subject: Revert 99283 - When the user navigates to the home page, make sure to set the RLZ string if needed. John: can you plase look at the content\... changes? Scott: can you plase look at the chrome\... changes? BUG=0 TEST=Install an official chrome build (not a chromium build) with a non organic brand code. During the install, make sure to choose google as the home page. When google is running, pressing the home page button should cause the request to include the RLZ http header. Pressed Alt-Home should do the samer thing. When starting chrome, the RLZ header should also be present since the startup page is the home page, and the home page is set to google. Navigating to the google.com manually by typing the URL or by clicking on a link should not cause the hrrp header to be added. Not choosing google as the home during install, or changing the home page to be something other than google should stop the http header from being added. This is true is even if the user subsequently set his home page to google again. Review URL: http://codereview.chromium.org/7791029 TBR=rogerta@chromium.org Review URL: http://codereview.chromium.org/7831030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99286 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/browser_main.cc | 21 ++------ chrome/browser/instant/instant_loader.cc | 12 ++--- chrome/browser/rlz/rlz.cc | 3 +- chrome/browser/rlz/rlz.h | 5 ++ chrome/browser/rlz/rlz_unittest.cc | 3 +- chrome/browser/sessions/session_types.cc | 2 - chrome/browser/ui/browser.cc | 15 +----- chrome/browser/ui/browser.h | 3 -- chrome/browser/ui/browser_navigator.cc | 62 +++------------------- chrome/common/pref_names.cc | 3 -- chrome/common/pref_names.h | 1 - .../browser/tab_contents/navigation_controller.cc | 15 +----- .../browser/tab_contents/navigation_controller.h | 11 +--- .../tab_contents/navigation_controller_unittest.cc | 4 +- content/browser/tab_contents/navigation_entry.h | 13 +---- content/browser/tab_contents/tab_contents.cc | 12 ++--- .../browser/tab_contents/tab_contents_delegate.cc | 4 +- .../browser/tab_contents/tab_contents_delegate.h | 4 +- .../tab_contents/tab_contents_delegate_unittest.cc | 24 ++++----- content/common/content_notification_types.h | 4 +- content/common/page_transition_types.h | 3 -- 21 files changed, 52 insertions(+), 172 deletions(-) diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 50b7802..d717f9e 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -44,7 +44,6 @@ #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/first_run/first_run_browser_process.h" #include "chrome/browser/first_run/upgrade_util.h" -#include "chrome/browser/google/google_url_tracker.h" #include "chrome/browser/instant/instant_field_trial.h" #include "chrome/browser/jankometer.h" #include "chrome/browser/language_usage_metrics.h" @@ -1881,23 +1880,11 @@ int BrowserMain(const MainFunctionParams& parameters) { } } } - - bool google_search_homepage = false; - PrefService* pref_service = profile->GetPrefs(); - if (pref_service) { - std::string homepage = pref_service->GetString(prefs::kHomePage); - google_search_homepage = - homepage == GoogleURLTracker::kDefaultGoogleHomepage; - } - + // TODO(rogerta): For now, always passing false for google_homeapge_default + // argument, so that functionality is disabled. A follow up CL will set it + // correctly. RLZTracker::InitRlzDelayed(is_first_run, master_prefs.ping_delay, - google_search_default, google_search_homepage); - - // Prime the RLZ cache for the home page access point so that its avaiable - // for the startup page if needed (i.e., when the startup page is set to - // the home page). - RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL); - + google_search_default, false); #endif // GOOGLE_CHROME_BUILD #endif // OS_WIN diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index cb2d593..0ad7f8b 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -181,8 +181,7 @@ class InstantLoader::TabContentsDelegateImpl // TabContentsDelegate: virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags) OVERRIDE; - virtual void AddNavigationHeaders(const GURL& url, - std::string* headers) OVERRIDE; + virtual std::string GetNavigationHeaders(const GURL& url) OVERRIDE; virtual bool ShouldFocusConstrainedWindow() OVERRIDE; virtual void WillShowConstrainedWindow(TabContents* source) OVERRIDE; virtual bool ShouldSuppressDialogs() OVERRIDE; @@ -413,11 +412,12 @@ void InstantLoader::TabContentsDelegateImpl::NavigationStateChanged( } } -void InstantLoader::TabContentsDelegateImpl::AddNavigationHeaders( - const GURL& url, - std::string* headers) { +std::string InstantLoader::TabContentsDelegateImpl::GetNavigationHeaders( + const GURL& url) { + std::string header; net::HttpUtil::AppendHeaderIfMissing(kPreviewHeader, kPreviewHeaderValue, - headers); + &header); + return header; } bool InstantLoader::TabContentsDelegateImpl::ShouldFocusConstrainedWindow() { diff --git a/chrome/browser/rlz/rlz.cc b/chrome/browser/rlz/rlz.cc index ea208a3..1af7d7b 100644 --- a/chrome/browser/rlz/rlz.cc +++ b/chrome/browser/rlz/rlz.cc @@ -196,7 +196,6 @@ bool RLZTracker::Init(bool first_run, int delay, bool google_default_search, NotificationService::AllSources()); ScheduleDelayedInit(delay); - return true; } @@ -296,7 +295,7 @@ void RLZTracker::Observe(int type, case content::NOTIFICATION_NAV_ENTRY_PENDING: { const NavigationEntry* entry = Details(details).ptr(); if (entry != NULL && - ((entry->transition_type() & PageTransition::HOME_PAGE) != 0)) { + ((entry->transition_type() & RLZ_PAGETRANSITION_HOME_PAGE) != 0)) { point = rlz_lib::CHROME_HOME_PAGE; record_used = &homepage_used_; call_record = true; diff --git a/chrome/browser/rlz/rlz.h b/chrome/browser/rlz/rlz.h index c335cbd..cbbec70 100644 --- a/chrome/browser/rlz/rlz.h +++ b/chrome/browser/rlz/rlz.h @@ -66,6 +66,11 @@ class RLZTracker : public NotificationObserver { RLZTracker(); ~RLZTracker(); + // This is a temporary constant used here until the home page change is + // committed, which will happen before 2011-09-01. This constant will be + // replaced with PageTransition::HOME_PAGE. + static const int RLZ_PAGETRANSITION_HOME_PAGE = 0x02000000; + // Thread function entry point, see ScheduleFinancialPing(). Assumes argument // is a pointer to an RLZTracker. static void _cdecl PingNow(void* tracker); diff --git a/chrome/browser/rlz/rlz_unittest.cc b/chrome/browser/rlz/rlz_unittest.cc index 3d1d860..96816a4 100644 --- a/chrome/browser/rlz/rlz_unittest.cc +++ b/chrome/browser/rlz/rlz_unittest.cc @@ -80,6 +80,7 @@ class TestRLZTracker : public RLZTracker { public: using RLZTracker::DelayedInit; using RLZTracker::Observe; + using RLZTracker::RLZ_PAGETRANSITION_HOME_PAGE; TestRLZTracker() : pingnow_called_(false), assume_io_thread_(false) { set_tracker(this); @@ -203,7 +204,7 @@ void RlzLibTest::SimulateOmniboxUsage() { void RlzLibTest::SimulateHomepageUsage() { NavigationEntry entry(NULL, 0, GURL(), GURL(), string16(), - PageTransition::HOME_PAGE); + TestRLZTracker::RLZ_PAGETRANSITION_HOME_PAGE); tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, NotificationService::AllSources(), Details(&entry)); diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc index 086eb3e..c1f1c28 100644 --- a/chrome/browser/sessions/session_types.cc +++ b/chrome/browser/sessions/session_types.cc @@ -66,8 +66,6 @@ NavigationEntry* TabNavigation::ToNavigationEntry(int page_id, // Use a transition type of reload so that we don't incorrectly // increase the typed count. PageTransition::RELOAD, - // The extra headers are not sync'ed across sessions. - std::string(), profile); entry->set_page_id(page_id); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 4122829..935ee68 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -313,7 +313,6 @@ Browser::Browser(Type type, Profile* profile) profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); profile_pref_registrar_.Add(prefs::kEnableBookmarkBar, this); - profile_pref_registrar_.Add(prefs::kHomePage, this); profile_pref_registrar_.Add(prefs::kInstantEnabled, this); profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this); @@ -1469,8 +1468,7 @@ void Browser::ReloadInternal(WindowOpenDisposition disposition, void Browser::Home(WindowOpenDisposition disposition) { UserMetrics::RecordAction(UserMetricsAction("Home")); - OpenURL(GetHomePage(), GURL(), disposition, - PageTransition::AUTO_BOOKMARK | PageTransition::HOME_PAGE); + OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); } void Browser::OpenCurrentURL() { @@ -2240,9 +2238,6 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterStringPref(prefs::kHomePage, chrome::kChromeUINewTabURL, PrefService::SYNCABLE_PREF); - prefs->RegisterBooleanPref(prefs::kHomePageChanged, - false, - PrefService::UNSYNCABLE_PREF); prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, true, PrefService::SYNCABLE_PREF); @@ -4038,9 +4033,6 @@ void Browser::Observe(int type, UpdateCommandsForBookmarkEditing(); } else if (pref_name == prefs::kEnableBookmarkBar) { UpdateCommandsForBookmarkBar(); - } else if (pref_name == prefs::kHomePage) { - PrefService* pref_service = Source(source).ptr(); - MarkHomePageAsChanged(pref_service); } else if (pref_name == prefs::kAllowFileSelectionDialogs) { UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); UpdateOpenFileState(); @@ -4493,11 +4485,6 @@ void Browser::UpdateCommandsForBookmarkBar() { show_main_ui); } -void Browser::MarkHomePageAsChanged(PrefService* pref_service) { - pref_service->SetBoolean(prefs::kHomePageChanged, true); - pref_service->ScheduleSavePersistentPrefs(); -} - void Browser::UpdateSaveAsState(int content_restrictions) { bool enabled = !(content_restrictions & CONTENT_RESTRICTION_SAVE); PrefService* state = g_browser_process->local_state(); diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index b131f12..f83843e 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -1042,9 +1042,6 @@ class Browser : public TabHandlerDelegate, // Updates commands that affect the bookmark bar. void UpdateCommandsForBookmarkBar(); - // Set the preference that indicates that the home page has been changed. - void MarkHomePageAsChanged(PrefService* pref_service); - // Update commands whose state depends on whether the window is in fullscreen // mode. void UpdateCommandsForFullscreenMode(bool is_fullscreen); diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index 2908ba1..cbc89ac 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -7,15 +7,10 @@ #include #include "base/command_line.h" -#include "base/stringprintf.h" -#include "base/utf_string_conversions.h" #include "chrome/browser/browser_about_handler.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_tab_helper.h" -#include "chrome/browser/google/google_url_tracker.h" -#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/rlz/rlz.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/browser.h" @@ -26,12 +21,10 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/common/extensions/extension.h" -#include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_url_handler.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/tab_contents.h" -#include "net/http/http_util.h" namespace { @@ -282,37 +275,6 @@ class ScopedTargetContentsOwner { DISALLOW_COPY_AND_ASSIGN(ScopedTargetContentsOwner); }; -void InitializeExtraHeaders(browser::NavigateParams* params, - Profile* profile, - std::string* extra_headers) { -#if defined(GOOGLE_CHROME_BUILD) - if (!profile) - profile = params->profile; - - // If this is a home page navigation, check to see if the home page is - // set to Google and add RLZ HTTP headers to the request. This is only - // done if Google was the original home page, and not changed afterwards by - // the user. - if (profile && (params->transition & PageTransition::HOME_PAGE) != 0) { - PrefService* pref_service = profile->GetPrefs(); - if (pref_service) { - if (!pref_service->GetBoolean(prefs::kHomePageChanged)) { - std::string homepage = pref_service->GetString(prefs::kHomePage); - if (homepage == GoogleURLTracker::kDefaultGoogleHomepage) { - std::wstring rlz_string; - RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, &rlz_string); - if (!rlz_string.empty()) { - net::HttpUtil::AppendHeaderIfMissing("X-Rlz-String", - WideToUTF8(rlz_string), - extra_headers); - } - } - } - } - } -#endif -} - } // namespace namespace browser { @@ -415,22 +377,14 @@ void Navigate(NavigateParams* params) { base_transition == PageTransition::RELOAD || base_transition == PageTransition::KEYWORD; - std::string extra_headers; - // Check if this is a singleton tab that already exists int singleton_index = GetIndexOfSingletonTab(params); // If no target TabContents was specified, we need to construct one if we are // supposed to target a new tab; unless it's a singleton that already exists. if (!params->target_contents && singleton_index < 0) { - GURL url; - if (params->url.is_empty()) { - url = params->browser->GetHomePage(); - params->transition |= PageTransition::HOME_PAGE; - } else { - url = params->url; - } - + GURL url = params->url.is_empty() ? params->browser->GetHomePage() + : params->url; if (params->disposition != CURRENT_TAB) { TabContents* source_contents = params->source_contents ? params->source_contents->tab_contents() : NULL; @@ -467,15 +421,12 @@ void Navigate(NavigateParams* params) { tab_contents())->OnUserGesture(); } - InitializeExtraHeaders(params, params->target_contents->profile(), - &extra_headers); - // Try to handle non-navigational URLs that popup dialogs and such, these // should not actually navigate. if (!HandleNonNavigationAboutURL(url)) { // Perform the actual navigation. - params->target_contents->controller().LoadURLWithHeaders( - url, params->referrer, params->transition, extra_headers); + params->target_contents->controller().LoadURL(url, params->referrer, + params->transition); } } else { // |target_contents| was specified non-NULL, and so we assume it has already @@ -522,9 +473,8 @@ void Navigate(NavigateParams* params) { target->controller().Reload(true); } else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE && target->GetURL() != params->url) { - InitializeExtraHeaders(params, NULL, &extra_headers); - target->controller().LoadURLWithHeaders( - params->url, params->referrer, params->transition, extra_headers); + target->controller().LoadURL( + params->url, params->referrer, params->transition); } // If the singleton tab isn't already selected, select it. diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index e17e841..bf3847a 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -24,9 +24,6 @@ const char kHomePageIsNewTabPage[] = "homepage_is_newtabpage"; // This is the URL of the page to load when opening new tabs. const char kHomePage[] = "homepage"; -// Did the user change the home page after install? -const char kHomePageChanged[] = "homepage_changed"; - // Used to determine if the last session exited cleanly. Set to false when // first opened, and to true when closing. On startup if the value is false, // it means the profile didn't exit cleanly. diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index e8d347c..cd68ad8 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -19,7 +19,6 @@ extern const char kAppsPromoCounter[]; extern const char kDefaultAppsInstalled[]; extern const char kHomePageIsNewTabPage[]; extern const char kHomePage[]; -extern const char kHomePageChanged[]; extern const char kSessionExitedCleanly[]; extern const char kRestoreOnStartup[]; extern const char kURLsToRestoreOnStartup[]; diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc index 1ee7492..85780cd 100644 --- a/content/browser/tab_contents/navigation_controller.cc +++ b/content/browser/tab_contents/navigation_controller.cc @@ -221,7 +221,6 @@ bool NavigationController::IsInitialNavigation() { // static NavigationEntry* NavigationController::CreateNavigationEntry( const GURL& url, const GURL& referrer, PageTransition::Type transition, - const std::string& extra_headers, content::BrowserContext* browser_context) { // Allow the browser URL handler to rewrite the URL. This will, for example, // remove "view-source:" from the beginning of the URL to get the URL that @@ -243,7 +242,6 @@ NavigationEntry* NavigationController::CreateNavigationEntry( entry->set_virtual_url(url); entry->set_user_typed_url(url); entry->set_update_virtual_url_with_url(reverse_on_redirect); - entry->set_extra_headers(extra_headers); return entry; } @@ -275,7 +273,7 @@ void NavigationController::LoadEntry(NavigationEntry* entry) { NotificationService::current()->Notify( content::NOTIFICATION_NAV_ENTRY_PENDING, Source(this), - Details(entry)); + NotificationService::NoDetails()); NavigateToPendingEntry(NO_RELOAD); } @@ -485,21 +483,10 @@ void NavigationController::AddTransientEntry(NavigationEntry* entry) { void NavigationController::LoadURL(const GURL& url, const GURL& referrer, PageTransition::Type transition) { - LoadURLWithHeaders(url, referrer, transition, std::string()); -} - -// TODO(rogerta): Remove this call and put the extra_headers argument directly -// in LoadURL(). -void NavigationController::LoadURLWithHeaders( - const GURL& url, - const GURL& referrer, - PageTransition::Type transition, - const std::string& extra_headers) { // The user initiated a load, we don't need to reload anymore. needs_reload_ = false; NavigationEntry* entry = CreateNavigationEntry(url, referrer, transition, - extra_headers, browser_context_); LoadEntry(entry); diff --git a/content/browser/tab_contents/navigation_controller.h b/content/browser/tab_contents/navigation_controller.h index a410c4d..c7d9d03 100644 --- a/content/browser/tab_contents/navigation_controller.h +++ b/content/browser/tab_contents/navigation_controller.h @@ -176,13 +176,6 @@ class NavigationController { void LoadURL(const GURL& url, const GURL& referrer, PageTransition::Type type); - // Loads the specified URL, specifying extra http headers to add to the - // request. Extra headers are separated by \n. - void LoadURLWithHeaders(const GURL& url, - const GURL& referrer, - PageTransition::Type type, - const std::string& extra_headers); - // Loads the current page if this NavigationController was restored from // history and the current page has not loaded yet. void LoadIfNecessary(); @@ -334,13 +327,11 @@ class NavigationController { bool IsInitialNavigation(); // Creates navigation entry and translates the virtual url to a real one. - // Used when navigating to a new URL using LoadURL. Extra headers are - // separated by \n. + // Used when navigating to a new URL using LoadURL. static NavigationEntry* CreateNavigationEntry( const GURL& url, const GURL& referrer, PageTransition::Type transition, - const std::string& extra_headers, content::BrowserContext* browser_context); private: diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc index fbb9b01..0830650 100644 --- a/content/browser/tab_contents/navigation_controller_unittest.cc +++ b/content/browser/tab_contents/navigation_controller_unittest.cc @@ -1438,7 +1438,7 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { GURL url("http://foo"); std::vector entries; NavigationEntry* entry = NavigationController::CreateNavigationEntry( - url, GURL(), PageTransition::RELOAD, std::string(), profile()); + url, GURL(), PageTransition::RELOAD, profile()); entry->set_page_id(0); entry->set_title(ASCIIToUTF16("Title")); entry->set_content_state("state"); @@ -1496,7 +1496,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { GURL url("http://foo"); std::vector entries; NavigationEntry* entry = NavigationController::CreateNavigationEntry( - url, GURL(), PageTransition::RELOAD, std::string(), profile()); + url, GURL(), PageTransition::RELOAD, profile()); entry->set_page_id(0); entry->set_title(ASCIIToUTF16("Title")); entry->set_content_state("state"); diff --git a/content/browser/tab_contents/navigation_entry.h b/content/browser/tab_contents/navigation_entry.h index c86e75d..a43eba9 100644 --- a/content/browser/tab_contents/navigation_entry.h +++ b/content/browser/tab_contents/navigation_entry.h @@ -318,14 +318,6 @@ class NavigationEntry { return ssl_; } - // Extra headers (separated by \n) to send during the request. - void set_extra_headers(const std::string& extra_headers) { - extra_headers_ = extra_headers; - } - const std::string& extra_headers() const { - return extra_headers_; - } - // Page-related helpers ------------------------------------------------------ // Returns the title to be displayed on the tab. This could be the title of @@ -425,11 +417,8 @@ class NavigationEntry { bool has_post_data_; RestoreType restore_type_; - // This member is not persisted with sesssion restore. - std::string extra_headers_; - // This is a cached version of the result of GetTitleForDisplay. It prevents - // us from having to do URL formatting on the URL every time the title is + // us from having to do URL formatting on the URL evey time the title is // displayed. When the URL, virtual URL, or title is set, this should be // cleared to force a refresh. mutable string16 cached_display_title_; diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index f87c69e..9271d1b 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -140,7 +140,6 @@ ViewMsg_Navigate_Type::Value GetNavigationType( void MakeNavigateParams(const NavigationEntry& entry, const NavigationController& controller, - TabContentsDelegate* delegate, NavigationController::ReloadType reload_type, ViewMsg_Navigate_Params* params) { params->page_id = entry.page_id(); @@ -154,10 +153,6 @@ void MakeNavigateParams(const NavigationEntry& entry, params->navigation_type = GetNavigationType(controller.browser_context(), entry, reload_type); params->request_time = base::Time::Now(); - params->extra_headers = entry.extra_headers(); - - if (delegate) - delegate->AddNavigationHeaders(params->url, ¶ms->extra_headers); } } // namespace @@ -592,8 +587,11 @@ bool TabContents::NavigateToEntry( // Navigate in the desired RenderViewHost. ViewMsg_Navigate_Params navigate_params; - MakeNavigateParams(entry, controller_, delegate_, reload_type, - &navigate_params); + MakeNavigateParams(entry, controller_, reload_type, &navigate_params); + if (delegate_) { + navigate_params.extra_headers = + delegate_->GetNavigationHeaders(navigate_params.url); + } dest_render_view_host->Navigate(navigate_params); if (entry.page_id() == -1) { diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc index 7247a7a..a6bdb98 100644 --- a/content/browser/tab_contents/tab_contents_delegate.cc +++ b/content/browser/tab_contents/tab_contents_delegate.cc @@ -34,8 +34,8 @@ void TabContentsDelegate::NavigationStateChanged(const TabContents* source, unsigned changed_flags) { } -void TabContentsDelegate::AddNavigationHeaders(const GURL& url, - std::string* headers) { +std::string TabContentsDelegate::GetNavigationHeaders(const GURL& url) { + return std::string(); } void TabContentsDelegate::AddNewContents(TabContents* source, diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h index b1f0d52..9638775 100644 --- a/content/browser/tab_contents/tab_contents_delegate.h +++ b/content/browser/tab_contents/tab_contents_delegate.h @@ -75,9 +75,9 @@ class TabContentsDelegate { virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags); - // Adds the navigation request headers to |headers|. Use + // Returns the set of headers to add to the navigation request. Use // net::HttpUtil::AppendHeaderIfMissing to build the set of headers. - virtual void AddNavigationHeaders(const GURL& url, std::string* headers); + virtual std::string GetNavigationHeaders(const GURL& url); // Creates a new tab with the already-created TabContents 'new_contents'. // The window for the added contents should be reparented correctly when this diff --git a/content/browser/tab_contents/tab_contents_delegate_unittest.cc b/content/browser/tab_contents/tab_contents_delegate_unittest.cc index fab9edb..55a25b8 100644 --- a/content/browser/tab_contents/tab_contents_delegate_unittest.cc +++ b/content/browser/tab_contents/tab_contents_delegate_unittest.cc @@ -33,33 +33,31 @@ class MockTabContentsDelegate : public TabContentsDelegate { } virtual void NavigationStateChanged(const TabContents* source, - unsigned changed_flags) OVERRIDE {} + unsigned changed_flags) {} - virtual void AddNavigationHeaders( - const GURL& url, std::string* headers) OVERRIDE { + virtual std::string GetNavigationHeaders(const GURL& url) { + return ""; } virtual void AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, - bool user_gesture) OVERRIDE {} + bool user_gesture) {} - virtual void ActivateContents(TabContents* contents) OVERRIDE {} + virtual void ActivateContents(TabContents* contents) {} - virtual void DeactivateContents(TabContents* contents) OVERRIDE {} + virtual void DeactivateContents(TabContents* contents) {} - virtual void LoadingStateChanged(TabContents* source) OVERRIDE {} + virtual void LoadingStateChanged(TabContents* source) {} - virtual void LoadProgressChanged(double progress) OVERRIDE {} + virtual void LoadProgressChanged(double progress) {} - virtual void CloseContents(TabContents* source) OVERRIDE {} + virtual void CloseContents(TabContents* source) {} - virtual void MoveContents(TabContents* source, - const gfx::Rect& pos) OVERRIDE { - } + virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} - virtual void UpdateTargetURL(TabContents* source, const GURL& url) OVERRIDE {} + virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} }; TEST(TabContentsDelegateTest, UnregisterInDestructor) { diff --git a/content/common/content_notification_types.h b/content/common/content_notification_types.h index 144ebb7..14e72f7 100644 --- a/content/common/content_notification_types.h +++ b/content/common/content_notification_types.h @@ -43,8 +43,8 @@ enum NotificationType { // // This notification is called after the pending entry is created, but // before we actually try to navigate. The source will be the - // NavigationController that owns the pending entry, and the details - // will be a NavigationEntry. + // NavigationController that owns the pending entry, and there are no + // details. NOTIFICATION_NAV_ENTRY_PENDING, // A new non-pending navigation entry has been created. This will diff --git a/content/common/page_transition_types.h b/content/common/page_transition_types.h index 1bd6ec9..357b433 100644 --- a/content/common/page_transition_types.h +++ b/content/common/page_transition_types.h @@ -108,9 +108,6 @@ class PageTransition { // User used the address bar to trigger this navigation. FROM_ADDRESS_BAR = 0x02000000, - // User is navigating to the home page. - HOME_PAGE = 0x04000000, - // The beginning of a navigation chain. CHAIN_START = 0x10000000, -- cgit v1.1