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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "components/omnibox/browser/shortcuts_backend.h" | 9 #include "components/omnibox/browser/shortcuts_backend.h" |
10 #include "extensions/browser/extension_registry.h" | 10 #include "extensions/browser/extension_registry.h" |
11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
12 | 12 |
13 ShortcutsExtensionsManager::ShortcutsExtensionsManager(Profile* profile) | 13 ShortcutsExtensionsManager::ShortcutsExtensionsManager(Profile* profile) |
14 : registry_observer_(this), profile_(profile) { | 14 : registry_observer_(this), profile_(profile) { |
15 DCHECK(profile_); | 15 DCHECK(profile_); |
16 registry_observer_.Add(extensions::ExtensionRegistry::Get(profile_)); | 16 registry_observer_.Add(extensions::ExtensionRegistry::Get(profile_)); |
17 } | 17 } |
18 | 18 |
19 ShortcutsExtensionsManager::~ShortcutsExtensionsManager() {} | 19 ShortcutsExtensionsManager::~ShortcutsExtensionsManager() {} |
20 | 20 |
21 void ShortcutsExtensionsManager::OnExtensionUnloaded( | 21 void ShortcutsExtensionsManager::OnExtensionUnloaded( |
22 content::BrowserContext* browser_context, | 22 content::BrowserContext* browser_context, |
23 const extensions::Extension* extension, | 23 const extensions::Extension* extension, |
24 extensions::UnloadedExtensionInfo::Reason reason) { | 24 extensions::UnloadedExtensionReason reason) { |
25 scoped_refptr<ShortcutsBackend> shortcuts_backend = | 25 scoped_refptr<ShortcutsBackend> shortcuts_backend = |
26 ShortcutsBackendFactory::GetForProfileIfExists(profile_); | 26 ShortcutsBackendFactory::GetForProfileIfExists(profile_); |
27 if (!shortcuts_backend) | 27 if (!shortcuts_backend) |
28 return; | 28 return; |
29 | 29 |
30 // When an extension is unloaded, we want to remove any Shortcuts associated | 30 // When an extension is unloaded, we want to remove any Shortcuts associated |
31 // with it. | 31 // with it. |
32 shortcuts_backend->DeleteShortcutsBeginningWithURL(extension->url()); | 32 shortcuts_backend->DeleteShortcutsBeginningWithURL(extension->url()); |
33 } | 33 } |
34 | 34 |
35 void ShortcutsExtensionsManager::OnShutdown( | 35 void ShortcutsExtensionsManager::OnShutdown( |
36 extensions::ExtensionRegistry* registry) { | 36 extensions::ExtensionRegistry* registry) { |
37 registry_observer_.RemoveAll(); | 37 registry_observer_.RemoveAll(); |
38 } | 38 } |
OLD | NEW |