OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/autocomplete/shortcuts_extensions_manager.h" | 5 #include "chrome/browser/autocomplete/shortcuts_extensions_manager.h" |
6 | 6 |
7 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 7 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "components/omnibox/browser/shortcuts_backend.h" | 10 #include "components/omnibox/browser/shortcuts_backend.h" |
11 #include "content/public/browser/notification_details.h" | 11 #include "content/public/browser/notification_details.h" |
12 #include "content/public/browser/notification_source.h" | 12 #include "content/public/browser/notification_source.h" |
| 13 #include "extensions/features/features.h" |
13 | 14 |
14 #if defined(ENABLE_EXTENSIONS) | 15 #if BUILDFLAG(ENABLE_EXTENSIONS) |
15 #include "extensions/browser/notification_types.h" | 16 #include "extensions/browser/notification_types.h" |
16 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
17 #endif | 18 #endif |
18 | 19 |
19 ShortcutsExtensionsManager::ShortcutsExtensionsManager(Profile* profile) | 20 ShortcutsExtensionsManager::ShortcutsExtensionsManager(Profile* profile) |
20 : profile_(profile) { | 21 : profile_(profile) { |
21 DCHECK(profile_); | 22 DCHECK(profile_); |
22 #if defined(ENABLE_EXTENSIONS) | 23 #if BUILDFLAG(ENABLE_EXTENSIONS) |
23 notification_registrar_.Add( | 24 notification_registrar_.Add( |
24 this, extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 25 this, extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
25 content::Source<Profile>(profile_)); | 26 content::Source<Profile>(profile_)); |
26 #endif | 27 #endif |
27 } | 28 } |
28 | 29 |
29 ShortcutsExtensionsManager::~ShortcutsExtensionsManager() {} | 30 ShortcutsExtensionsManager::~ShortcutsExtensionsManager() {} |
30 | 31 |
31 void ShortcutsExtensionsManager::Observe( | 32 void ShortcutsExtensionsManager::Observe( |
32 int type, | 33 int type, |
33 const content::NotificationSource& source, | 34 const content::NotificationSource& source, |
34 const content::NotificationDetails& details) { | 35 const content::NotificationDetails& details) { |
35 #if defined(ENABLE_EXTENSIONS) | 36 #if BUILDFLAG(ENABLE_EXTENSIONS) |
36 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, type); | 37 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, type); |
37 scoped_refptr<ShortcutsBackend> shortcuts_backend = | 38 scoped_refptr<ShortcutsBackend> shortcuts_backend = |
38 ShortcutsBackendFactory::GetForProfileIfExists(profile_); | 39 ShortcutsBackendFactory::GetForProfileIfExists(profile_); |
39 if (!shortcuts_backend) | 40 if (!shortcuts_backend) |
40 return; | 41 return; |
41 | 42 |
42 // When an extension is unloaded, we want to remove any Shortcuts associated | 43 // When an extension is unloaded, we want to remove any Shortcuts associated |
43 // with it. | 44 // with it. |
44 shortcuts_backend->DeleteShortcutsBeginningWithURL( | 45 shortcuts_backend->DeleteShortcutsBeginningWithURL( |
45 content::Details<extensions::UnloadedExtensionInfo>(details) | 46 content::Details<extensions::UnloadedExtensionInfo>(details) |
46 ->extension->url()); | 47 ->extension->url()); |
47 #endif | 48 #endif |
48 } | 49 } |
OLD | NEW |