Chromium Code Reviews| Index: chrome/browser/ui/location_bar/location_bar.cc |
| diff --git a/chrome/browser/ui/location_bar/location_bar.cc b/chrome/browser/ui/location_bar/location_bar.cc |
| index 81b3724222a22d798cabe369c399b7b0637a03ac..e62b578ee01680c6dfaba21a1e452d2c427d14fb 100644 |
| --- a/chrome/browser/ui/location_bar/location_bar.cc |
| +++ b/chrome/browser/ui/location_bar/location_bar.cc |
| @@ -4,9 +4,13 @@ |
| #include "chrome/browser/ui/location_bar/location_bar.h" |
| +#include "base/strings/string_util.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h" |
| +#include "content/public/browser/web_contents.h" |
| #include "extensions/browser/extension_registry.h" |
| +#include "extensions/common/constants.h" |
| #include "extensions/common/extension_set.h" |
| #include "extensions/common/feature_switch.h" |
| #include "extensions/common/permissions/permissions_data.h" |
| @@ -32,3 +36,22 @@ bool LocationBar::IsBookmarkStarHiddenByExtension() const { |
| return false; |
| } |
| + |
| +// static |
| +base::string16 LocationBar::GetExtensionName( |
| + const GURL& url, |
| + content::WebContents* web_contents) { |
| + if (web_contents && url.SchemeIs(extensions::kExtensionScheme)) { |
| + content::BrowserContext* browser_context = |
| + web_contents->GetBrowserContext(); |
| + extensions::ExtensionRegistry* extension_registry = |
| + extensions::ExtensionRegistry::Get(browser_context); |
| + const extensions::Extension* extension = |
| + extension_registry->enabled_extensions().GetByID(url.host()); |
| + if (extension) { |
| + base::string16 extension_name(base::UTF8ToUTF16(extension->name())); |
|
Peter Kasting
2016/12/20 01:59:31
Nit: Prefer '=' to () for initializing strings; se
meacer
2016/12/21 01:38:56
Done.
|
| + return base::CollapseWhitespace(extension_name, false); |
|
Peter Kasting
2016/12/20 01:59:31
Nit: Using early-returns to unindent lets us rewri
meacer
2016/12/21 01:38:56
Done.
Peter Kasting
2016/12/21 02:09:40
Correct. This won't though:
return extension
meacer
2016/12/21 02:14:10
Done.
|
| + } |
| + } |
| + return base::string16(); |
| +} |