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 |
| 35 // resource |
35 // number for the title of the page. If we don't have a specialized title, | 36 // number for the title of the page. If we don't have a specialized title, |
36 // returns -1. | 37 // returns -1. |
37 int StringForChromeHost(const GURL& url) { | 38 int StringForChromeHost(const GURL& url) { |
38 DCHECK(url.is_empty() || url.SchemeIs(content::kChromeUIScheme)); | 39 DCHECK(url.is_empty() || url.SchemeIs(content::kChromeUIScheme)); |
39 | 40 |
40 if (url.is_empty()) | 41 if (url.is_empty()) |
41 return IDS_NEW_TAB_TITLE; | 42 return IDS_NEW_TAB_TITLE; |
42 | 43 |
43 // TODO(gbillock): Just get the page title and special case exceptions? | 44 // TODO(gbillock): Just get the page title and special case exceptions? |
44 std::string host = url.host(); | 45 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, | 171 base::string16 OriginChip::LabelFromURLForProfile(const GURL& provided_url, |
171 Profile* profile) { | 172 Profile* profile) { |
172 // First, strip view-source: if it appears. Note that GetContent removes | 173 // First, strip view-source: if it appears. Note that GetContent removes |
173 // "view-source:" but leaves the original scheme (http, https, ftp, etc). | 174 // "view-source:" but leaves the original scheme (http, https, ftp, etc). |
174 GURL url(provided_url); | 175 GURL url(provided_url); |
175 if (url.SchemeIs(content::kViewSourceScheme)) | 176 if (url.SchemeIs(content::kViewSourceScheme)) |
176 url = GURL(url.GetContent()); | 177 url = GURL(url.GetContent()); |
177 | 178 |
178 // About scheme pages. Currently all about: URLs other than about:blank | 179 // About scheme pages. Currently all about: URLs other than about:blank |
179 // redirect to chrome: URLs, so this only affects about:blank. | 180 // redirect to chrome: URLs, so this only affects about:blank. |
180 if (url.SchemeIs(content::kAboutScheme)) | 181 if (url.SchemeIs(url::kAboutScheme)) |
181 return base::UTF8ToUTF16(url.spec()); | 182 return base::UTF8ToUTF16(url.spec()); |
182 | 183 |
183 // Chrome built-in pages. | 184 // Chrome built-in pages. |
184 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { | 185 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { |
185 int string_ref = StringForChromeHost(url); | 186 int string_ref = StringForChromeHost(url); |
186 return l10n_util::GetStringUTF16( | 187 return l10n_util::GetStringUTF16( |
187 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); | 188 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); |
188 } | 189 } |
189 | 190 |
190 // For chrome-extension URLs, return the extension name. | 191 // For chrome-extension URLs, return the extension name. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 248 |
248 #if defined(OS_CHROMEOS) | 249 #if defined(OS_CHROMEOS) |
249 if (url.SchemeIs(chrome::kCrosScheme) || | 250 if (url.SchemeIs(chrome::kCrosScheme) || |
250 url.SchemeIs(chrome::kDriveScheme)) | 251 url.SchemeIs(chrome::kDriveScheme)) |
251 return base::UTF8ToUTF16(url.spec()); | 252 return base::UTF8ToUTF16(url.spec()); |
252 #endif | 253 #endif |
253 | 254 |
254 // If all else fails, return the hostname. | 255 // If all else fails, return the hostname. |
255 return base::UTF8ToUTF16(url.host()); | 256 return base::UTF8ToUTF16(url.host()); |
256 } | 257 } |
OLD | NEW |