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

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

Issue 2555063003: Render extension URLs with chips (Closed)
Patch Set: Chip -> text 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 CHECK(web_contents);
45 if (!url.SchemeIs(extensions::kExtensionScheme))
46 return base::string16();
47
48 content::BrowserContext* browser_context = web_contents->GetBrowserContext();
49 extensions::ExtensionRegistry* extension_registry =
50 extensions::ExtensionRegistry::Get(browser_context);
51 const extensions::Extension* extension =
52 extension_registry->enabled_extensions().GetByID(url.host());
53 return extension ? base::CollapseWhitespace(
54 base::UTF8ToUTF16(extension->name()), false)
55 : base::string16();
56 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/location_bar/location_bar.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698