OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/scoped_observer.h" |
13 #include "chrome/browser/autocomplete/autocomplete_input.h" | 14 #include "chrome/browser/autocomplete/autocomplete_input.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 16 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "extensions/browser/extension_registry_observer.h" |
18 #include "ui/base/window_open_disposition.h" | 20 #include "ui/base/window_open_disposition.h" |
19 | 21 |
| 22 namespace extensions { |
| 23 class ExtensionRegistry; |
| 24 } |
| 25 |
20 // This provider is responsible for keeping track of which Extension Apps are | 26 // This provider is responsible for keeping track of which Extension Apps are |
21 // installed and their URLs. An instance of it gets created and managed by | 27 // installed and their URLs. An instance of it gets created and managed by |
22 // AutocompleteController. | 28 // AutocompleteController. |
23 class ExtensionAppProvider : public AutocompleteProvider, | 29 class ExtensionAppProvider : public AutocompleteProvider, |
24 public content::NotificationObserver { | 30 public content::NotificationObserver, |
| 31 public extensions::ExtensionRegistryObserver { |
25 public: | 32 public: |
26 ExtensionAppProvider(AutocompleteProviderListener* listener, | 33 ExtensionAppProvider(AutocompleteProviderListener* listener, |
27 Profile* profile); | 34 Profile* profile); |
28 | 35 |
29 // AutocompleteProvider: | 36 // AutocompleteProvider: |
30 virtual void Start(const AutocompleteInput& input, | 37 virtual void Start(const AutocompleteInput& input, |
31 bool minimal_changes) OVERRIDE; | 38 bool minimal_changes) OVERRIDE; |
32 | 39 |
33 // Launch an Extension App from |match| details provided by the Omnibox. If | 40 // Launch an Extension App from |match| details provided by the Omnibox. If |
34 // the application wants to launch as a window or panel, |disposition| is | 41 // the application wants to launch as a window or panel, |disposition| is |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 int CalculateRelevance(AutocompleteInput::Type type, | 81 int CalculateRelevance(AutocompleteInput::Type type, |
75 int input_length, | 82 int input_length, |
76 int target_length, | 83 int target_length, |
77 const GURL& url); | 84 const GURL& url); |
78 | 85 |
79 // content::NotificationObserver implementation: | 86 // content::NotificationObserver implementation: |
80 virtual void Observe(int type, | 87 virtual void Observe(int type, |
81 const content::NotificationSource& source, | 88 const content::NotificationSource& source, |
82 const content::NotificationDetails& details) OVERRIDE; | 89 const content::NotificationDetails& details) OVERRIDE; |
83 | 90 |
| 91 // extensions::ExtensionRegistryObserver implementation: |
| 92 virtual void OnExtensionLoaded( |
| 93 content::BrowserContext* browser_context, |
| 94 const extensions::Extension* extension) OVERRIDE; |
| 95 |
84 content::NotificationRegistrar registrar_; | 96 content::NotificationRegistrar registrar_; |
85 | 97 |
| 98 ScopedObserver<extensions::ExtensionRegistry, |
| 99 extensions::ExtensionRegistryObserver> |
| 100 extension_registry_observer_; |
| 101 |
86 // Our cache of ExtensionApp objects (name + url) representing the extension | 102 // Our cache of ExtensionApp objects (name + url) representing the extension |
87 // apps we know/care about. | 103 // apps we know/care about. |
88 ExtensionApps extension_apps_; | 104 ExtensionApps extension_apps_; |
89 | 105 |
90 DISALLOW_COPY_AND_ASSIGN(ExtensionAppProvider); | 106 DISALLOW_COPY_AND_ASSIGN(ExtensionAppProvider); |
91 }; | 107 }; |
92 | 108 |
93 #endif // CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ | 109 #endif // CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
OLD | NEW |