summaryrefslogtreecommitdiffstats
path: root/content/browser/tab_contents
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 02:01:38 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-02 02:01:38 +0000
commita1be1f83509b1fcf1310bd030572202dc7c44058 (patch)
treead807f8d363cc4271c92693bf0db92ae597d1e28 /content/browser/tab_contents
parent400d323d53525a13fbfc47efa8a95c4b13cbccb9 (diff)
downloadchromium_src-a1be1f83509b1fcf1310bd030572202dc7c44058.zip
chromium_src-a1be1f83509b1fcf1310bd030572202dc7c44058.tar.gz
chromium_src-a1be1f83509b1fcf1310bd030572202dc7c44058.tar.bz2
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
Diffstat (limited to 'content/browser/tab_contents')
-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
8 files changed, 25 insertions, 62 deletions
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<NavigationController>(this),
- Details<NavigationEntry>(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<NavigationEntry*> 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<NavigationEntry*> 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, &params->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) {