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

Unified Diff: chrome/browser/ui/location_bar/location_bar.cc

Issue 2555063003: Render extension URLs with chips (Closed)
Patch Set: Enlarge the window so that it's over the minimum window size Created 4 years 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 side-by-side diff with in-line comments
Download patch
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 efa6c167b097e2dc3ad9804a79ff9a1dfa99c451..26141ac675d3f22120a633d2964b0fe68a24ed6f 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"
@@ -14,6 +18,13 @@
const char LocationBar::kSecurityChipFeatureVisibilityParam[] = "visibility";
const char LocationBar::kSecurityChipFeatureAnimationParam[] = "animation";
+namespace {
+const base::char16 kLineBreakChars[] = {'\n', '\r', '\t',
+ 0x2028, // Line separator
+ 0x2029, // Paragraph separator
+ 0};
+} // namespace
+
LocationBar::LocationBar(Profile* profile) : profile_(profile) {
}
@@ -35,3 +46,25 @@ bool LocationBar::IsBookmarkStarHiddenByExtension() const {
return false;
}
+
+base::string16 LocationBar::GetExtensionName(
+ const GURL& url,
+ content::WebContents* web_contents) const {
+ if (web_contents && url.SchemeIs(extensions::kExtensionScheme)) {
Peter Kasting 2016/12/14 22:47:07 Can there be no web_contents? Consider adding a c
meacer 2016/12/16 18:46:17 I don't see an obvious code path that would led to
Peter Kasting 2016/12/20 01:59:31 IIRC, the places where LocationBarView does this a
meacer 2016/12/21 01:38:56 Done, added a CHECK.
+ content::BrowserContext* browser_context =
+ web_contents->GetBrowserContext();
+ extensions::ExtensionRegistry* extension_registry =
+ extensions::ExtensionRegistry::Get(browser_context);
+ if (extension_registry) {
Peter Kasting 2016/12/14 22:47:07 Can this actually fail?
meacer 2016/12/16 18:46:17 Looks like it can't, removed the check.
+ const extensions::Extension* extension =
+ extension_registry->enabled_extensions().GetByID(url.host());
+ if (extension) {
+ base::string16 extension_name(base::UTF8ToUTF16(extension->name()));
+ base::ReplaceChars(extension_name, kLineBreakChars,
+ base::ASCIIToUTF16(" "), &extension_name);
Peter Kasting 2016/12/14 22:47:07 Why do you need this? It seems like CollapseWhite
meacer 2016/12/16 18:46:17 This is the rebase of an old CL, and I seem to rem
+ return base::CollapseWhitespace(extension_name, false);
+ }
+ }
+ }
+ return base::string16();
+}

Powered by Google App Engine
This is Rietveld 408576698