summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 03:36:47 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 03:36:47 +0000
commit6c6b02dcf61fa8d344a3b1768b5e9610c17468c1 (patch)
tree1d62f8bc14264eace0e5bf489edb3634142d7df4
parent2bf646e71e7f103b1e761a68284462849cba7bcb (diff)
downloadchromium_src-6c6b02dcf61fa8d344a3b1768b5e9610c17468c1.zip
chromium_src-6c6b02dcf61fa8d344a3b1768b5e9610c17468c1.tar.gz
chromium_src-6c6b02dcf61fa8d344a3b1768b5e9610c17468c1.tar.bz2
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. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=99283 Review URL: http://codereview.chromium.org/7791029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99309 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_main.cc21
-rw-r--r--chrome/browser/instant/instant_loader.cc12
-rw-r--r--chrome/browser/rlz/rlz.cc3
-rw-r--r--chrome/browser/rlz/rlz.h5
-rw-r--r--chrome/browser/rlz/rlz_unittest.cc3
-rw-r--r--chrome/browser/sessions/session_types.cc2
-rw-r--r--chrome/browser/ui/browser.cc15
-rw-r--r--chrome/browser/ui/browser.h3
-rw-r--r--chrome/browser/ui/browser_navigator.cc64
-rw-r--r--chrome/common/pref_names.cc3
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--content/browser/tab_contents/navigation_controller.cc15
-rw-r--r--content/browser/tab_contents/navigation_controller.h11
-rw-r--r--content/browser/tab_contents/navigation_controller_unittest.cc4
-rw-r--r--content/browser/tab_contents/navigation_entry.h13
-rw-r--r--content/browser/tab_contents/tab_contents.cc12
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.cc4
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.h4
-rw-r--r--content/browser/tab_contents/tab_contents_delegate_unittest.cc24
-rw-r--r--content/common/content_notification_types.h4
-rw-r--r--content/common/page_transition_types.h3
21 files changed, 174 insertions, 52 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index d717f9e..50b7802 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -44,6 +44,7 @@
#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"
@@ -1880,11 +1881,23 @@ int BrowserMain(const MainFunctionParams& parameters) {
}
}
}
- // 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.
+
+ 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;
+ }
+
RLZTracker::InitRlzDelayed(is_first_run, master_prefs.ping_delay,
- google_search_default, false);
+ 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);
+
#endif // GOOGLE_CHROME_BUILD
#endif // OS_WIN
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index 1a71176..8b28bc0 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -181,7 +181,8 @@ class InstantLoader::TabContentsDelegateImpl
// TabContentsDelegate:
virtual void NavigationStateChanged(const TabContents* source,
unsigned changed_flags) OVERRIDE;
- virtual std::string GetNavigationHeaders(const GURL& url) OVERRIDE;
+ virtual void AddNavigationHeaders(const GURL& url,
+ std::string* headers) OVERRIDE;
virtual bool ShouldFocusConstrainedWindow() OVERRIDE;
virtual void WillShowConstrainedWindow(TabContents* source) OVERRIDE;
virtual bool ShouldSuppressDialogs() OVERRIDE;
@@ -412,12 +413,11 @@ void InstantLoader::TabContentsDelegateImpl::NavigationStateChanged(
}
}
-std::string InstantLoader::TabContentsDelegateImpl::GetNavigationHeaders(
- const GURL& url) {
- std::string header;
+void InstantLoader::TabContentsDelegateImpl::AddNavigationHeaders(
+ const GURL& url,
+ std::string* headers) {
net::HttpUtil::AppendHeaderIfMissing(kPreviewHeader, kPreviewHeaderValue,
- &header);
- return header;
+ headers);
}
bool InstantLoader::TabContentsDelegateImpl::ShouldFocusConstrainedWindow() {
diff --git a/chrome/browser/rlz/rlz.cc b/chrome/browser/rlz/rlz.cc
index 1af7d7b..ea208a3 100644
--- a/chrome/browser/rlz/rlz.cc
+++ b/chrome/browser/rlz/rlz.cc
@@ -196,6 +196,7 @@ bool RLZTracker::Init(bool first_run, int delay, bool google_default_search,
NotificationService::AllSources());
ScheduleDelayedInit(delay);
+
return true;
}
@@ -295,7 +296,7 @@ void RLZTracker::Observe(int type,
case content::NOTIFICATION_NAV_ENTRY_PENDING: {
const NavigationEntry* entry = Details<NavigationEntry>(details).ptr();
if (entry != NULL &&
- ((entry->transition_type() & RLZ_PAGETRANSITION_HOME_PAGE) != 0)) {
+ ((entry->transition_type() & 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 cbbec70..c335cbd 100644
--- a/chrome/browser/rlz/rlz.h
+++ b/chrome/browser/rlz/rlz.h
@@ -66,11 +66,6 @@ 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 96816a4..3d1d860 100644
--- a/chrome/browser/rlz/rlz_unittest.cc
+++ b/chrome/browser/rlz/rlz_unittest.cc
@@ -80,7 +80,6 @@ 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);
@@ -204,7 +203,7 @@ void RlzLibTest::SimulateOmniboxUsage() {
void RlzLibTest::SimulateHomepageUsage() {
NavigationEntry entry(NULL, 0, GURL(), GURL(), string16(),
- TestRLZTracker::RLZ_PAGETRANSITION_HOME_PAGE);
+ PageTransition::HOME_PAGE);
tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING,
NotificationService::AllSources(),
Details<NavigationEntry>(&entry));
diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc
index c1f1c28..086eb3e 100644
--- a/chrome/browser/sessions/session_types.cc
+++ b/chrome/browser/sessions/session_types.cc
@@ -66,6 +66,8 @@ 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 0775e37..764c3b6 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -314,6 +314,7 @@ 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,7 +1470,8 @@ void Browser::ReloadInternal(WindowOpenDisposition disposition,
void Browser::Home(WindowOpenDisposition disposition) {
UserMetrics::RecordAction(UserMetricsAction("Home"));
- OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK);
+ OpenURL(GetHomePage(), GURL(), disposition,
+ PageTransition::AUTO_BOOKMARK | PageTransition::HOME_PAGE);
}
void Browser::OpenCurrentURL() {
@@ -2239,6 +2241,9 @@ 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);
@@ -4034,6 +4039,9 @@ void Browser::Observe(int type,
UpdateCommandsForBookmarkEditing();
} else if (pref_name == prefs::kEnableBookmarkBar) {
UpdateCommandsForBookmarkBar();
+ } else if (pref_name == prefs::kHomePage) {
+ PrefService* pref_service = Source<PrefService>(source).ptr();
+ MarkHomePageAsChanged(pref_service);
} else if (pref_name == prefs::kAllowFileSelectionDialogs) {
UpdateSaveAsState(GetContentRestrictionsForSelectedTab());
UpdateOpenFileState();
@@ -4486,6 +4494,11 @@ 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 f83843e..b131f12 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -1042,6 +1042,9 @@ 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 cbc89ac..f597016 100644
--- a/chrome/browser/ui/browser_navigator.cc
+++ b/chrome/browser/ui/browser_navigator.cc
@@ -7,10 +7,15 @@
#include <algorithm>
#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"
@@ -21,10 +26,12 @@
#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 {
@@ -275,6 +282,39 @@ class ScopedTargetContentsOwner {
DISALLOW_COPY_AND_ASSIGN(ScopedTargetContentsOwner);
};
+void InitializeExtraHeaders(browser::NavigateParams* params,
+ Profile* profile,
+ std::string* extra_headers) {
+#if defined(OS_WIN)
+#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
+#endif
+}
+
} // namespace
namespace browser {
@@ -377,14 +417,22 @@ 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 = params->url.is_empty() ? params->browser->GetHomePage()
- : params->url;
+ GURL url;
+ if (params->url.is_empty()) {
+ url = params->browser->GetHomePage();
+ params->transition |= PageTransition::HOME_PAGE;
+ } else {
+ url = params->url;
+ }
+
if (params->disposition != CURRENT_TAB) {
TabContents* source_contents = params->source_contents ?
params->source_contents->tab_contents() : NULL;
@@ -421,12 +469,15 @@ 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().LoadURL(url, params->referrer,
- params->transition);
+ params->target_contents->controller().LoadURLWithHeaders(
+ url, params->referrer, params->transition, extra_headers);
}
} else {
// |target_contents| was specified non-NULL, and so we assume it has already
@@ -473,8 +524,9 @@ void Navigate(NavigateParams* params) {
target->controller().Reload(true);
} else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE &&
target->GetURL() != params->url) {
- target->controller().LoadURL(
- params->url, params->referrer, params->transition);
+ InitializeExtraHeaders(params, NULL, &extra_headers);
+ target->controller().LoadURLWithHeaders(
+ params->url, params->referrer, params->transition, extra_headers);
}
// 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 bf3847a..e17e841 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -24,6 +24,9 @@ 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 cd68ad8..e8d347c 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -19,6 +19,7 @@ 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 85780cd..1ee7492 100644
--- a/content/browser/tab_contents/navigation_controller.cc
+++ b/content/browser/tab_contents/navigation_controller.cc
@@ -221,6 +221,7 @@ 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
@@ -242,6 +243,7 @@ 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;
}
@@ -273,7 +275,7 @@ void NavigationController::LoadEntry(NavigationEntry* entry) {
NotificationService::current()->Notify(
content::NOTIFICATION_NAV_ENTRY_PENDING,
Source<NavigationController>(this),
- NotificationService::NoDetails());
+ Details<NavigationEntry>(entry));
NavigateToPendingEntry(NO_RELOAD);
}
@@ -483,10 +485,21 @@ 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 c7d9d03..a410c4d 100644
--- a/content/browser/tab_contents/navigation_controller.h
+++ b/content/browser/tab_contents/navigation_controller.h
@@ -176,6 +176,13 @@ 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();
@@ -327,11 +334,13 @@ 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.
+ // Used when navigating to a new URL using LoadURL. Extra headers are
+ // separated by \n.
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 0830650..fbb9b01 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<NavigationEntry*> entries;
NavigationEntry* entry = NavigationController::CreateNavigationEntry(
- url, GURL(), PageTransition::RELOAD, profile());
+ url, GURL(), PageTransition::RELOAD, std::string(), 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<NavigationEntry*> entries;
NavigationEntry* entry = NavigationController::CreateNavigationEntry(
- url, GURL(), PageTransition::RELOAD, profile());
+ url, GURL(), PageTransition::RELOAD, std::string(), 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 a43eba9..c86e75d 100644
--- a/content/browser/tab_contents/navigation_entry.h
+++ b/content/browser/tab_contents/navigation_entry.h
@@ -318,6 +318,14 @@ 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
@@ -417,8 +425,11 @@ 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 evey time the title is
+ // us from having to do URL formatting on the URL every 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 9271d1b..f87c69e 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -140,6 +140,7 @@ 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();
@@ -153,6 +154,10 @@ 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, &params->extra_headers);
}
} // namespace
@@ -587,11 +592,8 @@ bool TabContents::NavigateToEntry(
// Navigate in the desired RenderViewHost.
ViewMsg_Navigate_Params navigate_params;
- MakeNavigateParams(entry, controller_, reload_type, &navigate_params);
- if (delegate_) {
- navigate_params.extra_headers =
- delegate_->GetNavigationHeaders(navigate_params.url);
- }
+ MakeNavigateParams(entry, controller_, delegate_, reload_type,
+ &navigate_params);
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 a6bdb98..7247a7a 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) {
}
-std::string TabContentsDelegate::GetNavigationHeaders(const GURL& url) {
- return std::string();
+void TabContentsDelegate::AddNavigationHeaders(const GURL& url,
+ std::string* headers) {
}
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 9638775..b1f0d52 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);
- // Returns the set of headers to add to the navigation request. Use
+ // Adds the navigation request headers to |headers|. Use
// net::HttpUtil::AppendHeaderIfMissing to build the set of headers.
- virtual std::string GetNavigationHeaders(const GURL& url);
+ virtual void AddNavigationHeaders(const GURL& url, std::string* headers);
// 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 55a25b8..fab9edb 100644
--- a/content/browser/tab_contents/tab_contents_delegate_unittest.cc
+++ b/content/browser/tab_contents/tab_contents_delegate_unittest.cc
@@ -33,31 +33,33 @@ class MockTabContentsDelegate : public TabContentsDelegate {
}
virtual void NavigationStateChanged(const TabContents* source,
- unsigned changed_flags) {}
+ unsigned changed_flags) OVERRIDE {}
- virtual std::string GetNavigationHeaders(const GURL& url) {
- return "";
+ virtual void AddNavigationHeaders(
+ const GURL& url, std::string* headers) OVERRIDE {
}
virtual void AddNewContents(TabContents* source,
TabContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_pos,
- bool user_gesture) {}
+ bool user_gesture) OVERRIDE {}
- virtual void ActivateContents(TabContents* contents) {}
+ virtual void ActivateContents(TabContents* contents) OVERRIDE {}
- virtual void DeactivateContents(TabContents* contents) {}
+ virtual void DeactivateContents(TabContents* contents) OVERRIDE {}
- virtual void LoadingStateChanged(TabContents* source) {}
+ virtual void LoadingStateChanged(TabContents* source) OVERRIDE {}
- virtual void LoadProgressChanged(double progress) {}
+ virtual void LoadProgressChanged(double progress) OVERRIDE {}
- virtual void CloseContents(TabContents* source) {}
+ virtual void CloseContents(TabContents* source) OVERRIDE {}
- virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {}
+ virtual void MoveContents(TabContents* source,
+ const gfx::Rect& pos) OVERRIDE {
+ }
- virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
+ virtual void UpdateTargetURL(TabContents* source, const GURL& url) OVERRIDE {}
};
TEST(TabContentsDelegateTest, UnregisterInDestructor) {
diff --git a/content/common/content_notification_types.h b/content/common/content_notification_types.h
index 14e72f7..144ebb7 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 there are no
- // details.
+ // NavigationController that owns the pending entry, and the details
+ // will be a NavigationEntry.
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 357b433..1bd6ec9 100644
--- a/content/common/page_transition_types.h
+++ b/content/common/page_transition_types.h
@@ -108,6 +108,9 @@ 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,