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_) |
127 extensions()->GetExtensionOrAppByURL(displayed_url_); | 126 ->enabled_extensions() |
| 127 .GetByID(displayed_url_.host()); |
128 | 128 |
129 if (extension) { | 129 if (extension) { |
130 icon_ = IDR_EXTENSIONS_FAVICON; | 130 icon_ = IDR_EXTENSIONS_FAVICON; |
131 extension_icon_image_.reset( | 131 extension_icon_image_.reset( |
132 new extensions::IconImage(profile_, | 132 new extensions::IconImage(profile_, |
133 extension, | 133 extension, |
134 extensions::IconsInfo::GetIcons(extension), | 134 extensions::IconsInfo::GetIcons(extension), |
135 extension_misc::EXTENSION_ICON_BITTY, | 135 extension_misc::EXTENSION_ICON_BITTY, |
136 extensions::util::GetDefaultAppIcon(), | 136 extensions::util::GetDefaultAppIcon(), |
137 owner_)); | 137 owner_)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 // Chrome built-in pages. | 191 // Chrome built-in pages. |
192 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { | 192 if (url.is_empty() || url.SchemeIs(content::kChromeUIScheme)) { |
193 int string_ref = StringForChromeHost(url); | 193 int string_ref = StringForChromeHost(url); |
194 return l10n_util::GetStringUTF16( | 194 return l10n_util::GetStringUTF16( |
195 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); | 195 (string_ref == -1) ? IDS_SHORT_PRODUCT_NAME : string_ref); |
196 } | 196 } |
197 | 197 |
198 // For chrome-extension URLs, return the extension name. | 198 // For chrome-extension URLs, return the extension name. |
199 if (url.SchemeIs(extensions::kExtensionScheme)) { | 199 if (url.SchemeIs(extensions::kExtensionScheme)) { |
200 ExtensionService* service = | |
201 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
202 const extensions::Extension* extension = | 200 const extensions::Extension* extension = |
203 service->extensions()->GetExtensionOrAppByURL(url); | 201 extensions::ExtensionRegistry::Get(profile) |
| 202 ->enabled_extensions() |
| 203 .GetByID(url.host()); |
204 return extension ? | 204 return extension ? |
205 base::UTF8ToUTF16(extension->name()) : base::UTF8ToUTF16(url.host()); | 205 base::UTF8ToUTF16(extension->name()) : base::UTF8ToUTF16(url.host()); |
206 } | 206 } |
207 | 207 |
208 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs(url::kFtpScheme)) { | 208 if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIs(url::kFtpScheme)) { |
209 // See ToolbarModelImpl::GetText(). Does not pay attention to any user | 209 // See ToolbarModelImpl::GetText(). Does not pay attention to any user |
210 // edits, and uses GetURL/net::FormatUrl -- We don't really care about | 210 // edits, and uses GetURL/net::FormatUrl -- We don't really care about |
211 // length or the autocomplete parser. | 211 // length or the autocomplete parser. |
212 // TODO(gbillock): This uses an algorithm very similar to GetText, which | 212 // TODO(gbillock): This uses an algorithm very similar to GetText, which |
213 // is probably too conservative. Try out just using a simpler mechanism of | 213 // 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) | 256 #if defined(OS_CHROMEOS) |
257 if (url.SchemeIs(chrome::kCrosScheme) || | 257 if (url.SchemeIs(chrome::kCrosScheme) || |
258 url.SchemeIs(content::kExternalFileScheme)) { | 258 url.SchemeIs(content::kExternalFileScheme)) { |
259 return base::UTF8ToUTF16(url.spec()); | 259 return base::UTF8ToUTF16(url.spec()); |
260 } | 260 } |
261 #endif | 261 #endif |
262 | 262 |
263 // If all else fails, return the hostname. | 263 // If all else fails, return the hostname. |
264 return base::UTF8ToUTF16(url.host()); | 264 return base::UTF8ToUTF16(url.host()); |
265 } | 265 } |
OLD | NEW |