1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/autocomplete/shortcuts_extensions_manager.h"
7 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "components/omnibox/browser/shortcuts_backend.h"
11 #include "content/public/browser/notification_details.h"
12 #include "content/public/browser/notification_source.h"
14 #if defined(ENABLE_EXTENSIONS)
15 #include "extensions/browser/notification_types.h"
16 #include "extensions/common/extension.h"
19 ShortcutsExtensionsManager::ShortcutsExtensionsManager(Profile
* profile
)
22 #if defined(ENABLE_EXTENSIONS)
23 notification_registrar_
.Add(
24 this, extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED
,
25 content::Source
<Profile
>(profile_
));
29 ShortcutsExtensionsManager::~ShortcutsExtensionsManager() {}
31 void ShortcutsExtensionsManager::Observe(
33 const content::NotificationSource
& source
,
34 const content::NotificationDetails
& details
) {
35 #if defined(ENABLE_EXTENSIONS)
36 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED
, type
);
37 scoped_refptr
<ShortcutsBackend
> shortcuts_backend
=
38 ShortcutsBackendFactory::GetForProfileIfExists(profile_
);
39 if (!shortcuts_backend
)
42 // When an extension is unloaded, we want to remove any Shortcuts associated
44 shortcuts_backend
->DeleteShortcutsBeginningWithURL(
45 content::Details
<extensions::UnloadedExtensionInfo
>(details
)