| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/toolbar/origin_chip_info.h" | 5 #include "chrome/browser/ui/toolbar/origin_chip_info.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_icon_image.h" | 10 #include "chrome/browser/extensions/extension_icon_image.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
| 25 #include "grit/components_strings.h" | 25 #include "grit/components_strings.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 28 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // For selected kChromeUIScheme and kAboutScheme, return the string resource | 34 // For selected kChromeUIScheme and url::kAboutScheme, return the string resourc
e |
| 35 // number for the title of the page. If we don't have a specialized title, | 35 // number for the title of the page. If we don't have a specialized title, |
| 36 // returns -1. | 36 // returns -1. |
| 37 int StringForChromeHost(const GURL& url) { | 37 int StringForChromeHost(const GURL& url) { |
| 38 DCHECK(url.is_empty() || url.SchemeIs(content::kChromeUIScheme)); | 38 DCHECK(url.is_empty() || url.SchemeIs(content::kChromeUIScheme)); |
| 39 | 39 |
| 40 if (url.is_empty()) | 40 if (url.is_empty()) |
| 41 return IDS_NEW_TAB_TITLE; | 41 return IDS_NEW_TAB_TITLE; |
| 42 | 42 |
| 43 // TODO(gbillock): Just get the page title and special case exceptions? | 43 // TODO(gbillock): Just get the page title and special case exceptions? |
| 44 std::string host = url.host(); | 44 std::string host = url.host(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 base::string16 OriginChip::LabelFromURLForProfile(const GURL& provided_url, | 170 base::string16 OriginChip::LabelFromURLForProfile(const GURL& provided_url, |
| 171 Profile* profile) { | 171 Profile* profile) { |
| 172 // First, strip view-source: if it appears. Note that GetContent removes | 172 // First, strip view-source: if it appears. Note that GetContent removes |
| 173 // "view-source:" but leaves the original scheme (http, https, ftp, etc). | 173 // "view-source:" but leaves the original scheme (http, https, ftp, etc). |
| 174 GURL url(provided_url); | 174 GURL url(provided_url); |
| 175 if (url.SchemeIs(content::kViewSourceScheme)) | 175 if (url.SchemeIs(content::kViewSourceScheme)) |
| 176 url = GURL(url.GetContent()); | 176 url = GURL(url.GetContent()); |
| 177 | 177 |
| 178 // About scheme pages. Currently all about: URLs other than about:blank | 178 // About scheme pages. Currently all about: URLs other than about:blank |
| 179 // redirect to chrome: URLs, so this only affects about:blank. | 179 // redirect to chrome: URLs, so this only affects about:blank. |
| 180 if (url.SchemeIs(content::kAboutScheme)) | 180 if (url.SchemeIs(url::kAboutScheme)) |
| 181 return base::UTF8ToUTF16(url.spec()); | 181 return base::UTF8ToUTF16(url.spec()); |
| 182 | 182 |
| 183 // Chrome built-in pages. | 183 // Chrome built-in pages. |
| 184 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { | 184 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { |
| 185 int string_ref = StringForChromeHost(url); | 185 int string_ref = StringForChromeHost(url); |
| 186 return l10n_util::GetStringUTF16( | 186 return l10n_util::GetStringUTF16( |
| 187 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); | 187 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); |
| 188 } | 188 } |
| 189 | 189 |
| 190 // For chrome-extension URLs, return the extension name. | 190 // For chrome-extension URLs, return the extension name. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 #if defined(OS_CHROMEOS) | 248 #if defined(OS_CHROMEOS) |
| 249 if (url.SchemeIs(chrome::kCrosScheme) || | 249 if (url.SchemeIs(chrome::kCrosScheme) || |
| 250 url.SchemeIs(chrome::kDriveScheme)) | 250 url.SchemeIs(chrome::kDriveScheme)) |
| 251 return base::UTF8ToUTF16(url.spec()); | 251 return base::UTF8ToUTF16(url.spec()); |
| 252 #endif | 252 #endif |
| 253 | 253 |
| 254 // If all else fails, return the hostname. | 254 // If all else fails, return the hostname. |
| 255 return base::UTF8ToUTF16(url.host()); | 255 return base::UTF8ToUTF16(url.host()); |
| 256 } | 256 } |
| OLD | NEW |