Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3556)

Unified Diff: chrome/browser/autocomplete/extension_app_provider.h

Issue 6758031: Implement a simple Extension App Omnibox provider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/extension_app_provider.h
===================================================================
--- chrome/browser/autocomplete/extension_app_provider.h (revision 0)
+++ chrome/browser/autocomplete/extension_app_provider.h (revision 0)
@@ -0,0 +1,73 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+//
+// This file contains the Extension App autocomplete provider. The provider
+// is responsible for keeping track of which Extension Apps are installed and
+// their URLs. An instance of it gets created and managed by the autocomplete
+// controller.
+//
+// For more information on the autocomplete system in general, including how
+// the autocomplete controller and autocomplete providers work, see
+// chrome/browser/autocomplete.h.
+
+#ifndef CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_
+#pragma once
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "chrome/browser/autocomplete/autocomplete.h"
+#include "content/common/notification_observer.h"
+#include "content/common/notification_registrar.h"
+#include "base/compiler_specific.h"
+
+class TemplateURLModel;
+
+class ExtensionAppProvider : public AutocompleteProvider,
+ public NotificationObserver {
+ public:
+ ExtensionAppProvider(ACProviderListener* listener, Profile* profile);
+ // For testing.
+ ExtensionAppProvider(ACProviderListener* listener, TemplateURLModel* model);
+
+ // AutocompleteProvider implementation:
+ virtual void Start(const AutocompleteInput& input,
+ bool minimal_changes) OVERRIDE;
+ virtual void Stop() OVERRIDE;
+
+ private:
+ // An ExtensionApp is a pair of Extension Name and the Launch URL.
+ typedef std::pair<std::string, std::string> ExtensionApp;
+
+ virtual ~ExtensionAppProvider();
+
+ // Fetch the current app list and cache it locally.
+ void RefreshAppList();
+
+ // Register for install/uninstall notification so we can update our cache.
+ void RegisterForNotifications();
+
+ // Calculate the relevance of the match.
+ static int CalculateRelevance(AutocompleteInput::Type type,
+ bool complete,
+ bool matches_name);
+
+ // NotificationObserver implementation:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) OVERRIDE;
+
+ NotificationRegistrar registrar_;
+
+ // Our cache of ExtensionApp objects (name + url) representing the extension
+ // apps we know about.
+ std::vector<ExtensionApp> extension_apps_;
Peter Kasting 2011/03/31 21:33:59 Nit: Make this a typedef also (ExtensionApps).
Finnur 2011/04/01 15:49:36 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionAppProvider);
+};
+
+#endif // CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_
Property changes on: chrome\browser\autocomplete\extension_app_provider.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698