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

Side by Side Diff: chrome/browser/autocomplete/extension_app_provider.h

Issue 8364001: Strip special characters in extension omnibox suggestions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 // 5 //
6 // This file contains the Extension App autocomplete provider. The provider 6 // This file contains the Extension App autocomplete provider. The provider
7 // is responsible for keeping track of which Extension Apps are installed and 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 8 // their URLs. An instance of it gets created and managed by the autocomplete
9 // controller. 9 // controller.
10 // 10 //
11 // For more information on the autocomplete system in general, including how 11 // For more information on the autocomplete system in general, including how
12 // the autocomplete controller and autocomplete providers work, see 12 // the autocomplete controller and autocomplete providers work, see
13 // chrome/browser/autocomplete.h. 13 // chrome/browser/autocomplete.h.
14 14
15 #ifndef CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ 15 #ifndef CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_
16 #define CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ 16 #define CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_
17 #pragma once 17 #pragma once
18 18
19 #include <utility> 19 #include <utility>
20 #include <vector> 20 #include <vector>
21 21
22 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
23 #include "base/gtest_prod_util.h"
23 #include "chrome/browser/autocomplete/autocomplete.h" 24 #include "chrome/browser/autocomplete/autocomplete.h"
24 #include "chrome/browser/autocomplete/autocomplete_match.h" 25 #include "chrome/browser/autocomplete/autocomplete_match.h"
25 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
27 28
28 class ExtensionAppProvider : public AutocompleteProvider, 29 class ExtensionAppProvider : public AutocompleteProvider,
29 public content::NotificationObserver { 30 public content::NotificationObserver {
30 public: 31 public:
31 ExtensionAppProvider(ACProviderListener* listener, Profile* profile); 32 ExtensionAppProvider(ACProviderListener* listener, Profile* profile);
32 33
33 // Only used for testing. 34 // Only used for testing.
34 void AddExtensionAppForTesting(const string16& app_name, 35 void AddExtensionAppForTesting(const string16& app_name,
35 const string16& url); 36 const string16& url);
36 37
37 // AutocompleteProvider implementation: 38 // AutocompleteProvider implementation:
38 virtual void Start(const AutocompleteInput& input, 39 virtual void Start(const AutocompleteInput& input,
39 bool minimal_changes) OVERRIDE; 40 bool minimal_changes) OVERRIDE;
40 41
41 private: 42 private:
43 FRIEND_TEST_ALL_PREFIXES(ExtensionAppProviderTest, CreateMatchSanitize);
44
42 // An ExtensionApp is a pair of Extension Name and the Launch URL. 45 // An ExtensionApp is a pair of Extension Name and the Launch URL.
43 typedef std::pair<string16, string16> ExtensionApp; 46 typedef std::pair<string16, string16> ExtensionApp;
44 typedef std::vector<ExtensionApp> ExtensionApps; 47 typedef std::vector<ExtensionApp> ExtensionApps;
45 48
46 virtual ~ExtensionAppProvider(); 49 virtual ~ExtensionAppProvider();
47 50
51 // Construct a match for the specified parameters.
52 AutocompleteMatch CreateAutocompleteMatch(const AutocompleteInput& input,
53 const string16& name,
54 const string16& url,
55 size_t name_match_index,
56 size_t url_match_index);
57
48 // Fetch the current app list and cache it locally. 58 // Fetch the current app list and cache it locally.
49 void RefreshAppList(); 59 void RefreshAppList();
50 60
51 // Register for install/uninstall notification so we can update our cache. 61 // Register for install/uninstall notification so we can update our cache.
52 void RegisterForNotifications(); 62 void RegisterForNotifications();
53 63
54 // Calculate the relevance of the match. 64 // Calculate the relevance of the match.
55 int CalculateRelevance(AutocompleteInput::Type type, 65 int CalculateRelevance(AutocompleteInput::Type type,
56 int input_length, 66 int input_length,
57 int target_length, 67 int target_length,
58 const GURL& url); 68 const GURL& url);
59 69
60 // content::NotificationObserver implementation: 70 // content::NotificationObserver implementation:
61 virtual void Observe(int type, 71 virtual void Observe(int type,
62 const content::NotificationSource& source, 72 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE; 73 const content::NotificationDetails& details) OVERRIDE;
64 74
65 content::NotificationRegistrar registrar_; 75 content::NotificationRegistrar registrar_;
66 76
67 // Our cache of ExtensionApp objects (name + url) representing the extension 77 // Our cache of ExtensionApp objects (name + url) representing the extension
68 // apps we know about. 78 // apps we know about.
69 ExtensionApps extension_apps_; 79 ExtensionApps extension_apps_;
70 80
71 DISALLOW_COPY_AND_ASSIGN(ExtensionAppProvider); 81 DISALLOW_COPY_AND_ASSIGN(ExtensionAppProvider);
72 }; 82 };
73 83
74 #endif // CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_ 84 #endif // CHROME_BROWSER_AUTOCOMPLETE_EXTENSION_APP_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_match.cc ('k') | chrome/browser/autocomplete/extension_app_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698