| 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/location_bar/origin_chip_info.h" | 5 #include "chrome/browser/ui/location_bar/origin_chip_info.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | |
| 13 #include "chrome/browser/extensions/extension_util.h" | 12 #include "chrome/browser/extensions/extension_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/safe_browsing/client_side_detection_host.h" | 14 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
| 16 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" |
| 17 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 16 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 18 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 21 #include "chrome/grit/chromium_strings.h" | 20 #include "chrome/grit/chromium_strings.h" |
| 22 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
| 23 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 24 #include "extensions/browser/extension_icon_image.h" | 23 #include "extensions/browser/extension_icon_image.h" |
| 25 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_registry.h" |
| 26 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
| 27 #include "extensions/common/manifest_handlers/icons_handler.h" | 26 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 28 #include "grit/components_strings.h" | 27 #include "grit/components_strings.h" |
| 29 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 30 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 33 | 32 |
| 34 namespace { | 33 namespace { |
| 35 | 34 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 label_ = OriginChip::LabelFromURLForProfile(displayed_url, profile_); | 115 label_ = OriginChip::LabelFromURLForProfile(displayed_url, profile_); |
| 117 if (security_level_ == ToolbarModel::EV_SECURE) { | 116 if (security_level_ == ToolbarModel::EV_SECURE) { |
| 118 label_ = l10n_util::GetStringFUTF16(IDS_SITE_CHIP_EV_SSL_LABEL, | 117 label_ = l10n_util::GetStringFUTF16(IDS_SITE_CHIP_EV_SSL_LABEL, |
| 119 toolbar_model->GetEVCertName(), | 118 toolbar_model->GetEVCertName(), |
| 120 label_); | 119 label_); |
| 121 } | 120 } |
| 122 | 121 |
| 123 | 122 |
| 124 if (displayed_url_.SchemeIs(extensions::kExtensionScheme)) { | 123 if (displayed_url_.SchemeIs(extensions::kExtensionScheme)) { |
| 125 const extensions::Extension* extension = | 124 const extensions::Extension* extension = |
| 126 extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 125 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 127 extensions()->GetExtensionOrAppByURL(displayed_url_); | 126 displayed_url_.host(), extensions::ExtensionRegistry::ENABLED); |
| 128 | 127 |
| 129 if (extension) { | 128 if (extension) { |
| 130 icon_ = IDR_EXTENSIONS_FAVICON; | 129 icon_ = IDR_EXTENSIONS_FAVICON; |
| 131 extension_icon_image_.reset( | 130 extension_icon_image_.reset( |
| 132 new extensions::IconImage(profile_, | 131 new extensions::IconImage(profile_, |
| 133 extension, | 132 extension, |
| 134 extensions::IconsInfo::GetIcons(extension), | 133 extensions::IconsInfo::GetIcons(extension), |
| 135 extension_misc::EXTENSION_ICON_BITTY, | 134 extension_misc::EXTENSION_ICON_BITTY, |
| 136 extensions::util::GetDefaultAppIcon(), | 135 extensions::util::GetDefaultAppIcon(), |
| 137 owner_)); | 136 owner_)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 189 |
| 191 // Chrome built-in pages. | 190 // Chrome built-in pages. |
| 192 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { | 191 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { |
| 193 int string_ref = StringForChromeHost(url); | 192 int string_ref = StringForChromeHost(url); |
| 194 return l10n_util::GetStringUTF16( | 193 return l10n_util::GetStringUTF16( |
| 195 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); | 194 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); |
| 196 } | 195 } |
| 197 | 196 |
| 198 // For chrome-extension URLs, return the extension name. | 197 // For chrome-extension URLs, return the extension name. |
| 199 if (url.SchemeIs(extensions::kExtensionScheme)) { | 198 if (url.SchemeIs(extensions::kExtensionScheme)) { |
| 200 ExtensionService* service = | |
| 201 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
| 202 const extensions::Extension* extension = | 199 const extensions::Extension* extension = |
| 203 service->extensions()->GetExtensionOrAppByURL(url); | 200 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
| 201 url.host(), extensions::ExtensionRegistry::ENABLED); |
| 204 return extension ? | 202 return extension ? |
| 205 base::UTF8ToUTF16(extension->name()) : base::UTF8ToUTF16(url.host()); | 203 base::UTF8ToUTF16(extension->name()) : base::UTF8ToUTF16(url.host()); |
| 206 } | 204 } |
| 207 | 205 |
| 208 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs(url::kFtpScheme)) { | 206 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs(url::kFtpScheme)) { |
| 209 // See ToolbarModelImpl::GetText(). Does not pay attention to any user | 207 // See ToolbarModelImpl::GetText(). Does not pay attention to any user |
| 210 // edits, and uses GetURL/net::FormatUrl -- We don't really care about | 208 // edits, and uses GetURL/net::FormatUrl -- We don't really care about |
| 211 // length or the autocomplete parser. | 209 // length or the autocomplete parser. |
| 212 // TODO(gbillock): This uses an algorithm very similar to GetText, which | 210 // TODO(gbillock): This uses an algorithm very similar to GetText, which |
| 213 // is probably too conservative. Try out just using a simpler mechanism of | 211 // is probably too conservative. Try out just using a simpler mechanism of |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 #if defined(OS_CHROMEOS) | 254 #if defined(OS_CHROMEOS) |
| 257 if (url.SchemeIs(chrome::kCrosScheme) || | 255 if (url.SchemeIs(chrome::kCrosScheme) || |
| 258 url.SchemeIs(content::kExternalFileScheme)) { | 256 url.SchemeIs(content::kExternalFileScheme)) { |
| 259 return base::UTF8ToUTF16(url.spec()); | 257 return base::UTF8ToUTF16(url.spec()); |
| 260 } | 258 } |
| 261 #endif | 259 #endif |
| 262 | 260 |
| 263 // If all else fails, return the hostname. | 261 // If all else fails, return the hostname. |
| 264 return base::UTF8ToUTF16(url.host()); | 262 return base::UTF8ToUTF16(url.host()); |
| 265 } | 263 } |
| OLD | NEW |