Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / autocomplete / shortcuts_extensions_manager.cc
blobaebc8d77d10e6a25af063d6ea97c908487aab218
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"
17 #endif
19 ShortcutsExtensionsManager::ShortcutsExtensionsManager(Profile* profile)
20 : profile_(profile) {
21 DCHECK(profile_);
22 #if defined(ENABLE_EXTENSIONS)
23 notification_registrar_.Add(
24 this, extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
25 content::Source<Profile>(profile_));
26 #endif
29 ShortcutsExtensionsManager::~ShortcutsExtensionsManager() {}
31 void ShortcutsExtensionsManager::Observe(
32 int type,
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)
40 return;
42 // When an extension is unloaded, we want to remove any Shortcuts associated
43 // with it.
44 shortcuts_backend->DeleteShortcutsBeginningWithURL(
45 content::Details<extensions::UnloadedExtensionInfo>(details)
46 ->extension->url());
47 #endif