Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7975)

Unified Diff: chrome/browser/ui/toolbar/toolbar_model_impl.cc

Issue 424383002: Experiment with displaying origins in the Omnibox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/toolbar_model_impl.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_model_impl.cc b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
index 1d18458e6dd52ab52ff690b69e98d18f9e8be3b6..8bcee75700f1e8fd7ed85d546090468bf4e858dd 100644
--- a/chrome/browser/ui/toolbar/toolbar_model_impl.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
@@ -215,6 +215,37 @@ base::string16 ToolbarModelImpl::GetEVCertName() const {
base::UTF8ToUTF16(cert->subject().country_name));
}
+base::string16 ToolbarModelImpl::GetOriginDisplayName() const {
+ std::string languages; // Empty if we don't have a |navigation_controller|.
+ Profile* profile = GetProfile();
+ if (profile)
+ languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
+
+ GURL url(GetURL());
+ std::string displayed_origin;
+
+ if ("https" == url.scheme() || "http" == url.scheme()) {
+ displayed_origin = url.host();
+ if (url.port().length() > 0 &&
+ (("https" == url.scheme() && "443" != url.port()) ||
+ ("http" == url.scheme() && "80" != url.port()))) {
+ displayed_origin += ":" + url.port();
+ }
+ } else if ("file" == url.scheme()) {
+ displayed_origin = url.path();
+ } else {
+ // TODO(palmer): This is inefficient because we are just going to
+ // convert it back into a GURL for net::FormatUrl. This function gets
+ // called surprisingly often so it should be fast and clean.
+ displayed_origin = url.GetOrigin().spec();
+ }
+
+ // TODO(palmer): This is just testing:
+ return base::ASCIIToUTF16(displayed_origin);
+
+ //return net::FormatUrl(GURL(displayed_origin), languages);
+}
+
bool ToolbarModelImpl::ShouldDisplayURL() const {
// Note: The order here is important.
// - The WebUI test must come before the extension scheme test because there
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_model_impl.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698