Commit 5b8dfb30 authored by Christopher Lam's avatar Christopher Lam Committed by Commit Bot

Remove Bookmark Manager API permissions, and clean up EnhancedBookmarkKeyService.

Bug: 938695
Change-Id: I90600729c8a356632fe2de593cade87b52c4195c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1510622Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658454}
parent 655f2b6f
......@@ -147,7 +147,6 @@
#include "chrome/browser/extensions/api/networking_private/networking_private_ui_delegate_factory_impl.h"
#include "chrome/browser/extensions/browser_context_keyed_service_factories.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/ui/bookmarks/enhanced_bookmark_key_service_factory.h"
#include "chrome/browser/ui/web_applications/web_app_metrics_factory.h"
#include "chrome/browser/ui/web_applications/web_app_ui_delegate_impl_factory.h"
#include "chrome/browser/web_applications/web_app_provider_factory.h"
......@@ -259,7 +258,6 @@ void ChromeBrowserMainExtraPartsProfiles::
#if defined(OS_CHROMEOS)
chromeos::EasyUnlockServiceFactory::GetInstance();
#endif
EnhancedBookmarkKeyServiceFactory::GetInstance();
#endif
#if defined(OS_ANDROID)
explore_sites::ExploreSitesServiceFactory::GetInstance();
......
......@@ -801,10 +801,6 @@ jumbo_split_static_library("ui") {
"bookmarks/bookmark_tab_helper_observer.h",
"bookmarks/bookmark_utils_desktop.cc",
"bookmarks/bookmark_utils_desktop.h",
"bookmarks/enhanced_bookmark_key_service.cc",
"bookmarks/enhanced_bookmark_key_service.h",
"bookmarks/enhanced_bookmark_key_service_factory.cc",
"bookmarks/enhanced_bookmark_key_service_factory.h",
"browser.cc",
"browser.h",
"browser_command_controller.cc",
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/bookmarks/enhanced_bookmark_key_service.h"
#include <algorithm>
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/extensions/api/commands/command_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/accelerator_utils.h"
#include "chrome/common/extensions/command.h"
#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/manifest_constants.h"
EnhancedBookmarkKeyService::EnhancedBookmarkKeyService(
content::BrowserContext* context) : browser_context_(context) {
Profile* profile = Profile::FromBrowserContext(browser_context_);
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED,
content::Source<Profile>(profile->GetOriginalProfile()));
}
EnhancedBookmarkKeyService::~EnhancedBookmarkKeyService() {
}
void EnhancedBookmarkKeyService::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED, type);
const extensions::Extension* enhanced_bookmark_extension =
GetEnhancedBookmarkExtension();
if (!enhanced_bookmark_extension)
return;
extensions::ExtensionCommandRemovedDetails* payload =
content::Details<extensions::ExtensionCommandRemovedDetails>(details)
.ptr();
if (payload->extension_id == enhanced_bookmark_extension->id())
return;
ui::Accelerator key = extensions::Command::StringToAccelerator(
payload->accelerator, payload->command_name);
ui::Accelerator bookmark_accelerator =
chrome::GetPrimaryChromeAcceleratorForBookmarkPage();
if (key == bookmark_accelerator) {
extensions::CommandService* command_service =
extensions::CommandService::Get(browser_context_);
extensions::Command existing_command;
if (!command_service->GetPageActionCommand(
enhanced_bookmark_extension->id(),
extensions::CommandService::ACTIVE,
&existing_command, nullptr)) {
command_service->AddKeybindingPref(
bookmark_accelerator, enhanced_bookmark_extension->id(),
extensions::manifest_values::kPageActionCommandEvent, false,
false);
}
}
}
const extensions::Extension*
EnhancedBookmarkKeyService::GetEnhancedBookmarkExtension() const {
const extensions::ExtensionSet& extensions =
extensions::ExtensionRegistry::Get(browser_context_)
->enabled_extensions();
extensions::ExtensionSet::const_iterator loc =
std::find_if(extensions.begin(), extensions.end(),
[](scoped_refptr<const extensions::Extension> extension) {
static const char enhanced_ext_hash[] =
// http://crbug.com/312900
"D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2";
std::string hashed_id =
crx_file::id_util::HashedIdInHex(extension->id());
return hashed_id == enhanced_ext_hash;
});
return loc != extensions.end() ? loc->get() : nullptr;
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_BOOKMARKS_ENHANCED_BOOKMARK_KEY_SERVICE_H_
#define CHROME_BROWSER_UI_BOOKMARKS_ENHANCED_BOOKMARK_KEY_SERVICE_H_
#include "base/macros.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
namespace content {
class BrowserContext;
} // namespace content
namespace extensions {
class Extension;
} // namespace extensions
// Maintains assignment of bookmark keybinding on the enhanced bookmarks
// extension when not assigned to other extensions.
class EnhancedBookmarkKeyService : public content::NotificationObserver,
public KeyedService {
public:
EnhancedBookmarkKeyService(content::BrowserContext* context);
~EnhancedBookmarkKeyService() override;
private:
// Overridden from content::NotificationObserver:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
const extensions::Extension* GetEnhancedBookmarkExtension() const;
// The content notification registrar for listening to extension key events.
content::NotificationRegistrar registrar_;
content::BrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(EnhancedBookmarkKeyService);
};
#endif // CHROME_BROWSER_UI_BOOKMARKS_ENHANCED_BOOKMARK_KEY_SERVICE_H_
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/bookmarks/enhanced_bookmark_key_service_factory.h"
#include "base/memory/singleton.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/ui/bookmarks/enhanced_bookmark_key_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
// static
EnhancedBookmarkKeyServiceFactory*
EnhancedBookmarkKeyServiceFactory::GetInstance() {
return base::Singleton<EnhancedBookmarkKeyServiceFactory>::get();
}
EnhancedBookmarkKeyServiceFactory::EnhancedBookmarkKeyServiceFactory()
: BrowserContextKeyedServiceFactory(
"EnhancedBookmarkKeyService",
BrowserContextDependencyManager::GetInstance()) {
}
EnhancedBookmarkKeyServiceFactory::~EnhancedBookmarkKeyServiceFactory() {
}
KeyedService* EnhancedBookmarkKeyServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
return new EnhancedBookmarkKeyService(context);
}
content::BrowserContext*
EnhancedBookmarkKeyServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context);
}
bool EnhancedBookmarkKeyServiceFactory::ServiceIsCreatedWithBrowserContext()
const {
return true;
}
bool EnhancedBookmarkKeyServiceFactory::ServiceIsNULLWhileTesting() const {
return true;
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_BOOKMARKS_ENHANCED_BOOKMARK_KEY_SERVICE_FACTORY_H_
#define CHROME_BROWSER_UI_BOOKMARKS_ENHANCED_BOOKMARK_KEY_SERVICE_FACTORY_H_
#include "base/macros.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
namespace content {
class BrowserContext;
} // namespace content
namespace base {
template <typename T> struct DefaultSingletonTraits;
}
// Singleton that owns all EnhancedBookmarkKeyServices and associates them with
// BrowserContexts.
class EnhancedBookmarkKeyServiceFactory
: public BrowserContextKeyedServiceFactory {
public:
static EnhancedBookmarkKeyServiceFactory* GetInstance();
private:
friend struct base::DefaultSingletonTraits<EnhancedBookmarkKeyServiceFactory>;
EnhancedBookmarkKeyServiceFactory();
~EnhancedBookmarkKeyServiceFactory() override;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
bool ServiceIsCreatedWithBrowserContext() const override;
bool ServiceIsNULLWhileTesting() const override;
DISALLOW_COPY_AND_ASSIGN(EnhancedBookmarkKeyServiceFactory);
};
#endif // CHROME_BROWSER_UI_BOOKMARKS_ENHANCED_BOOKMARK_KEY_SERVICE_FACTORY_H_
......@@ -58,18 +58,10 @@
"extension_types": ["extension"],
"platforms": ["win", "mac"]
},
"chrome_ui_overrides": [{
"chrome_ui_overrides": {
"channel": "dev",
"extension_types": ["extension"]
}, {
"channel": "stable",
"extension_types": ["extension"],
"whitelist": [
"D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
"D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
"3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
]
}],
},
"chrome_url_overrides": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"]
......
......@@ -18,17 +18,6 @@
namespace extensions {
namespace util {
namespace {
// Returns true if |extension| should always be enabled in incognito mode.
bool IsWhitelistedForIncognito(const Extension* extension) {
const Feature* feature = FeatureProvider::GetBehaviorFeature(
behavior_feature::kWhitelistedForIncognito);
return feature && feature->IsAvailableToExtension(extension).is_available();
}
} // namespace
bool SiteHasIsolatedStorage(const GURL& extension_site_url,
content::BrowserContext* context) {
const Extension* extension = ExtensionRegistry::Get(context)->
......@@ -55,8 +44,6 @@ bool IsIncognitoEnabled(const std::string& extension_id,
// work in incognito mode.
if (Manifest::IsComponentLocation(extension->location()))
return true;
if (IsWhitelistedForIncognito(extension))
return true;
}
return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id);
}
......
......@@ -337,11 +337,6 @@
"12E618C3C6E97495AAECF2AC12DEB082353241C6", // QO component extension
"3727DD3E564B6055387425027AD74C58784ACC15", // Editor
"C41AD9DCD670210295614257EF8C9945AD68D86E", // Google Now
// TODO(michaelpg): Determine whether these three extensions (D5736E4,
// D57DE39, 3F65507) require this feature: crbug.com/652433.
"D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900.
"D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444.
"3F65507A3B39259B38C8173C6FFA3D12DF64CCE9", // http://crbug.com/371562.
"D7986543275120831B39EF28D1327552FC343960", // http://crbug.com/378067
"A291B26E088FA6BA53FFD72F0916F06EBA7C585A", // http://crbug.com/378067
"07BD6A765FFC289FF755D7CAB2893A40EC337FEC", // http://crbug.com/456214
......
......@@ -8,18 +8,6 @@
// well as feature.h, simple_feature.h, and feature_provider.h.
{
"whitelisted_for_incognito": {
"channel": "stable",
"extension_types": "all",
// This is "external_component" for legacy reasons; it should be
// unnecessary given there's a whitelist.
"location": "external_component",
"whitelist": [
"D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
"D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
"3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
]
},
"do_not_sync": {
"channel": "stable",
"component_extensions_auto_granted": false,
......
......@@ -294,9 +294,6 @@
"2FC374607C2DF285634B67C64A2E356C607091C3", // Quickoffice
"3727DD3E564B6055387425027AD74C58784ACC15", // Quickoffice internal
"12E618C3C6E97495AAECF2AC12DEB082353241C6", // QO component extension
"D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
"D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
"3F65507A3B39259B38C8173C6FFA3D12DF64CCE9", // http://crbug.com/371562
"2B6C6A4A5940017146F3E58B7F90116206E84685", // http://crbug.com/642141
"B6C2EFAB3EC3BF6EF03701408B6B09A67B2D0069", // http://crbug.com/642141
"96FF2FFA5C9173C76D47184B3E86D267B37781DE", // http://crbug.com/642141
......@@ -318,10 +315,7 @@
"whitelist": [
"2FC374607C2DF285634B67C64A2E356C607091C3", // Quickoffice
"3727DD3E564B6055387425027AD74C58784ACC15", // Quickoffice internal
"12E618C3C6E97495AAECF2AC12DEB082353241C6", // QO component extension
"D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
"D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
"3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
"12E618C3C6E97495AAECF2AC12DEB082353241C6" // QO component extension
]
}],
"fileSystem.requestDownloads": {
......@@ -415,9 +409,6 @@
"7AE714FFD394E073F0294CFA134C9F91DB5FBAA4", // CCD Development
"C7DA3A55C2355F994D3FDDAD120B426A0DF63843", // CCD Testing
"75E3CFFFC530582C583E4690EF97C70B9C8423B7", // CCD Release
"D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900.
"D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444.
"3F65507A3B39259B38C8173C6FFA3D12DF64CCE9", // http://crbug.com/371562.
"06BE211D5F014BAB34BC22D9DDA09C63A81D828E", // Official XKB virtual kbd
"CFBF7EE448FA48960FFDA7CEB30F7A21B26AA981", // Official m17n virtual kbd
"B9EF10DDFEA11EF77873CC5009809E5037FC4C7A", // Google input tools
......
......@@ -8,8 +8,6 @@ namespace extensions {
namespace behavior_feature {
const char kWhitelistedForIncognito[] = "whitelisted_for_incognito";
const char kDoNotSync[] = "do_not_sync";
const char kZoomWithoutBubble[] = "zoom_without_bubble";
......
......@@ -11,7 +11,6 @@ namespace extensions {
// One day we might want to auto generate these.
namespace behavior_feature {
extern const char kWhitelistedForIncognito[];
extern const char kDoNotSync[];
extern const char kZoomWithoutBubble[];
extern const char kAllowUsbDevicesPermissionInterfaceClass[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment