Chromium Code Reviews| 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" | |
| 9 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 10 #include "components/omnibox/browser/shortcuts_backend.h" | 9 #include "components/omnibox/browser/shortcuts_backend.h" |
| 11 #include "content/public/browser/notification_details.h" | 10 #include "extensions/browser/extension_registry.h" |
| 12 #include "content/public/browser/notification_source.h" | 11 #include "extensions/common/extension.h" |
| 13 #include "extensions/features/features.h" | 12 #include "extensions/features/features.h" |
| 14 | 13 |
| 15 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
| 16 #include "extensions/browser/notification_types.h" | |
| 17 #include "extensions/common/extension.h" | |
| 18 #endif | |
| 19 | |
| 20 ShortcutsExtensionsManager::ShortcutsExtensionsManager(Profile* profile) | 14 ShortcutsExtensionsManager::ShortcutsExtensionsManager(Profile* profile) |
| 21 : profile_(profile) { | 15 : registry_observer_(this), profile_(profile) { |
| 22 DCHECK(profile_); | 16 DCHECK(profile_); |
| 23 #if BUILDFLAG(ENABLE_EXTENSIONS) | 17 registry_observer_.Add(extensions::ExtensionRegistry::Get(profile_)); |
| 24 notification_registrar_.Add( | |
| 25 this, extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | |
| 26 content::Source<Profile>(profile_)); | |
| 27 #endif | |
| 28 } | 18 } |
| 29 | 19 |
| 30 ShortcutsExtensionsManager::~ShortcutsExtensionsManager() {} | 20 ShortcutsExtensionsManager::~ShortcutsExtensionsManager() {} |
|
Peter Kasting
2017/03/30 23:35:31
Nit: You're also welcome to =default this in the h
limasdf
2017/03/31 03:26:27
Linking error for `= default` in the header :(
Peter Kasting
2017/03/31 06:09:59
Oh? I would have expected the warning, if any, to
limasdf
2017/03/31 06:17:53
Sorry for the confusion. First I just commented ou
| |
| 31 | 21 |
| 32 void ShortcutsExtensionsManager::Observe( | 22 void ShortcutsExtensionsManager::OnExtensionUnloaded( |
| 33 int type, | 23 content::BrowserContext* browser_context, |
| 34 const content::NotificationSource& source, | 24 const extensions::Extension* extension, |
| 35 const content::NotificationDetails& details) { | 25 extensions::UnloadedExtensionInfo::Reason reason) { |
| 36 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
| 37 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, type); | |
| 38 scoped_refptr<ShortcutsBackend> shortcuts_backend = | 26 scoped_refptr<ShortcutsBackend> shortcuts_backend = |
| 39 ShortcutsBackendFactory::GetForProfileIfExists(profile_); | 27 ShortcutsBackendFactory::GetForProfileIfExists(profile_); |
| 40 if (!shortcuts_backend) | 28 if (!shortcuts_backend) |
| 41 return; | 29 return; |
| 42 | 30 |
| 43 // When an extension is unloaded, we want to remove any Shortcuts associated | 31 // When an extension is unloaded, we want to remove any Shortcuts associated |
| 44 // with it. | 32 // with it. |
| 45 shortcuts_backend->DeleteShortcutsBeginningWithURL( | 33 shortcuts_backend->DeleteShortcutsBeginningWithURL(extension->url()); |
| 46 content::Details<extensions::UnloadedExtensionInfo>(details) | |
| 47 ->extension->url()); | |
| 48 #endif | |
| 49 } | 34 } |
| 35 | |
| 36 void ShortcutsExtensionsManager::OnShutdown( | |
| 37 extensions::ExtensionRegistry* registry) { | |
| 38 registry_observer_.RemoveAll(); | |
| 39 } | |
| OLD | NEW |