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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 base::string16 OriginChip::LabelFromURLForProfile(const GURL& provided_url, | 160 base::string16 OriginChip::LabelFromURLForProfile(const GURL& provided_url, |
161 Profile* profile) { | 161 Profile* profile) { |
162 // First, strip view-source: if it appears. Note that GetContent removes | 162 // First, strip view-source: if it appears. Note that GetContent removes |
163 // "view-source:" but leaves the original scheme (http, https, ftp, etc). | 163 // "view-source:" but leaves the original scheme (http, https, ftp, etc). |
164 GURL url(provided_url); | 164 GURL url(provided_url); |
165 if (url.SchemeIs(content::kViewSourceScheme)) | 165 if (url.SchemeIs(content::kViewSourceScheme)) |
166 url = GURL(url.GetContent()); | 166 url = GURL(url.GetContent()); |
167 | 167 |
168 // About scheme pages. Currently all about: URLs other than about:blank | 168 // About scheme pages. Currently all about: URLs other than about:blank |
169 // redirect to chrome: URLs, so this only affects about:blank. | 169 // redirect to chrome: URLs, so this only affects about:blank. |
170 if (url.SchemeIs(chrome::kAboutScheme)) | 170 if (url.SchemeIs(content::kAboutScheme)) |
171 return base::UTF8ToUTF16(url.spec()); | 171 return base::UTF8ToUTF16(url.spec()); |
172 | 172 |
173 // Chrome built-in pages. | 173 // Chrome built-in pages. |
174 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { | 174 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { |
175 int string_ref = StringForChromeHost(url); | 175 int string_ref = StringForChromeHost(url); |
176 return l10n_util::GetStringUTF16( | 176 return l10n_util::GetStringUTF16( |
177 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); | 177 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); |
178 } | 178 } |
179 | 179 |
180 // For chrome-extension URLs, return the extension name. | 180 // For chrome-extension URLs, return the extension name. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 #if defined(OS_CHROMEOS) | 238 #if defined(OS_CHROMEOS) |
239 if (url.SchemeIs(chrome::kCrosScheme) || | 239 if (url.SchemeIs(chrome::kCrosScheme) || |
240 url.SchemeIs(chrome::kDriveScheme)) | 240 url.SchemeIs(chrome::kDriveScheme)) |
241 return base::UTF8ToUTF16(url.spec()); | 241 return base::UTF8ToUTF16(url.spec()); |
242 #endif | 242 #endif |
243 | 243 |
244 // If all else fails, return the hostname. | 244 // If all else fails, return the hostname. |
245 return base::UTF8ToUTF16(url.host()); | 245 return base::UTF8ToUTF16(url.host()); |
246 } | 246 } |
OLD | NEW |