| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 // |
| 5 // |
| 6 // This file contains the Extension App autocomplete provider. The provider |
| 7 // is responsible for keeping track of which Extension Apps are installed and |
| 8 // their URLs. An instance of it gets created and managed by the autocomplete |
| 9 // controller. |
| 10 // |
| 11 // For more information on the autocomplete system in general, including how |
| 12 // the autocomplete controller and autocomplete providers work, see |
| 13 // chrome/browser/autocomplete.h. |
| 14 |
| 15 #ifndef CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
| 16 #define CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
| 17 #pragma once |
| 18 |
| 19 #include <string> |
| 20 #include <utility> |
| 21 #include <vector> |
| 22 |
| 23 #include "base/compiler_specific.h" |
| 24 #include "chrome/browser/autocomplete/autocomplete.h" |
| 25 #include "content/common/notification_observer.h" |
| 26 #include "content/common/notification_registrar.h" |
| 27 |
| 28 class TemplateURLModel; |
| 29 |
| 30 class ExtensionAppProvider : public AutocompleteProvider, |
| 31 public NotificationObserver { |
| 32 public: |
| 33 ExtensionAppProvider(ACProviderListener* listener, Profile* profile); |
| 34 |
| 35 // AutocompleteProvider implementation: |
| 36 virtual void Start(const AutocompleteInput& input, |
| 37 bool minimal_changes) OVERRIDE; |
| 38 |
| 39 private: |
| 40 // An ExtensionApp is a pair of Extension Name and the Launch URL. |
| 41 typedef std::pair<std::string, std::string> ExtensionApp; |
| 42 typedef std::vector<ExtensionApp> ExtensionApps; |
| 43 |
| 44 virtual ~ExtensionAppProvider(); |
| 45 |
| 46 // Fetch the current app list and cache it locally. |
| 47 void RefreshAppList(); |
| 48 |
| 49 // Register for install/uninstall notification so we can update our cache. |
| 50 void RegisterForNotifications(); |
| 51 |
| 52 // Calculate the relevance of the match. |
| 53 int CalculateRelevance(AutocompleteInput::Type type, |
| 54 int input_length, |
| 55 int target_length); |
| 56 |
| 57 // NotificationObserver implementation: |
| 58 virtual void Observe(NotificationType type, |
| 59 const NotificationSource& source, |
| 60 const NotificationDetails& details) OVERRIDE; |
| 61 |
| 62 NotificationRegistrar registrar_; |
| 63 |
| 64 // Our cache of ExtensionApp objects (name + url) representing the extension |
| 65 // apps we know about. |
| 66 ExtensionApps extension_apps_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(ExtensionAppProvider); |
| 69 }; |
| 70 |
| 71 #endif // CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ |
| OLD | NEW |