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

Side by Side Diff: chrome/browser/ui/toolbar/origin_chip_info.cc

Issue 273193004: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing files. Created 6 years, 6 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 unified diff | Download patch
OLDNEW
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // For chrome-extension URLs, return the extension name. 190 // For chrome-extension URLs, return the extension name.
191 if (url.SchemeIs(extensions::kExtensionScheme)) { 191 if (url.SchemeIs(extensions::kExtensionScheme)) {
192 ExtensionService* service = 192 ExtensionService* service =
193 extensions::ExtensionSystem::Get(profile)->extension_service(); 193 extensions::ExtensionSystem::Get(profile)->extension_service();
194 const extensions::Extension* extension = 194 const extensions::Extension* extension =
195 service->extensions()->GetExtensionOrAppByURL(url); 195 service->extensions()->GetExtensionOrAppByURL(url);
196 return extension ? 196 return extension ?
197 base::UTF8ToUTF16(extension->name()) : base::UTF8ToUTF16(url.host()); 197 base::UTF8ToUTF16(extension->name()) : base::UTF8ToUTF16(url.host());
198 } 198 }
199 199
200 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs(content::kFtpScheme)) { 200 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs(url::kFtpScheme)) {
201 // See ToolbarModelImpl::GetText(). Does not pay attention to any user 201 // See ToolbarModelImpl::GetText(). Does not pay attention to any user
202 // edits, and uses GetURL/net::FormatUrl -- We don't really care about 202 // edits, and uses GetURL/net::FormatUrl -- We don't really care about
203 // length or the autocomplete parser. 203 // length or the autocomplete parser.
204 // TODO(gbillock): This uses an algorithm very similar to GetText, which 204 // TODO(gbillock): This uses an algorithm very similar to GetText, which
205 // is probably too conservative. Try out just using a simpler mechanism of 205 // is probably too conservative. Try out just using a simpler mechanism of
206 // StripWWW() and IDNToUnicode(). 206 // StripWWW() and IDNToUnicode().
207 std::string languages; 207 std::string languages;
208 if (profile) 208 if (profile)
209 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); 209 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
210 210
(...skipping 12 matching lines...) Expand all
223 formatted = formatted.substr(4); 223 formatted = formatted.substr(4);
224 if (EndsWith(formatted, base::ASCIIToUTF16("/"), false)) 224 if (EndsWith(formatted, base::ASCIIToUTF16("/"), false))
225 formatted = formatted.substr(0, formatted.size() - 1); 225 formatted = formatted.substr(0, formatted.size() - 1);
226 return formatted; 226 return formatted;
227 } 227 }
228 228
229 // These internal-ish debugging-style schemes we don't expect users 229 // These internal-ish debugging-style schemes we don't expect users
230 // to see. In these cases, the site chip will display the first 230 // to see. In these cases, the site chip will display the first
231 // part of the full URL. 231 // part of the full URL.
232 if (url.SchemeIs(chrome::kChromeNativeScheme) || 232 if (url.SchemeIs(chrome::kChromeNativeScheme) ||
233 url.SchemeIs(content::kBlobScheme) || 233 url.SchemeIs(url::kBlobScheme) ||
234 url.SchemeIs(content::kChromeDevToolsScheme) || 234 url.SchemeIs(content::kChromeDevToolsScheme) ||
235 url.SchemeIs(content::kDataScheme) || 235 url.SchemeIs(url::kDataScheme) ||
236 url.SchemeIs(content::kFileScheme) || 236 url.SchemeIs(url::kFileScheme) ||
237 url.SchemeIs(content::kFileSystemScheme) || 237 url.SchemeIs(url::kFileSystemScheme) ||
238 url.SchemeIs(content::kGuestScheme) || 238 url.SchemeIs(content::kGuestScheme) ||
239 url.SchemeIs(content::kJavaScriptScheme) || 239 url.SchemeIs(url::kJavaScriptScheme) ||
240 url.SchemeIs(content::kMailToScheme) || 240 url.SchemeIs(url::kMailToScheme) ||
241 url.SchemeIs(content::kMetadataScheme) || 241 url.SchemeIs(content::kMetadataScheme) ||
242 url.SchemeIs(content::kSwappedOutScheme)) { 242 url.SchemeIs(content::kSwappedOutScheme)) {
243 std::string truncated_url; 243 std::string truncated_url;
244 base::TruncateUTF8ToByteSize(url.spec(), 1000, &truncated_url); 244 base::TruncateUTF8ToByteSize(url.spec(), 1000, &truncated_url);
245 return base::UTF8ToUTF16(truncated_url); 245 return base::UTF8ToUTF16(truncated_url);
246 } 246 }
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator_impl.cc ('k') | chrome/browser/web_applications/web_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698