summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-05 13:46:23 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-05 13:46:23 +0000
commit45d0ef7f291e28657d2198c6c9dd8197ee543a66 (patch)
tree84aaf7e95414adf7867f7cfa86c8927658cb0656 /chrome
parent2ad6a8d2023f51b9b521fc40594d3e7610eecad4 (diff)
downloadchromium_src-45d0ef7f291e28657d2198c6c9dd8197ee543a66.zip
chromium_src-45d0ef7f291e28657d2198c6c9dd8197ee543a66.tar.gz
chromium_src-45d0ef7f291e28657d2198c6c9dd8197ee543a66.tar.bz2
Remove use of NavigationController from NavigationEntry so NavigationEntry can be used independently.
BUG=none TEST=page titles in back/foward menu, tabs Review URL: http://codereview.chromium.org/5976015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70506 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/tab_contents/navigation_entry.cc9
-rw-r--r--chrome/browser/tab_contents/navigation_entry.h11
-rw-r--r--chrome/browser/tab_contents/navigation_entry_unittest.cc8
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc13
-rw-r--r--chrome/browser/ui/toolbar/back_forward_menu_model.cc6
5 files changed, 22 insertions, 25 deletions
diff --git a/chrome/browser/tab_contents/navigation_entry.cc b/chrome/browser/tab_contents/navigation_entry.cc
index a14fc08..d5504ba 100644
--- a/chrome/browser/tab_contents/navigation_entry.cc
+++ b/chrome/browser/tab_contents/navigation_entry.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/renderer_host/site_instance.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/common/chrome_constants.h"
-#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/app_resources.h"
#include "net/base/net_util.h"
@@ -78,7 +77,7 @@ void NavigationEntry::set_site_instance(SiteInstance* site_instance) {
}
const string16& NavigationEntry::GetTitleForDisplay(
- const NavigationController* navigation_controller) {
+ const std::string& languages) {
// Most pages have real titles. Don't even bother caching anything if this is
// the case.
if (!title_.empty())
@@ -90,12 +89,6 @@ const string16& NavigationEntry::GetTitleForDisplay(
return cached_display_title_;
// Use the virtual URL first if any, and fall back on using the real URL.
- std::string languages;
- if (navigation_controller) {
- languages = navigation_controller->profile()->GetPrefs()->
- GetString(prefs::kAcceptLanguages);
- }
-
string16 title;
std::wstring elided_title;
if (!virtual_url_.is_empty()) {
diff --git a/chrome/browser/tab_contents/navigation_entry.h b/chrome/browser/tab_contents/navigation_entry.h
index ca97e02..57d93c4 100644
--- a/chrome/browser/tab_contents/navigation_entry.h
+++ b/chrome/browser/tab_contents/navigation_entry.h
@@ -16,7 +16,6 @@
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"
-class NavigationController;
class SiteInstance;
////////////////////////////////////////////////////////////////////////////////
@@ -322,12 +321,10 @@ class NavigationEntry {
// Page-related helpers ------------------------------------------------------
// Returns the title to be displayed on the tab. This could be the title of
- // the page if it is available or the URL.
- //
- // The NavigationController corresponding to this entry must be given so we
- // can get the preferences so we can optionally format a URL for display. It
- // may be NULL if you don't need proper URL formatting (e.g. unit tests).
- const string16& GetTitleForDisplay(const NavigationController* controller);
+ // the page if it is available or the URL. |languages| is the list of
+ // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper
+ // URL formatting isn't needed (e.g., unit tests).
+ const string16& GetTitleForDisplay(const std::string& languages);
// Returns true if the current tab is in view source mode. This will be false
// if there is no navigation.
diff --git a/chrome/browser/tab_contents/navigation_entry_unittest.cc b/chrome/browser/tab_contents/navigation_entry_unittest.cc
index e28cf1c..014817c 100644
--- a/chrome/browser/tab_contents/navigation_entry_unittest.cc
+++ b/chrome/browser/tab_contents/navigation_entry_unittest.cc
@@ -53,18 +53,18 @@ TEST_F(NavigationEntryTest, NavigationEntryURLs) {
EXPECT_EQ(GURL(), entry1_.get()->url());
EXPECT_EQ(GURL(), entry1_.get()->virtual_url());
- EXPECT_TRUE(entry1_.get()->GetTitleForDisplay(NULL).empty());
+ EXPECT_TRUE(entry1_.get()->GetTitleForDisplay("").empty());
// Setting URL affects virtual_url and GetTitleForDisplay
entry1_.get()->set_url(GURL("http://www.google.com"));
EXPECT_EQ(GURL("http://www.google.com"), entry1_.get()->url());
EXPECT_EQ(GURL("http://www.google.com"), entry1_.get()->virtual_url());
EXPECT_EQ(ASCIIToUTF16("www.google.com"),
- entry1_.get()->GetTitleForDisplay(NULL));
+ entry1_.get()->GetTitleForDisplay(""));
// Title affects GetTitleForDisplay
entry1_.get()->set_title(ASCIIToUTF16("Google"));
- EXPECT_EQ(ASCIIToUTF16("Google"), entry1_.get()->GetTitleForDisplay(NULL));
+ EXPECT_EQ(ASCIIToUTF16("Google"), entry1_.get()->GetTitleForDisplay(""));
// Setting virtual_url doesn't affect URL
entry2_.get()->set_virtual_url(GURL("display:url"));
@@ -73,7 +73,7 @@ TEST_F(NavigationEntryTest, NavigationEntryURLs) {
EXPECT_EQ(GURL("display:url"), entry2_.get()->virtual_url());
// Having a title set in constructor overrides virtual URL
- EXPECT_EQ(ASCIIToUTF16("title"), entry2_.get()->GetTitleForDisplay(NULL));
+ EXPECT_EQ(ASCIIToUTF16("title"), entry2_.get()->GetTitleForDisplay(""));
// User typed URL is independent of the others
EXPECT_EQ(GURL(), entry1_.get()->user_typed_url());
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 6ab990b..698d691 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -651,9 +651,10 @@ const string16& TabContents::GetTitle() const {
// Transient entries take precedence. They are used for interstitial pages
// that are shown on top of existing pages.
NavigationEntry* entry = controller_.GetTransientEntry();
- if (entry)
- return entry->GetTitleForDisplay(&controller_);
-
+ if (entry) {
+ return entry->GetTitleForDisplay(profile()->GetPrefs()->
+ GetString(prefs::kAcceptLanguages));
+ }
DOMUI* our_dom_ui = render_manager_.pending_dom_ui() ?
render_manager_.pending_dom_ui() : render_manager_.dom_ui();
if (our_dom_ui) {
@@ -672,8 +673,10 @@ const string16& TabContents::GetTitle() const {
// keep the old page's title until the new load has committed and we get a new
// title.
entry = controller_.GetLastCommittedEntry();
- if (entry)
- return entry->GetTitleForDisplay(&controller_);
+ if (entry) {
+ return entry->GetTitleForDisplay(profile()->GetPrefs()->
+ GetString(prefs::kAcceptLanguages));
+ }
return EmptyString16();
}
diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc
index 390dce0..9874ef9 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc
@@ -14,7 +14,10 @@
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -77,7 +80,8 @@ string16 BackForwardMenuModel::GetLabelAt(int index) const {
// super long.
NavigationEntry* entry = GetNavigationEntry(index);
string16 menu_text(entry->GetTitleForDisplay(
- &GetTabContents()->controller()));
+ GetTabContents()->profile()->GetPrefs()->
+ GetString(prefs::kAcceptLanguages)));
menu_text = gfx::ElideText(menu_text, gfx::Font(), kMaxWidth, false);
for (size_t i = menu_text.find('&'); i != string16::npos;