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

Side by Side Diff: chrome/browser/ui/location_bar/location_bar.cc

Issue 2555063003: Render extension URLs with chips (Closed)
Patch Set: pkasting comments and rebase 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 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/location_bar/location_bar.h" 5 #include "chrome/browser/ui/location_bar/location_bar.h"
6 6
7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h" 10 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
11 #include "content/public/browser/web_contents.h"
9 #include "extensions/browser/extension_registry.h" 12 #include "extensions/browser/extension_registry.h"
13 #include "extensions/common/constants.h"
10 #include "extensions/common/extension_set.h" 14 #include "extensions/common/extension_set.h"
11 #include "extensions/common/feature_switch.h" 15 #include "extensions/common/feature_switch.h"
12 #include "extensions/common/permissions/permissions_data.h" 16 #include "extensions/common/permissions/permissions_data.h"
13 17
14 LocationBar::LocationBar(Profile* profile) : profile_(profile) { 18 LocationBar::LocationBar(Profile* profile) : profile_(profile) {
15 } 19 }
16 20
17 LocationBar::~LocationBar() { 21 LocationBar::~LocationBar() {
18 } 22 }
19 23
20 bool LocationBar::IsBookmarkStarHiddenByExtension() const { 24 bool LocationBar::IsBookmarkStarHiddenByExtension() const {
21 const extensions::ExtensionSet& extension_set = 25 const extensions::ExtensionSet& extension_set =
22 extensions::ExtensionRegistry::Get(profile_)->enabled_extensions(); 26 extensions::ExtensionRegistry::Get(profile_)->enabled_extensions();
23 for (extensions::ExtensionSet::const_iterator i = extension_set.begin(); 27 for (extensions::ExtensionSet::const_iterator i = extension_set.begin();
24 i != extension_set.end(); ++i) { 28 i != extension_set.end(); ++i) {
25 if (extensions::UIOverrides::RemovesBookmarkButton(i->get()) && 29 if (extensions::UIOverrides::RemovesBookmarkButton(i->get()) &&
26 ((*i)->permissions_data()->HasAPIPermission( 30 ((*i)->permissions_data()->HasAPIPermission(
27 extensions::APIPermission::kBookmarkManagerPrivate) || 31 extensions::APIPermission::kBookmarkManagerPrivate) ||
28 extensions::FeatureSwitch::enable_override_bookmarks_ui() 32 extensions::FeatureSwitch::enable_override_bookmarks_ui()
29 ->IsEnabled())) 33 ->IsEnabled()))
30 return true; 34 return true;
31 } 35 }
32 36
33 return false; 37 return false;
34 } 38 }
39
40 // static
41 base::string16 LocationBar::GetExtensionName(
42 const GURL& url,
43 content::WebContents* web_contents) {
44 if (web_contents && url.SchemeIs(extensions::kExtensionScheme)) {
45 content::BrowserContext* browser_context =
46 web_contents->GetBrowserContext();
47 extensions::ExtensionRegistry* extension_registry =
48 extensions::ExtensionRegistry::Get(browser_context);
49 const extensions::Extension* extension =
50 extension_registry->enabled_extensions().GetByID(url.host());
51 if (extension) {
52 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.
53 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.
54 }
55 }
56 return base::string16();
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698