| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/tab_contents/navigation_entry.h" | 5 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/pref_service.h" | 10 #include "chrome/browser/pref_service.h" |
| 10 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
| 11 #include "chrome/browser/renderer_host/site_instance.h" | 12 #include "chrome/browser/renderer_host/site_instance.h" |
| 12 #include "chrome/browser/tab_contents/navigation_controller.h" | 13 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 14 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 15 #include "grit/app_resources.h" | 17 #include "grit/app_resources.h" |
| 16 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 17 | 19 |
| 18 // Use this to get a new unique ID for a NavigationEntry during construction. | 20 // Use this to get a new unique ID for a NavigationEntry during construction. |
| 19 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). | 21 // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). |
| 20 static int GetUniqueID() { | 22 static int GetUniqueID() { |
| 21 static int unique_id_counter = 0; | 23 static int unique_id_counter = 0; |
| 22 return ++unique_id_counter; | 24 return ++unique_id_counter; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // cache since it's more complicated to compute. | 86 // cache since it's more complicated to compute. |
| 85 if (!cached_display_title_.empty()) | 87 if (!cached_display_title_.empty()) |
| 86 return cached_display_title_; | 88 return cached_display_title_; |
| 87 | 89 |
| 88 // Use the virtual URL first if any, and fall back on using the real URL. | 90 // Use the virtual URL first if any, and fall back on using the real URL. |
| 89 std::wstring languages; | 91 std::wstring languages; |
| 90 if (navigation_controller) { | 92 if (navigation_controller) { |
| 91 languages = navigation_controller->profile()->GetPrefs()->GetString( | 93 languages = navigation_controller->profile()->GetPrefs()->GetString( |
| 92 prefs::kAcceptLanguages); | 94 prefs::kAcceptLanguages); |
| 93 } | 95 } |
| 96 |
| 97 std::wstring title; |
| 98 std::wstring elided_title; |
| 94 if (!virtual_url_.is_empty()) { | 99 if (!virtual_url_.is_empty()) { |
| 95 cached_display_title_ = WideToUTF16Hack(net::FormatUrl( | 100 title = net::FormatUrl(virtual_url_, languages); |
| 96 virtual_url_, languages)); | |
| 97 } else if (!url_.is_empty()) { | 101 } else if (!url_.is_empty()) { |
| 98 cached_display_title_ = WideToUTF16Hack(net::FormatUrl(url_, languages)); | 102 title = net::FormatUrl(url_, languages); |
| 99 } | 103 } |
| 104 ElideString(title, chrome::kMaxTitleChars, &elided_title); |
| 105 cached_display_title_ = WideToUTF16Hack(elided_title); |
| 100 return cached_display_title_; | 106 return cached_display_title_; |
| 101 } | 107 } |
| 102 | 108 |
| 103 bool NavigationEntry::IsViewSourceMode() const { | 109 bool NavigationEntry::IsViewSourceMode() const { |
| 104 return virtual_url_.SchemeIs(chrome::kViewSourceScheme); | 110 return virtual_url_.SchemeIs(chrome::kViewSourceScheme); |
| 105 } | 111 } |
| OLD | NEW |